This is a test version of Biostars. For the public version, visit https://www.biostars.org.
WGCNA "trait" file format?

I am trying to create co-expression network between lncRNA and RNA but I am not sure if the "trait" file I have made is correct. I have 14 samples with two conditions "Nodules" and "ctrl". Is this format right?

Client  group
X3  1
X4  1
X5  1
X6  1
X8  1
X9  1
X10 1
X11 1
X15 1
X16 1
X17 1
X128    0
X129    0
X130    0
rna-seq sequencing r gene

Did you try using this file and it didn't work, that's why you are asking it? Or you didn't try it? Looks ok to me.

It worked. but I was not sure if the results are correct. I am getting an error while generating the heatmap, so I was not confident.

labeledHeatmap(Matrix = moduleTraitCor,
               xLabels = names(datTraits),
               yLabels = names(MEs),
               ySymbols = names(MEs),
               colorLabels = FALSE,
               colors = greenWhiteRed(50),
               textMatrix = textMatrix,
               setStdMargins = FALSE,
               cex.text = 0.5,
               zlim = c(-1,1),
               main = paste("Module-trait relationships"))

Error in colorMatrix[, c] : incorrect number of dimensions

Somethings seems to be wrong in your colormatrix. Try making the heatmap with default colors. Use blueWhiteRed instead of greenWhiteRed.

Still the same error :(

Yes over there also you see it is related to color scale. Could also be related to difference in row names of phenodata and sample ids.

1 answer

ploting heatmap using complexheatmap alternative to labeledHeatmap

# Define numbers of genes and samples
nGenes = ncol(datExpr);
nSamples = nrow(datExpr);
# Recalculate MEs with color labels
MEs0 = moduleEigengenes(datExpr, dynamicColors)$eigengenes
MEs = orderMEs(MEs0)
moduleTraitCor = cor(MEs, datTraits$group, use = "p");
moduleTraitPvalue = corPvalueStudent(moduleTraitCor, nSamples);


sizeGrWindow(10,6)
# Will display correlations and their p-values
textMatrix = paste(signif(moduleTraitCor, 2), "(",signif(moduleTraitPvalue, 1), ")", sep = "");
dim(textMatrix) = dim(moduleTraitCor)
# Display the correlation values within a heatmap plot
Heatmap(moduleTraitCor,
              name = "Cor",
              column_title="Module-trait relationships",
              rect_gp = gpar(col = "black"),
              cell_fun = function(j, i, x, y, width, height, fill) {
              grid.text(sprintf(textMatrix[i, j]), x, y, gp = gpar(fontsize = 10))})

Log in to answer this question.