Derek55
2012-Oct-18 14:33 UTC
[R] WGCNA: Combining block-wise dendrograms and modules into a single figure
Hello fellow R users,
I am currently learning to use R, so please forgive me if there is an
obvious explanation for the following problem. My goal is to perform WGCNA
on a dataset of 19776 genes, so I opted to follow the block-wise network
construction (Section 2c) in the WGCNA R Tutorial by Peter Langfelder and
Steve Horvath.
I ended up with 10 blocks and am able to plot the dendrograms and module
colors for each block, but I am having trouble grouping all of the blocks
together for a single dendrogram/module color figure. On page 4 of section
2c in the WGCNA tutorial, the single-block network construction workspace is
loaded and it contains a variable called 'geneTree'. geneTree references
block 1 of the single-block network construction, which encompasses the
entire dendrogram.
geneTree = net$dendrograms[[1]]
The problem here is that I cannot perform single-block construction because
I do not have enough RAM, so I do not know how to reproduce the complete
dendrogram using the blocks that I am currently working with. If I had
simply reused the same definition for geneTree using the block-wise network,
it would simply print block 1 out of 10 blocks (I have already tried this).
Session Information:
R version 2.15.1 (2012-06-22)
Platform: i386-pc-mingw32/i386 (32-bit)
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] splines stats graphics grDevices utils datasets methods
[8] base
other attached packages:
[1] WGCNA_1.23-1 MASS_7.3-18 reshape_0.8.4
[4] plyr_1.7.1 cluster_1.14.2 Hmisc_3.9-3
[7] survival_2.36-14 flashClust_1.01-2 dynamicTreeCut_1.21
[10] impute_1.32.0
loaded via a namespace (and not attached):
[1] grid_2.15.1 lattice_0.20-6
I have tried several methods for compiling the separate dendrograms together
for the complete figure:
Input:
plotDendroAndColors(bwnet$dendrograms[[1:10]],
bwModuleColors[bwnet$blockGenes[[1:10]]],
"Module colors",
dendroLabels = FALSE, hang = 0.03,
addGuide = TRUE, guideHang = 0.05)
# Above, 'bwnew$dendrograms[[x]]' is equivalent to the parameter
specified
by 'geneTree', but must be changed each time to plot blocks 1-10
# In addition, bwModuleColors[bwnet$blockGenes[[x]]] should be changed with
the parameters for the geneTree equivalent
Output:
"Error in bwnet$blockGenes[[1:10]] : recursive indexing failed at level
2"
Input:
Same as above, changing bwnet$dendrograms[[1:10]] to bwnet$dendrograms[1:10]
and bwModuleColors[bwnet$blockGenes[[1:10]]] to
bwModuleColors[bwnet$blockGenes[1:10]]
Output:
"Error in bwModuleColors[bwnet$blockGenes[1:10]] :
invalid subscript type 'list' "
Input:
Same as above, but changed bwModuleColors[bwnet$blockGenes[1:10]] back to
bwModuleColors[bwnet$blockGenes[[1:10]]]
Output:
"Error in bwnet$blockGenes[[1:10]] : recursive indexing failed at level
2"
Any of these examples could be replicated straight from the tutorial using
the mouse data and trying to combine block 1 and block 2 without loading and
referencing the auto-network construction workspace.
Thank you very much for your time and input,
~Derek
--
View this message in context:
http://r.789695.n4.nabble.com/WGCNA-Combining-block-wise-dendrograms-and-modules-into-a-single-figure-tp4646627.html
Sent from the R help mailing list archive at Nabble.com.
Peter Langfelder
2012-Oct-18 17:17 UTC
[R] WGCNA: Combining block-wise dendrograms and modules into a single figure
Hi Derek, the simple answer is that the block-specific dendrograms cannot be meaningfully combined into a single dendrogram. You have to plot them separately. You can create a multi-panel figure that shows all block dendrograms in one big figure, although with 10 blocks I would not necessarily attempt it. One comment that does not quite relate to your question but may still be relevant is that you seem to have too many blocks. Unless you have a really old computer with 1GB RAM or less, the block size you used is likely too small. (The tutorial uses a small block size to illustrate the approach.) If you have 4GB RAM, try maxBlockSize = 8000. If you have 8GB, you can try maxBlockSize about 12000. You will get fewer blocks and most likely a better clustering/modules. Best, Peter On Thu, Oct 18, 2012 at 7:33 AM, Derek55 <derekgperez at utexas.edu> wrote:> Hello fellow R users, > > I am currently learning to use R, so please forgive me if there is an > obvious explanation for the following problem. My goal is to perform WGCNA > on a dataset of 19776 genes, so I opted to follow the block-wise network > construction (Section 2c) in the WGCNA R Tutorial by Peter Langfelder and > Steve Horvath. > > I ended up with 10 blocks and am able to plot the dendrograms and module > colors for each block, but I am having trouble grouping all of the blocks > together for a single dendrogram/module color figure. On page 4 of section > 2c in the WGCNA tutorial, the single-block network construction workspace is > loaded and it contains a variable called 'geneTree'. geneTree references > block 1 of the single-block network construction, which encompasses the > entire dendrogram. > > geneTree = net$dendrograms[[1]] > > The problem here is that I cannot perform single-block construction because > I do not have enough RAM, so I do not know how to reproduce the complete > dendrogram using the blocks that I am currently working with. If I had > simply reused the same definition for geneTree using the block-wise network, > it would simply print block 1 out of 10 blocks (I have already tried this). > > Session Information: > > R version 2.15.1 (2012-06-22) > Platform: i386-pc-mingw32/i386 (32-bit) > > locale: > [1] LC_COLLATE=English_United States.1252 > [2] LC_CTYPE=English_United States.1252 > [3] LC_MONETARY=English_United States.1252 > [4] LC_NUMERIC=C > [5] LC_TIME=English_United States.1252 > > attached base packages: > [1] splines stats graphics grDevices utils datasets methods > [8] base > > other attached packages: > [1] WGCNA_1.23-1 MASS_7.3-18 reshape_0.8.4 > [4] plyr_1.7.1 cluster_1.14.2 Hmisc_3.9-3 > [7] survival_2.36-14 flashClust_1.01-2 dynamicTreeCut_1.21 > [10] impute_1.32.0 > > loaded via a namespace (and not attached): > [1] grid_2.15.1 lattice_0.20-6 > > > > I have tried several methods for compiling the separate dendrograms together > for the complete figure: > > Input: > > plotDendroAndColors(bwnet$dendrograms[[1:10]], > bwModuleColors[bwnet$blockGenes[[1:10]]], > "Module colors", > dendroLabels = FALSE, hang = 0.03, > addGuide = TRUE, guideHang = 0.05) > > # Above, 'bwnew$dendrograms[[x]]' is equivalent to the parameter specified > by 'geneTree', but must be changed each time to plot blocks 1-10 > # In addition, bwModuleColors[bwnet$blockGenes[[x]]] should be changed with > the parameters for the geneTree equivalent > > Output: > > "Error in bwnet$blockGenes[[1:10]] : recursive indexing failed at level 2" > > Input: > > Same as above, changing bwnet$dendrograms[[1:10]] to bwnet$dendrograms[1:10] > and bwModuleColors[bwnet$blockGenes[[1:10]]] to > bwModuleColors[bwnet$blockGenes[1:10]] > > Output: > > "Error in bwModuleColors[bwnet$blockGenes[1:10]] : > invalid subscript type 'list' " > > Input: > > Same as above, but changed bwModuleColors[bwnet$blockGenes[1:10]] back to > bwModuleColors[bwnet$blockGenes[[1:10]]] > > Output: > > "Error in bwnet$blockGenes[[1:10]] : recursive indexing failed at level 2" > > Any of these examples could be replicated straight from the tutorial using > the mouse data and trying to combine block 1 and block 2 without loading and > referencing the auto-network construction workspace. > > Thank you very much for your time and input, > > ~Derek > > > > -- > View this message in context: http://r.789695.n4.nabble.com/WGCNA-Combining-block-wise-dendrograms-and-modules-into-a-single-figure-tp4646627.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.