dRWRcontact
is supposed to estimate sample relationships (ie.
contact strength between samples) from an input gene-sample matrix, an
input graph and its affinity matrix pre-computed according to random
walk restart (RWR) of the input graph. It includes: 1) RWR-smoothed
columns of input gene-sample matrix based on the pre-computed affinity
matrix; 2) calculation of contact strength (inner products of
RWR-smooth columns of input gene-sample matrix); 3) estimation of the
contact signficance by a randomalisation procedure. Parallel computing
is also supported for Linux or Mac operating systems.
dRWRcontact(data, g, Amatrix, permutation = c("random", "degree"), num.permutation = 10, p.adjust.method = c("BH", "BY", "bonferroni", "holm", "hochberg", "hommel"), adjp.cutoff = 0.05, parallel = TRUE, multicores = NULL, verbose = T)
source("http://bioconductor.org/biocLite.R");
biocLite(c("foreach","doParallel"))
. If not yet installed, this option
will be disabledan object of class "dContact", a list with following components:
ratio
: a symmetric matrix storing ratio (the observed
against the expected) between pairwise samples
zscore
: a symmetric matrix storing zscore between pairwise
samples
pval
: a symmetric matrix storing pvalue between pairwise
samples
adjpval
: a symmetric matrix storing adjusted pvalue
between pairwise samples
cgraph
: the constructed contact graph (as a 'igraph'
object) under the cutoff of adjusted value
call
: the call that produced this result
none
# 1) generate a random graph according to the ER model g <- erdos.renyi.game(100, 1/100) # 2) produce the induced subgraph only based on the nodes in query subg <- dNetInduce(g, V(g), knn=0) V(subg)$name <- 1:vcount(subg) # 3) pre-compute affinity matrix from the input graph Amatrix <- dRWR(g=subg, parallel=FALSE)Start at 2018-01-19 12:36:55 First, get the adjacency matrix of the input graph (2018-01-19 12:36:55) ... Notes: using unweighted graph! Then, normalise the adjacency matrix using laplacian normalisation (2018-01-19 12:36:55) ... Third, RWR of 8 sets of seeds using 7.5e-01 restart probability (2018-01-19 12:36:55) ... 1 out of 8 seed sets (2018-01-19 12:36:55) 2 out of 8 seed sets (2018-01-19 12:36:55) 3 out of 8 seed sets (2018-01-19 12:36:55) 4 out of 8 seed sets (2018-01-19 12:36:55) 5 out of 8 seed sets (2018-01-19 12:36:55) 6 out of 8 seed sets (2018-01-19 12:36:55) 7 out of 8 seed sets (2018-01-19 12:36:55) 8 out of 8 seed sets (2018-01-19 12:36:55) Fourth, rescale steady probability vector (2018-01-19 12:36:55) ... Finally, output 8 by 8 affinity matrix normalised by none (2018-01-19 12:36:55) ... Finish at 2018-01-19 12:36:55 Runtime in total is: 0 secs# 4) estimate RWR-based sample relationships # define sets of seeds as data # each seed with equal weight (i.e. all non-zero entries are '1') aSeeds <- c(1,0,1,0,1) bSeeds <- c(0,0,1,0,1) data <- data.frame(aSeeds,bSeeds) rownames(data) <- 1:5 # calcualte their two contacts dContact <- dRWRcontact(data=data, g=subg, Amatrix=Amatrix, parallel=FALSE)Start at 2018-01-19 12:36:55 First, RWR on input graph (8 nodes and 8 edges) using input matrix (5 rows and 2 columns) as seeds and pre-computed affinity matrix (8 rows and 8 columns) (2018-01-19 12:36:55)... Second, calculate contact strength (2018-01-19 12:36:55)... Third, generate the distribution of contact strength based on 10 permutations on nodes respecting random (2018-01-19 12:36:55)... 1 out of 10 (2018-01-19 12:36:55) 2 out of 10 (2018-01-19 12:36:55) 3 out of 10 (2018-01-19 12:36:55) 4 out of 10 (2018-01-19 12:36:55) 5 out of 10 (2018-01-19 12:36:55) 6 out of 10 (2018-01-19 12:36:55) 7 out of 10 (2018-01-19 12:36:55) 8 out of 10 (2018-01-19 12:36:55) 9 out of 10 (2018-01-19 12:36:55) 10 out of 10 (2018-01-19 12:36:55) Last, estimate the significance of contact strength: zscore, pvalue, and BH adjusted-pvalue (2018-01-19 12:36:55)... Also, construct the contact graph under the cutoff 5.0e-02 of adjusted-pvalue (2018-01-19 12:36:55)... Finish at 2018-01-19 12:36:55 Runtime in total is: 0 secsdContact$ratio aSeeds bSeeds aSeeds 1.067951 1.085205 bSeeds 1.085205 1.065881 $zscore aSeeds bSeeds aSeeds 0.8876375 1.2074194 bSeeds 1.2074194 0.9311248 $pval aSeeds bSeeds aSeeds 0.3 0.1 bSeeds 0.1 0.2 $adjpval aSeeds bSeeds aSeeds 0.3 0.1 bSeeds 0.1 0.2 $cgraph IGRAPH a6b96ce UN-- 2 0 -- + attr: name (v/c) + edges from a6b96ce (vertex names): $call dRWRcontact(data = data, g = subg, Amatrix = Amatrix, parallel = FALSE) $method [1] "dnet" attr(,"class") [1] "dContact"