sparseRWR {crosstalkr} | R Documentation |
Perform random walk with repeats on a sparse matrix
Description
This function borrows heavily from the RWR function in the RANKS package (cite here)
Usage
sparseRWR(seed_proteins, w, gamma = 0.6, eps = 1e-10, tmax = 1000, norm = TRUE)
Arguments
seed_proteins |
user defined seed proteins |
w |
The adjacency matrix of a given graph in sparse format - dgCMatrix |
gamma |
restart probability |
eps |
maximum allowed difference between the computed probabilities at the steady state |
tmax |
the maximum number of iterations for the RWR |
norm |
if True, w is normalized by dividing each value by the column sum. |
Value
numeric vector, affinity scores for all nodes in graph relative to provided seeds
Examples
# 1) Run Random walk with restarts on a simple matrix
v1 = (c(1,1,1,0))
v2 = c(0,0,0,1)
v3 = c(1,1,1,0)
v4 = c(0,0,0,1)
w = matrix(data = c(v1,v2,v3,v4), ncol = 4, nrow = 4)
sparseRWR(seed_proteins = c(1,3), w = w, norm = TRUE)
# 2) Works just as well on a sparse matrix
v1 = (c(1,1,1,0))
v2 = c(0,0,0,1)
v3 = c(1,1,1,0)
v4 = c(0,0,0,1)
w = matrix(data = c(v1,v2,v3,v4), ncol = 4, nrow = 4)
w = Matrix::Matrix(w, sparse = TRUE)
sparseRWR(seed_proteins = c(1,4), w = w, norm = TRUE)
#3) Sample workflow for use with human protein-protein interaction network
#g <- prep_biogrid()
#w <- igraph::as_adjacency_matrix(g)
#sparseRWR(seed_proteins = c("EGFR", "KRAS"), w = w, norm = TRUE)
[Package crosstalkr version 1.0.5 Index]