Question: Keeping pheatmap colour range the same for different data sets
4
gravatar for as9309
3.9 years ago by
as930940
as930940 wrote:

Hi,

I've got fold change data for samples 1 and 2 from time point t1 to time point t2. I want to create a heat map using pheatmap for subsets of genes (~50-100 per set) but I want to be able to define the colour scale to be the same for all.

At the moment, R picks the range based on the highest fold change e.g.

Heat map 1: this subset has a 200 fold upregulation but no downregulation so 0 is blue and +200 is red.

Heat map 2: this subset has 100 fold down regulation in one gene and only 2 fold upregulation for another, so the range will be -100 is blue and +2 is red.

Is there a way that I can say +200 is always red and -100 is always blue and keep this range for all heat maps?

Thanks.

rna-seq pheatmap R • 28k views
ADD COMMENTlink modified 3.9 years ago by Selenocysteine600 • written 3.9 years ago by as930940

From the manual: https://cran.r-project.org/web/packages/pheatmap/pheatmap.pdf, I think you can use the breaks option.

ADD REPLYlink written 3.9 years ago by Selenocysteine600
13
gravatar for Selenocysteine
3.9 years ago by
Dublin, Ireland
Selenocysteine600 wrote:

This is sample code for the ALL dataset I downloaded from Bioconductor:

library(ALL)
library(pheatmap)
library(RColorBrewer)

# Imports the sample expression data
data("ALL")
expressionData = exprs(ALL)

# Sets the minimum (0), the maximum (15), and the increasing steps (+1) for the color scale
# Note: if some of your genes are outside of this range, they will appear white on the heatmap
breaksList = seq(0, 15, by = 1)

# Plots the first heatmap
pheatmap(expressionData[1:10, ], # Plots the first 10 genes of the dataset
         color = colorRampPalette(rev(brewer.pal(n = 7, name = "RdYlBu")))(length(breaksList)), # Defines the vector of colors for the legend (it has to be of the same lenght of breaksList)
         breaks = breaksList) # Sets the breaks of the color scale as in breaksList

# Plots the second heatmap with the same color and breaks options
pheatmap(expressionData[20:30, ], # Plots the third 10 genes of the dataset
         color = colorRampPalette(rev(brewer.pal(n = 7, name = "RdYlBu")))(length(breaksList)),
         breaks = breaksList)

First heatmap enter image description here Second heatmap enter image description here

ADD COMMENTlink written 3.9 years ago by Selenocysteine600
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: 1261 users visited in the last hour