[R] Separating Output of Modularity Analyses
Chelsea Hinton
che|@e@rh|nton @end|ng |rom gm@||@com
Tue Nov 19 14:50:49 CET 2019
Hello,
I am working to evaluate the structure of shrub-pollinator networks using
modularity analyses. I have generated 100 null model networks to test for
modularity and extract c and z scores for each (measuring statistical
significance in real networks). However, the output of the "czvalues" for
all 100 null models comes out in one mass clump (See below code). The
highlighted section in the below code is an example of the null c and z
values. I have 17 plants in my shrub-pollinator network (represented by the
whole numbers) and so the first 17 values are the c scores followed by the
next 17 which are z scores and so on.
Is there a way I can easily separate out the c values from the z values? Or
should I instead generate 100 null networks individually?
R Code for null model generation and c and z output for nulls:
library(bipartite)
network<-read.csv(file.choose(), header = TRUE, row.names = 1)
nw<-sortweb(network)
weighted<-as.matrix(nw)
nulls <- nullmodel(weighted, N=100, method=3)
null.res <- unlist(sapply(nulls, metaComputeModules, USE.NAMES = TRUE)) #takes
a while ...
null.res
## [[1]]
## Slot "likelihood":
## [1] 0.1309568
##
##
## [[2]]
## Slot "likelihood":
## [1] 0.1303186
##
##
## [[3]]
## Slot "likelihood":
## [1] 0.14044
.............
## [[100]]
## Slot "likelihood":
## [1] 0.1332231
null.cz<-unlist(sapply(null.res, czvalues, level = "lower", USE.NAMES = TRUE
))
null.cz
## 1 2 3 4 5 6
## 0.64147140 0.74959438 0.62019013 0.65895062 0.73724490 0.72664360
## 7 8 9 10 11 12
## 0.73553719 0.57500000 0.60204082 0.66000000 0.72000000 0.37500000
## 13 14 15 16 17 1
## 0.37500000 0.77777778 0.27777778 0.44444444 0.00000000 0.70710678
## 2 3 4 5 6 7
## 0.70710678 1.10729957 1.68025904 -0.70710678 -0.12539247 0.99339927
## 8 9 10 11 12 13
## 0.62696233 0.72849280 -0.27007306 -0.86094603 -0.83722650 -0.72727630
## 14 15 16 17 1 2
## -0.86094603 -0.42633438 -0.70710678 -1.02821822 0.65504683 0.62195782
## 3 4 5 6 7 8
## 0.65606509 0.70226843 0.71777778 0.58500000 0.71500000 0.74048443
## 9 10 11 12 13 14
## 0.70000000 0.44444444 0.57142857 0.75000000 0.62500000 0.66666667
## 15 16 17 1 2 3
## 0.44444444 0.44444444 0.00000000 0.70710678 1.04053196 NA
## 4 5 6 7 8 9
## 0.70710678 -0.08671100 2.15643011 0.40204629 0.40204629 -0.47514562
Thank you for your time,
Chelsea
[[alternative HTML version deleted]]
More information about the R-help
mailing list