Diffbind: how to include all the samples in the heatmap while using the contrast
Entering edit mode
Last seen 4.5 years ago


I'm using Diffbind for obtaining differential binding patterns for a bunch of samples. I was wondering how I could have all the samples in the correlation heatmap while using the contrast option on a subset of samples. I would like to see the correlation map between all the samples while using only the peaks deferentially bound between a subset of samples. Here is my script:

ESR1_mutation_db_T47D <- dba(sampleSheet="C:/Users/seb10/Box Sync/esr1-mut/ChIP-seq data/Diffbind/Running_DiffBind/Meta_data_T47D.csv")

ESR1_mutation_cr_T47D <- dba.count(ESR1_mutation_db_T47D, summits = 228)

ESR1_mutation_dba_vehWT_vs_vehMut_T47D <- dba.contrast(ESR1_mutation_cr_T47D, group1 = ESR1_mutation_cr_T47D$masks$`WT-V`, group2 = ESR1_mutation_cr_T47D$masks$Mut)

ESR1_mutation_dba_vehWT_vs_Mut_T47D <- dba.analyze(ESR1_mutation_dba_vehWT_vs_Mut_T47D)
dba.plotHeatmap(ESR1_mutation_dba_vehWT_vs_Mut_T47D, contrast=1, th=1, ColAttributes = DBA_CONDITION, RowAttributes = DBA_CONDITION)

And here is my contrast:

> ESR1_mutation_dba_vehWT_vs_Mut_T47D
6 Samples, 3480 sites in matrix:
            ID Tissue Factor Condition Treatment Caller Intervals FRiP
1    T47D-WT-V     WT     ER      WT-V   Vehicle counts      3480 0.00
2    T47D-WT-E     WT     ER      WT-E        E2 counts      3480 0.01
3 T47D-Y537S-V    Mut     ER   Y537S-V   Vehicle counts      3480 0.00
4 T47D-Y537S-E    Mut     ER   Y537S-E        E2 counts      3480 0.01
5 T47D-D538G-V    Mut     ER   D538G-V   Vehicle counts      3480 0.00
6 T47D-D538G-E    Mut     ER   D538G-E        E2 counts      3480 0.03

1 Contrast:
  Group1 Members1 Group2 Members2 DB.DESeq2
1 group1        1 group2        4        46

In this case if I plot the "ESR1_mutation_dba_vehWT_vs_Mut_T47D", it only shows me 5 samples which are present in the contrast. Please let me know if you need other information.



diffbind heatmap correlation • 1.0k views
Entering edit mode
Rory Stark ★ 4.1k
Last seen 1 day ago
CRUK, Cambridge, UK

Hi Amir-

There's actually an easy way to do this in DiffBind, by setting the mask parameter in dba.plotHeatmap (or dba.plotPCA). There's an example on the help page for dba.heatmap using a contrast that excludes the T47D samples, but makes a plot using the differentially bound sites that include the T47D samples.

This should do what you want:

> dba.plotHeatmap(ESR1_mutation_dba_vehWT_vs_Mut_T47D, contrast=1, th=1,
                  ColAttributes = DBA_CONDITION, RowAttributes = DBA_CONDITION)

Two things worth noting:

  • By setting th=1, you will get all the sites, so this is the same as doing the plot without the contrast. If you want to see how the excluded sample clusters using only differentially bound sites, you need to set th to a lower threshold (default is th=0.05).
  • As you probably know, attempting to fit a GLM when there are no replicates in one of the sample groups is not really a valid thing to do. This analysis depends on replicates!




Entering edit mode

Thanks Rory, very well explained!




Login before adding your answer.

Traffic: 504 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