Question: dendogram in R
0
gravatar for parinv
9 weeks ago by
parinv0
pune, India
parinv0 wrote:

I am following the WGCNA tutorial by Peter Langfelder and Steve Horvath. In Step-by-step network construction and module detection (2b), I am getting an error in the Merging of modules whose expression profiles are similar.

     # Calculate eigengenes
MEList = moduleEigengenes(datExpr, colors = dynamicColors)
MEs = MEList$eigengenes
# Calculate dissimilarity of module eigengenes
MEDiss = 1-cor(MEs);
# Cluster module eigengenes
METree = hclust(as.dist(MEDiss), method = "average");
# Plot the result
sizeGrWindow(7, 6)
plot(METree, main = "Clustering of module eigengenes",
xlab = "", sub = "")
MEDissThres = 0.25
# Plot the cut line into the dendrogram
abline(h=MEDissThres, col = "red")
# Call an automatic merging function
merge = mergeCloseModules(datExpr, dynamicColors, cutHeight = MEDissThres, verbose = 3)
# The merged module colors
mergedColors = merge$colors;
# Eigengenes of the new merged modules:
mergedMEs = merge$newMEs;
sizeGrWindow(12, 9)

#pdf(file = "Plots/geneDendro-3.pdf", wi = 9, he = 6)

    plotDendroAndColors(geneTree, cbind(dynamicColors, mergedColors),
    c("Dynamic Tree Cut", "Merged dynamic"),
    dendroLabels = FALSE, hang = 0.03,
    addGuide = TRUE, guideHang = 0.05)

In the final step for dendrogram, I'm facing an error:

Error in plotOrderedColors(dendro$order, colors = colors, rowLabels = rowLabels, : ERROR: length of colors vector not compatible with number of objects in 'order'.

Can anyone help with this error? Thank you.

R • 213 views
ADD COMMENTlink modified 9 weeks ago • written 9 weeks ago by parinv0
1

According to the error, you have different number of factor levels in dendro$order and in the color vector. This is, that you are either supplying too few or too many colors. Check that the length of both vectors is the same.

Hope you are able to fix it!

Jordi

ADD REPLYlink written 9 weeks ago by jordi.planells130

Did it work for you? Have you been able to solve the error? If you have, then bookmark the answer and close the question.

ADD REPLYlink written 9 weeks ago by jordi.planells130

Closing the question is not the correct way to do this. If @parinv confirms that your advice solved their problem then one of the mods can move your comment to answer. It can then be accepted by @parinv to provide closure to this thread.

ADD REPLYlink modified 9 weeks ago • written 9 weeks ago by genomax84k

That's what I meant with "If you have..." part

ADD REPLYlink written 9 weeks ago by jordi.planells130

Thank you for your reply,

  • Length of both the vectors are not same. What should i do to make it same?

  • Also I found problem in the other command:

    dynamicMods = cutreeDynamic(dendro = geneTree, distM = NULL, method = "hybrid", deepSplit = 2, pamRespectsDendro = FALSE, minClusterSize = minModuleSize,) it gives warning:

Warning message: In cutreeDynamic(dendro = geneTree, distM = NULL, method = "hybrid", : cutreeDynamic: method "hybrid" requires a valid dissimilarity matrix "distM". Defaulting to method "tree"

can you suggest what can help here?

ADD REPLYlink written 8 weeks ago by parinv0
1

Length of both the vectors are not same. What should i do to make it same?

Please trace back through your code, line by line, in order to understand what might be happening to result in the discrepancy in length between these objects.

Also I found problem in the other command:

Can you confirm that you are following the WGCNA tutorial, please?

ADD REPLYlink modified 8 weeks ago • written 8 weeks ago by Kevin Blighe60k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1795 users visited in the last hour