Knet(g, nperm=100, dist.method=c("shortest.paths", "diffusion", "mfpt"),
vertex.attr="pheno", edge.attr=NULL, correct.factor=1, nsteps=1000,
prob=c(0, 0.05, 0.5, 0.95, 1), parallel=NULL, B=NULL, verbose=TRUE)
igraph
object, the network to work on.
correct.factor
.
Knet
permutations.
NULL
. If parallel computing is available, this value denotes the number of cores that the computation will be split over.
g
output by the BinGraph
function. If NULL
, then B is computed within the Knet
function.
TRUE
messages about the progress of the function are displayed.
Knet
is run on the single set of vertex weights and a list containing the statistics below is returned. If more than one vertex attribute is input, then Knet
is run on each set of vertex weights and a list containing an element for each vertex attribute is returned. Each element contains a sub-list containing the statistics below for the relevant vertex attribute.NA
if no permutations are completed.NA
if no permutations are completed.NA
if no permutations are completed.NA
if no permutations are completed.The SANTA method applies Ripley's K-function, a well-established approach to spatial statistics that measures the strength of clustering of points on a plane, and extends it in a number of ways. First, a Knet function is defined by adapting the approach for networks using vertex pair distance measures. Second, vertex weights are incorporated into Knet and the importance of vertices made relative to their own associated weight. Third, the mean vertex weight is subtracted from each individual vertex weight when calculating the Knet function. This means that the Knet function measures the degree of vertex weight clustering relative to a random distribution of vertex weights. The Knet function is defined as
$$K^{net}[s]=\frac{2}{p^2} \sum_i p_i \sum_j(p_j - \bar{p}) I(d^g[i,j]<=s)$$< p="">
where $p_i$ is the weight of vertex $i$, $\bar{p}$ is the mean vertex weight across all vertices, and $I(dg[i,j]<=s)$ 1="" is="" an="" identity="" function,="" equaling="" if="" vertex="" $i$="" and="" $j$="" are="" within="" distance="" $s$="" $0$="" otherwise.="" <="" p="">
In order to derive a p-value and quantify the significance of the observed distribution of weights, the observed Knet-curve is compared to Knet-curves obtained using the same network but randomly permuted vertex weights. Vertices with missing weights (NA
) are not included within these permutations. The area under the Knet-curve (AUK) is calculated for the observed network and each of the permuted networks and a z-score used to produce a p-value. This p-value indicates the probability an observed AUK at least this high is seen given the null hypothesis that the vertex weights are randomly distributed.
If parallel computing is possible, parallel
can be used to split permutations over multiple cores. The snow
package is used to manage the parallel computing. If parallel=NULL
or parallel computing is not possible, then only one core is used. If a positive integer is input and parallel computing is possible, then the permutations are split over up to this many cores.
Vertex weights should be greater or equal that zero or equal to NA if the weight is missing.
=s)$>=s)$$<>Okabe, A. and Yamada, I. (2001). The K-function method on a network and its computational implementation Geographical Analysis. 33(3): 271-290.
Knode
# apply Knet to a network with hit clustering
g.clustered <- barabasi.game(50, directed=FALSE)
g.clustered <- SpreadHits(g.clustered, h=10, lambda=10)
res.clustered <- Knet(g.clustered, nperm=100, vertex.attr="hits")
res.clustered$pval
plot(res.clustered)
# apply Knet to a network without hit clustering
g.unclustered <- barabasi.game(50, directed=FALSE)
g.unclustered <- SpreadHits(g.unclustered, h=10, lambda=0)
res.unclustered <- Knet(g.unclustered, nperm=100, vertex.attr="hits")
res.unclustered$pval
plot(res.unclustered)
Run the code above in your browser using DataLab