Module detection¶
Coral¶
WGCNA: Module detection
Library
library(WGCNA)
enableWGCNAThreads(nThreads = 10)
## Allowing parallel execution with up to 10 working processes.
sessionInfo()
## R version 3.6.1 (2019-07-05)
## Platform: x86_64-conda_cos6-linux-gnu (64-bit)
## Running under: CentOS Linux 7 (Core)
##
## Matrix products: default
## BLAS/LAPACK: /yshare1/home/toru/anaconda3/envs/wgcna/lib/R/lib/libRblas.so
##
## locale:
## [1] LC_CTYPE=ja_JP.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=ja_JP.UTF-8 LC_COLLATE=ja_JP.UTF-8
## [5] LC_MONETARY=ja_JP.UTF-8 LC_MESSAGES=ja_JP.UTF-8
## [7] LC_PAPER=ja_JP.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=ja_JP.UTF-8 LC_IDENTIFICATION=C
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] WGCNA_1.69 fastcluster_1.1.25 dynamicTreeCut_1.63-1
## [4] rmarkdown_1.12
##
## loaded via a namespace (and not attached):
## [1] Rcpp_1.0.1 lattice_0.20-38 GO.db_3.10.0
## [4] png_0.1-7 digest_0.6.18 foreach_1.5.0
## [7] R6_2.4.1 backports_1.1.7 acepack_1.4.1
## [10] stats4_3.6.1 RSQLite_2.2.0 evaluate_0.13
## [13] ggplot2_3.3.1 pillar_1.4.4 rlang_0.4.6
## [16] data.table_1.12.8 rstudioapi_0.11 blob_1.2.1
## [19] S4Vectors_0.24.4 rpart_4.1-15 Matrix_1.2-17
## [22] preprocessCore_1.48.0 checkmate_2.0.0 splines_3.6.1
## [25] stringr_1.4.0 foreign_0.8-71 htmlwidgets_1.5.1
## [28] bit_1.1-15.2 munsell_0.5.0 compiler_3.6.1
## [31] xfun_0.6 pkgconfig_2.0.3 BiocGenerics_0.32.0
## [34] base64enc_0.1-3 htmltools_0.3.6 nnet_7.3-12
## [37] tibble_3.0.1 gridExtra_2.3 htmlTable_1.13.3
## [40] Hmisc_4.4-0 IRanges_2.20.2 codetools_0.2-16
## [43] matrixStats_0.56.0 crayon_1.3.4 grid_3.6.1
## [46] gtable_0.3.0 lifecycle_0.2.0 DBI_1.1.0
## [49] magrittr_1.5 scales_1.1.1 impute_1.60.0
## [52] stringi_1.4.3 doParallel_1.0.15 latticeExtra_0.6-29
## [55] ellipsis_0.3.1 vctrs_0.3.0 Formula_1.2-3
## [58] RColorBrewer_1.1-2 iterators_1.0.12 tools_3.6.1
## [61] bit64_0.9-7 Biobase_2.46.0 glue_1.3.1
## [64] jpeg_0.1-8.1 parallel_3.6.1 survival_3.1-12
## [67] yaml_2.2.0 AnnotationDbi_1.48.0 colorspace_1.4-1
## [70] cluster_2.0.8 memoise_1.1.0 knitr_1.22
Load files
load("2.1.c_WGCNA_ThresholdingPower.UT.RData")
Co-expresion network analysis
softPower = min(sft.c$fitIndices$Power[sft.c$fitIndices$SFT.R.sq > 0.8])
softPower
## [1] 14
# Adjacency matrix
adj.c = adjacency(mat.c,
power = softPower,
type = "signed")
# Topological overlap matrix
TOM.c = TOMsimilarity(adj.c,
TOMType = "signed")
## ..connectivity..
## ..matrix multiplication (system BLAS)..
## ..normalization..
## ..done.
dissTOM.c = 1 - TOM.c
# Hierarchical clustering with dissTOM
tree.c = hclust(as.dist(dissTOM.c), method = "average")
save(dissTOM.c, tree.c, file="2.2.c_WGCNA.TOM.UT.RData")
Module detection
minModuleSize = 30
dynamicMods = cutreeDynamic(dendro = tree.c,
distM = dissTOM.c,
deepSplit = 2,
pamRespectsDendro = FALSE,
minClusterSize = minModuleSize)
## ..cutHeight not given, setting it to 0.998 ===> 99% of the (truncated) height range in dendro.
## ..done.
dynamicColors = labels2colors(dynamicMods)
modules.c = list()
thresholds = seq(0, 0.3, by =0.05)
pdf("2.2.c_WGCNA.Tree.pdf", 6, 5)
for(t in thresholds){
tmp = mergeCloseModules(mat.c,
dynamicColors,
cutHeight=t,
verbose=3)
modules.c[[as.character(t)]] = tmp
plotDendroAndColors(tree.c,
data.frame(Module=tmp$colors),
dendroLabels = F,
addGuide = T,
guideHang = 0.05)
}
## mergeCloseModules: Merging modules whose distance is less than 0
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 49 module eigengenes in given set.
## Calculating new MEs...
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 49 module eigengenes in given set.
## mergeCloseModules: Merging modules whose distance is less than 0.05
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 49 module eigengenes in given set.
## Calculating new MEs...
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 49 module eigengenes in given set.
## mergeCloseModules: Merging modules whose distance is less than 0.1
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 49 module eigengenes in given set.
## Calculating new MEs...
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 49 module eigengenes in given set.
## mergeCloseModules: Merging modules whose distance is less than 0.15
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 49 module eigengenes in given set.
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 41 module eigengenes in given set.
## Calculating new MEs...
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 41 module eigengenes in given set.
## mergeCloseModules: Merging modules whose distance is less than 0.2
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 49 module eigengenes in given set.
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 39 module eigengenes in given set.
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 36 module eigengenes in given set.
## Calculating new MEs...
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 36 module eigengenes in given set.
## mergeCloseModules: Merging modules whose distance is less than 0.25
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 49 module eigengenes in given set.
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 34 module eigengenes in given set.
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 30 module eigengenes in given set.
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 29 module eigengenes in given set.
## Calculating new MEs...
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 29 module eigengenes in given set.
## mergeCloseModules: Merging modules whose distance is less than 0.3
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 49 module eigengenes in given set.
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 32 module eigengenes in given set.
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 28 module eigengenes in given set.
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 27 module eigengenes in given set.
## Calculating new MEs...
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 27 module eigengenes in given set.
dev.off()
## png
## 2
save(modules.c, file="2.2.c_WGCNA.Modules.UT.RData")
Zooxanthellae¶
WGCNA: Module detection
Library
library(WGCNA)
enableWGCNAThreads(nThreads = 10)
## Allowing parallel execution with up to 10 working processes.
sessionInfo()
## R version 3.6.1 (2019-07-05)
## Platform: x86_64-conda_cos6-linux-gnu (64-bit)
## Running under: CentOS Linux 7 (Core)
##
## Matrix products: default
## BLAS/LAPACK: /yshare1/home/toru/anaconda3/envs/wgcna/lib/R/lib/libRblas.so
##
## locale:
## [1] LC_CTYPE=ja_JP.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=ja_JP.UTF-8 LC_COLLATE=ja_JP.UTF-8
## [5] LC_MONETARY=ja_JP.UTF-8 LC_MESSAGES=ja_JP.UTF-8
## [7] LC_PAPER=ja_JP.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=ja_JP.UTF-8 LC_IDENTIFICATION=C
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] WGCNA_1.69 fastcluster_1.1.25 dynamicTreeCut_1.63-1
## [4] rmarkdown_1.12
##
## loaded via a namespace (and not attached):
## [1] Rcpp_1.0.1 lattice_0.20-38 GO.db_3.10.0
## [4] png_0.1-7 digest_0.6.18 foreach_1.5.0
## [7] R6_2.4.1 backports_1.1.7 acepack_1.4.1
## [10] stats4_3.6.1 RSQLite_2.2.0 evaluate_0.13
## [13] ggplot2_3.3.1 pillar_1.4.4 rlang_0.4.6
## [16] data.table_1.12.8 rstudioapi_0.11 blob_1.2.1
## [19] S4Vectors_0.24.4 rpart_4.1-15 Matrix_1.2-17
## [22] preprocessCore_1.48.0 checkmate_2.0.0 splines_3.6.1
## [25] stringr_1.4.0 foreign_0.8-71 htmlwidgets_1.5.1
## [28] bit_1.1-15.2 munsell_0.5.0 compiler_3.6.1
## [31] xfun_0.6 pkgconfig_2.0.3 BiocGenerics_0.32.0
## [34] base64enc_0.1-3 htmltools_0.3.6 nnet_7.3-12
## [37] tibble_3.0.1 gridExtra_2.3 htmlTable_1.13.3
## [40] Hmisc_4.4-0 IRanges_2.20.2 codetools_0.2-16
## [43] matrixStats_0.56.0 crayon_1.3.4 grid_3.6.1
## [46] gtable_0.3.0 lifecycle_0.2.0 DBI_1.1.0
## [49] magrittr_1.5 scales_1.1.1 impute_1.60.0
## [52] stringi_1.4.3 doParallel_1.0.15 latticeExtra_0.6-29
## [55] ellipsis_0.3.1 vctrs_0.3.0 Formula_1.2-3
## [58] RColorBrewer_1.1-2 iterators_1.0.12 tools_3.6.1
## [61] bit64_0.9-7 Biobase_2.46.0 glue_1.3.1
## [64] jpeg_0.1-8.1 parallel_3.6.1 survival_3.1-12
## [67] yaml_2.2.0 AnnotationDbi_1.48.0 colorspace_1.4-1
## [70] cluster_2.0.8 memoise_1.1.0 knitr_1.22
Load files
load("2.1.z_WGCNA_ThresholdingPower.UT.RData")
Co-expresion network analysis
softPower = sft.z$fitIndices$Power[sft.z$fitIndices$SFT.R.sq > 0.8]
softPower = min(softPower[softPower > 5])
softPower
## [1] 23
# adjacency matrix
adj.z = adjacency(mat.z,
power = softPower,
type = "signed")
# Topological overlap matrix
TOM.z = TOMsimilarity(adj.z,
TOMType = "signed")
## ..connectivity..
## ..matrix multiplication (system BLAS)..
## ..normalization..
## ..done.
dissTOM.z = 1 - TOM.z
# Hierarchical clustering with dissTOM
tree.z = hclust(as.dist(dissTOM.z), method = "average")
save(dissTOM.z, tree.z, file="2.2.z_WGCNA.TOM.UT.RData")
Module detection
minModuleSize = 30
dynamicMods = cutreeDynamic(dendro = tree.z,
distM = dissTOM.z,
deepSplit = 2,
pamRespectsDendro = FALSE,
minClusterSize = minModuleSize)
## ..cutHeight not given, setting it to 0.999 ===> 99% of the (truncated) height range in dendro.
## ..done.
dynamicColors = labels2colors(dynamicMods)
modules.z = list()
thresholds = seq(0, 0.3, by =0.05)
pdf("2.2.z_WGCNA.Tree.pdf", 6, 5)
for(t in thresholds){
tmp = mergeCloseModules(mat.z,
dynamicColors,
cutHeight=t,
verbose=3)
modules.z[[as.character(t)]] = tmp
plotDendroAndColors(tree.z,
data.frame(Module=tmp$colors),
dendroLabels = F,
addGuide = T,
guideHang = 0.05)
}
## mergeCloseModules: Merging modules whose distance is less than 0
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 58 module eigengenes in given set.
## Calculating new MEs...
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 58 module eigengenes in given set.
## mergeCloseModules: Merging modules whose distance is less than 0.05
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 58 module eigengenes in given set.
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 52 module eigengenes in given set.
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 50 module eigengenes in given set.
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 49 module eigengenes in given set.
## Calculating new MEs...
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 49 module eigengenes in given set.
## mergeCloseModules: Merging modules whose distance is less than 0.1
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 58 module eigengenes in given set.
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 42 module eigengenes in given set.
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 38 module eigengenes in given set.
## Calculating new MEs...
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 38 module eigengenes in given set.
## mergeCloseModules: Merging modules whose distance is less than 0.15
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 58 module eigengenes in given set.
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 35 module eigengenes in given set.
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 31 module eigengenes in given set.
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 30 module eigengenes in given set.
## Calculating new MEs...
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 30 module eigengenes in given set.
## mergeCloseModules: Merging modules whose distance is less than 0.2
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 58 module eigengenes in given set.
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 32 module eigengenes in given set.
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 28 module eigengenes in given set.
## Calculating new MEs...
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 28 module eigengenes in given set.
## mergeCloseModules: Merging modules whose distance is less than 0.25
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 58 module eigengenes in given set.
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 27 module eigengenes in given set.
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 24 module eigengenes in given set.
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 23 module eigengenes in given set.
## Calculating new MEs...
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 23 module eigengenes in given set.
## mergeCloseModules: Merging modules whose distance is less than 0.3
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 58 module eigengenes in given set.
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 22 module eigengenes in given set.
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 16 module eigengenes in given set.
## Calculating new MEs...
## multiSetMEs: Calculating module MEs.
## Working on set 1 ...
## moduleEigengenes: Calculating 16 module eigengenes in given set.
dev.off()
## png
## 2
save(modules.z, file="2.2.z_WGCNA.Modules.UT.RData")