Question: How to add labels to row block annotations in pheatmap?
1
gravatar for Thomas B.
3 months ago by
Thomas B.20
Thomas B.20 wrote:

Hi !

I am trying to add labels to row block annotations in pheatmap. I have the following code:

# load libraries

library("pheatmap")

# create example dataset

bins <- sample(c(1:27,50), size = 500, replace = TRUE)
list1 <- runif(500,-10,10)
list2 <- runif(500,-10,10)

dataset <- data.frame(bins, list1, list2)
dataset <- dataset[order(dataset$bins, -dataset$list1),]

# generate a vector of cumulative bincode sizes

row_gaps <- data.frame(cumsum(table(as.numeric(dataset$bins))))

# generate heatmap

pheatmap( 

  # data
  as.matrix(dataset[2:3]), annotation_row = dataset[1],

  # clustering options
  scale = "none", cluster_rows = FALSE, cluster_cols = FALSE,

  # drawing options
  legend = TRUE, legend_labels = c("10","5","0","-5","-10"),
  annotation_legend = FALSE, gaps_row = row_gaps[,1],
  show_colnames = TRUE, angle_col = 0, show_rownames = FALSE, display_numbers = FALSE    
)

Which gives the following output: enter image description here

I would like to produce something like this: enter image description here

Lists are fold changes in gene expression. Rows (genes) are divided into blocks corresponding to 'bin' identifiers. Row blocks may vary in size from one dataset to another, and numbering may not be continuous. Due to the small size of some blocks, I feel convenient to not label all of them (otherwise the labels overlap).

I have lots of datasets to process, so the idea is to not have to set anything manually.

I tried to find my way using grid.text, but only ended up with (very) approximate positioning of the labels.

Could someone help me there?

heatmap rna-seq R • 166 views
ADD COMMENTlink modified 10 weeks ago • written 3 months ago by Thomas B.20
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: 1500 users visited in the last hour