COmplex Network Description Of Regulators (CONDOR) implements methods for clustering bipartite networks and estimating the contribution of each node to its community’s modularity. For an application of this method to identify diesease-associated single nucleotide polymorphisms, see (https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1005033).
CONDOR can be installed through netZooR as follows:
if(!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("netZooR")
library(netZooR)
condor works with an edgelist (elist in the code below) as its input.
r = c(1,1,1,2,2,2,3,3,3,4,4);
b = c(1,2,3,1,2,4,2,3,4,3,4);
reds <- c("Alice","Sue","Janine","Mary")
blues <- c("Bob","John","Ed","Hank")
elist <- data.frame(red=reds[r], blue=blues[b])
In elist, notice all nodes of the same type–women and men in this case–appear in the same column together. This is a requirement. createCondorObject will throw an error if a node appears in both columns.
condor.object <- createCondorObject(elist)
A condor.object is just a list. You can look at the different items using names
names(condor.object)
## [1] "G" "edges" "Qcoms" "modularity" "red.memb"
## [6] "blue.memb" "qscores"
condorCluster will cluster the nodes and produce the overall modularity along with two community membership data.frames:
condor.object <- condorCluster(condor.object)
## [1] "modularity of projected graph 0"
## [1] "Q = 0"
## [1] "Q = 0.132231404958678"
## [1] "Q = 0.198347107438017"
## [1] "Q = 0.231404958677686"
## [1] "Q = 0.231404958677686"
print(condor.object$red.memb)
## red.names com
## 1 Alice 2
## 2 Janine 1
## 3 Mary 1
## 4 Sue 2
print(condor.object$blue.memb)
## blue.names com
## 1 Bob 2
## 2 Ed 1
## 3 Hank 1
## 4 John 2
Nodes in first community are {Alice, John, Bob, Sue}, nodes in second community are {Ed, Janine, Hank, Mary} based on the modularity maximization. Here’s a picture:
gtoy = graph.edgelist(as.matrix(elist),directed=FALSE)
set.graph.attribute(gtoy, "layout", layout.kamada.kawai(gtoy))
## IGRAPH 189a948 UN-- 8 11 --
## + attr: layout (g/n), name (v/c)
## + edges from 189a948 (vertex names):
## [1] Alice--Bob Alice--John Alice--Ed Bob --Sue John --Sue
## [6] Sue --Hank John --Janine Ed --Janine Hank --Janine Ed --Mary
## [11] Hank --Mary
V(gtoy)[c(reds,blues)]$color <- c(rep("red",4),rep("blue",4))
plot(gtoy,vertex.label.dist=2)
To get each node’s modularity contribution (as a fraction of the community’s modularity), run
condor.object <- condorQscore(condor.object)
If you have a subset of nodes that you think are more likely to lie at the cores of your communities, you can test this using condorCoreEnrich:
q_women <- condor.object$qscores$red.qscore
core_stats <- condorCoreEnrich(test_nodes=c("Alice","Mary"),
q=q_women,perm=TRUE,plot.hist=TRUE)
condor also works on weighted bipartite networks. The package comes with a quantitative pollination network data set (Small 1976) taken from the NCEAS interaction webs data base, containing interactions between 13 plants and 34 pollinators.
data(small1976)
condor.object <- createCondorObject(small1976)
condor.object <- condorCluster(condor.object, project=FALSE)
## [1] "modularity of projected graph 0.525346928655047"
## [1] "Q = 0.52666696475026"
## [1] "Q = 0.52666696475026"
condorPlotHeatmap(condor.object)
sessionInfo()
## R version 4.2.0 RC (2022-04-19 r82224)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 20.04.4 LTS
##
## Matrix products: default
## BLAS: /home/biocbuild/bbs-3.15-bioc/R/lib/libRblas.so
## LAPACK: /home/biocbuild/bbs-3.15-bioc/R/lib/libRlapack.so
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_GB LC_COLLATE=C
## [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
## [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] netZooR_1.0.0 yarn_1.22.0 pandaR_1.28.0
## [4] Biobase_2.56.0 BiocGenerics_0.42.0 reticulate_1.24
## [7] igraph_1.3.1
##
## loaded via a namespace (and not attached):
## [1] utf8_1.2.2 proto_1.0.0
## [3] RUnit_0.4.32 tidyselect_1.1.2
## [5] RSQLite_2.2.12 AnnotationDbi_1.58.0
## [7] grid_4.2.0 BiocParallel_1.30.0
## [9] munsell_0.5.0 base64url_1.4
## [11] codetools_0.2-18 preprocessCore_1.58.0
## [13] chron_2.3-56 pbdZMQ_0.3-7
## [15] colorspace_2.0-3 Category_2.62.0
## [17] filelock_1.0.2 highr_0.9
## [19] knitr_1.39 uuid_1.1-0
## [21] stats4_4.2.0 MatrixGenerics_1.8.0
## [23] repr_1.1.4 GenomeInfoDbData_1.2.8
## [25] bit64_4.0.5 rhdf5_2.40.0
## [27] downloader_0.4 vctrs_0.4.1
## [29] generics_0.1.2 xfun_0.30
## [31] BiocFileCache_2.4.0 R6_2.5.1
## [33] doParallel_1.0.17 GenomeInfoDb_1.32.0
## [35] illuminaio_0.38.0 RJSONIO_1.3-1.6
## [37] locfit_1.5-9.5 bitops_1.0-7
## [39] rhdf5filters_1.8.0 cachem_1.0.6
## [41] reshape_0.8.9 DelayedArray_0.22.0
## [43] assertthat_0.2.1 BiocIO_1.6.0
## [45] scales_1.2.0 nnet_7.3-17
## [47] gtable_0.3.0 rlang_1.0.2
## [49] genefilter_1.78.0 splines_4.2.0
## [51] rtracklayer_1.56.0 GEOquery_2.64.0
## [53] hexbin_1.28.2 reshape2_1.4.4
## [55] yaml_2.3.5 GenomicFeatures_1.48.0
## [57] backports_1.4.1 RBGL_1.72.0
## [59] tools_4.2.0 nor1mix_1.3-0
## [61] ggplot2_3.3.5 ellipsis_0.3.2
## [63] gplots_3.1.3 jquerylib_0.1.4
## [65] RColorBrewer_1.1-3 ggdendro_0.1.23
## [67] siggenes_1.70.0 STRINGdb_2.8.0
## [69] gsubfn_0.7 hash_2.2.6.2
## [71] Rcpp_1.0.8.3 plyr_1.8.7
## [73] base64enc_0.1-3 sparseMatrixStats_1.8.0
## [75] progress_1.2.2 zlibbioc_1.42.0
## [77] purrr_0.3.4 RCurl_1.98-1.6
## [79] prettyunits_1.1.1 sqldf_0.4-11
## [81] openssl_2.0.0 bumphunter_1.38.0
## [83] S4Vectors_0.34.0 cluster_2.1.3
## [85] SummarizedExperiment_1.26.0 fs_1.5.2
## [87] magrittr_2.0.3 data.table_1.14.2
## [89] matrixStats_0.62.0 hms_1.1.1
## [91] evaluate_0.15 xtable_1.8-4
## [93] XML_3.99-0.9 mclust_5.4.9
## [95] IRanges_2.30.0 compiler_4.2.0
## [97] biomaRt_2.52.0 minfi_1.42.0
## [99] tibble_3.1.6 RCy3_2.16.0
## [101] KernSmooth_2.23-20 crayon_1.5.1
## [103] htmltools_0.5.2 GOstats_2.62.0
## [105] mgcv_1.8-40 tzdb_0.3.0
## [107] tidyr_1.2.0 DBI_1.1.2
## [109] dbplyr_2.1.1 MASS_7.3-57
## [111] rappdirs_0.3.3 Matrix_1.4-1
## [113] readr_2.1.2 permute_0.9-7
## [115] cli_3.3.0 quantro_1.30.0
## [117] uchardet_1.1.0 quadprog_1.5-8
## [119] parallel_4.2.0 GenomicRanges_1.48.0
## [121] pkgconfig_2.0.3 GenomicAlignments_1.32.0
## [123] IRdisplay_1.1 xml2_1.3.3
## [125] foreach_1.5.2 annotate_1.74.0
## [127] penalized_0.9-52 bslib_0.3.1
## [129] rngtools_1.5.2 multtest_2.52.0
## [131] beanplot_1.3.1 XVector_0.36.0
## [133] AnnotationForge_1.38.0 doRNG_1.8.2
## [135] scrime_1.3.5 stringr_1.4.0
## [137] digest_0.6.29 vegan_2.6-2
## [139] graph_1.74.0 Biostrings_2.64.0
## [141] rmarkdown_2.14 base64_2.0
## [143] edgeR_3.38.0 DelayedMatrixStats_1.18.0
## [145] GSEABase_1.58.0 restfulr_0.0.13
## [147] curl_4.3.2 Rsamtools_2.12.0
## [149] gtools_3.9.2 rjson_0.2.21
## [151] lifecycle_1.0.1 nlme_3.1-157
## [153] jsonlite_1.8.0 Rhdf5lib_1.18.0
## [155] viridisLite_0.4.0 askpass_1.1
## [157] limma_3.52.0 fansi_1.0.3
## [159] pillar_1.7.0 lattice_0.20-45
## [161] plotrix_3.8-2 KEGGREST_1.36.0
## [163] fastmap_1.1.0 httr_1.4.2
## [165] survival_3.3-1 GO.db_3.15.0
## [167] glue_1.6.2 png_0.1-7
## [169] iterators_1.0.14 bit_4.0.4
## [171] Rgraphviz_2.40.0 stringi_1.7.6
## [173] sass_0.4.1 HDF5Array_1.24.0
## [175] blob_1.2.3 org.Hs.eg.db_3.15.0
## [177] caTools_1.18.2 memoise_2.0.1
## [179] IRkernel_1.3 dplyr_1.0.8