Thank you for your response. I enclose a reproducible code below:
library(WGCNA)
options(stringsAsFactors = FALSE)
n.genes = 200
n.samples=50
set.seed(0)
set.seed(0)
expr= matrix(rnorm (n.samples*n.genes), n.samples)
expr [,20:30]= expr[,30]
expr [,120:130]= expr[,120]
colnames(expr)= paste0('gene', 1:n.genes)
rownames (expr)= paste0('sample', 1:n.samples)
powers = c(c(1:10), seq(from = 12, to=30, by=4))
sft = pickSoftThreshold(expr, powerVector = powers, verbose = 5)
pwr= min( sft$fitIndices[,1][-sign(sft$fitIndices[,3])*sft$fitIndices[,2]>0.4])
net=blockwiseModules(expr, power = pwr, TOMType = "unsigned", minModuleSize = 5, #for testing reasons of this simulation
reassignThreshold = 0,mergeCutHeight = 0.25,numericLabels = TRUE,
maxBlockSize= 80,# for this simulation we'll have around 3 nets.
pamRespectsDendro = FALSE,saveTOMs = TRUE,saveTOMFileBase = "PETOM",verbose = 3)
moduleLabels = net$colors
moduleColors = labels2colors(net$colors)
MEs = net$MEs
geneTree = net$dendrograms[[1]]
plotDendroAndColors(net$dendrograms[[1]], moduleColors[net$blockGenes[[1]]],
"Module colors",
dendroLabels = F, hang = 0.03,
addGuide = TRUE, guideHang = 0.05)
dev.new()
plotDendroAndColors(net$dendrograms[[2]], moduleColors[net$blockGenes[[2]]],
"Module colors", #
dendroLabels = F, hang = 0.03,
addGuide = TRUE, guideHang = 0.05)
dev.new()
plotDendroAndColors(net$dendrograms[[3]], moduleColors[net$blockGenes[[3]]],
"Module colors",
dendroLabels = F, hang = 0.03,
addGuide = TRUE, guideHang = 0.05)
I want to put the last 3 plot in one and i used
plotDendroAndColors (hclust (dist(t(expr))), moduleColors)
which seems correct to me but I still doubt I have coded correctly. perhaps somewhere I should use
match (hclust (dist(t(expr)))$order, net$dendrograms[[1]]$order)
or something like that.
Cheers!