WGCNA HeatMap correlating modules and sample conditions
Entering edit mode
2.1 years ago
Raito92 ▴ 90

Hello everyone, I'm new to WGCNA analysis... I'm trying to carry out one by using WGCNA Bioconductor Package. Being a newbie, I'm sticking to the official tutorial. In the Section 4 of the Tutorial it's explained how to create a heatmap correlating the previously obtained modules with sample quantitative traits (such as, for instance, phenotypical, measurable traits), as shown below:

enter image description here

However, I'd need a heatmap showing the correlations between the previously obtained modules and sample conditions instead. This will significantly help me to pick the most significant modules and further analyze them in Cytoscape, highlighting how they correlate with my experimental conditions immediately (for instance, the red module has a positive correlation with samples injected with the pathogen, the purple one with samples collected from root... and so on). The heatmap would look similar to this one (however, here the correlation is between modules and samples, not between modules and samples clustered by condition...from this other tutorial.

enter image description here

Any suggestions about how to create this kind of heatmap?

Thanks in advance for your help, have a nice day.

RNAseq heatmap WGCNA conditions clustering • 2.2k views
Entering edit mode
2.1 years ago
LauferVA 4.2k


  1. Grab modules from your WGCNA output
  2. Grab your sample names as well as relevant grouping / blocking variables (for use in clustering) from your metadata file.
  3. Find the appropriate arguments, and feed into pheatmap.

I think a different program was used to make the above HM (because the colors appear different than I am used to seeing from pheatmap), but you shouldn't have any trouble at all making a diagram that is identical except for stylistically.

Entering edit mode

Hi, thank you for the (very quick!) answer. The official tutorial (first heatmap shown here) adopted labeledHeatmap. The second plot was created through ggplot.

Do you have a pheatmap usage example in a WGCNA context?

Entering edit mode

Hi again, no, I typically just create what I need.

In one of the WGCNA output files, you should have an object containing a list of all the sample IDs, then the cluster score for each. However this is formatted at present, you want to reformat it such that it is a matrix with row names being the gene module names and column names being the sample IDs. It's pretty likely that whatever output file you have is pretty close to that already. If not, paste the format of the output you do have as well as the format for the metadata you need in your original post and wee can go from there.

Entering edit mode

Hi LauferVA

gene_id colors
ENSG00000121410.12  turquoise
ENSG00000148584.16  turquoise
ENSG00000128274.17  turquoise
ENSG00000094914.14  turquoise
ENSG00000081760.17  black
ENSG00000103591.13  blue
ENSG00000115977.21  red
ENSG00000087884.16  turquoise
ENSG00000127837.10  blue
ENSG00000131043.13  yellow
ENSG00000205002.4   turquoise
ENSG00000090861.17  turquoise
ENSG00000124608.5   turquoise
ENSG00000266967.7   black
ENSG00000157426.14  turquoise

this is what i got as one ouput

another output is where i got (i guess) the correlation / cluster score of these in each sample

samples B1  B10 B11 B12 B13 B14 B15 B16
black   -0.029917627    0.008215218 0.00298303  -0.058609333    -0.0108937  0.032304968 -0.00712045 -0.043307876
blue    -0.19572086 0.034153279 0.049654506 0.030429713 0.05364303  0.049925743 -0.02128837 -0.014778403
brown   -0.059783447    0.065474055 0.084536969 -0.087345215    0.123531196 0.059711078 -0.159681571    -0.162748366
cyan    -0.198371587    -0.021083951    -0.050028852    0.094992144 -0.039469236    0.008094565 0.159868263 0.192145868
green   -0.134498917    0.047227554 0.084184572 -0.019087064    0.091375625 0.072386592 -0.171160482    -0.154354049
greenyellow -0.062892188    0.009824482 0.114381523 -0.140938531    -0.244207578    0.135514557 0.068088079 0.111446206
grey    0.1098187   0.072746354 -0.020492397    -0.091551334    0.02884783  0.069656351 0.135998064 0.06916196
magenta -0.251199011    -0.046513272    0.040336461 0.121265223 0.024140415 -0.024805459    -0.081755285    -0.072516821
pink    -0.189959424    0.048842012 -0.015831729    -0.016891322    -0.010951634    0.079484222 0.137488993 0.124954037

Also i have a sheet where the categorization is listed of my samples

IGIB1130567172  mild    M1
IGIB113002393843    mild    M2
IGIB113002298284    mild    M3
IGIB1130924841  mild    M4
IGIB113002224539    mild    M5
IGIB1130143348  mild    M6
IGIB1130482394  moderate    B1
IGIB1130491776  moderate    B2
IGIB113002311561    moderate    B3
IGIB1130926534  moderate    B4
IGIB113002365734    moderate    B5
IGIB1130395724  moderate    B6
IGIB1130483166  moderate    B7
IGIB113002317760    moderate    B8
IGIB113060368   moderate    B9
IGIB1130493597  moderate    B10
IGIB1130922137  moderate    B11
IGIB1130478750  moderate    B12
IGIB1130922387  moderate    B13
IGIB1130259880  severe  S1
IGIB113002313519    severe  S2
IGIB1130271063  severe  S3
IGIB113002307585    severe  S4

I tried this pheatmap:

cluster pheatmap

Why don't i see a single gene cluster (module) to be correlated positively or negatively for at least one group?? (ALSO I HAVE 45 IN MILD, 46 IN MODERATE AND 21 IN SEVERE, SO ISN'T IT SENSIBLE TO SEE CORRELATION OF MODULES IN ALL SAMPLES OF EITHER GROUP)

Entering edit mode


Also if anyone can comment on how can we have a heatmap of genes vs sample_conditions like in above query (gene names vs groups: mild, moderate and severe)



Login before adding your answer.

Traffic: 833 users visited in the last hour
Help About
Access RSS

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6