简体   繁体   中英

Only one bar when making stacked barplot as annotation

I am trying to make a stacked barplot as column annotation on a heatmap. I use ComplexHeatmap .

This is the input (foo) for the barplot:

      V1    V2    V3
1  28.50 67.30  0.00
2   0.00 63.90 25.40
3  16.30 67.80 15.90
4  24.10 75.30  0.00
5   0.00 70.90 20.60
6  18.90 62.50 13.90
7  19.80 68.70 11.50
8  22.60 64.90 10.10
9  28.10 66.80  0.00
10 16.60 74.30  0.08
11  0.14 79.90  0.06
12 23.70  0.71  0.00
13 26.70 66.60  0.00
14 16.80 58.20 20.60
15 13.30 82.20  0.00
16  0.32 61.70  6.30
17 21.50 62.20  0.14

To make it simple, I have removed the other annotations and the heatmap and just make the "troublesome" annotation plot. This is my code:

library(ComplexHeatmap)
ha = HeatmapAnnotation(barplot = anno_barplot(foo), annotation_height = unit(30,"mm"))
hm = Heatmap(zero_row_mat, top_annotation = ha)
hm

And this is the resulting barplot 在此处输入图片说明

Reading the ComplexHeatmap reference manual, I would have expected a stacked barplot since my input is a matrix (with more than 1 column), but instead I get only one bar. I can't figure out what I am doing wrong. Any ideas?

You're right, when I run:

DF <- data.frame( A = rep(c(0,5), 5), B = 2:11, C = 3:12 )
hb = HeatmapAnnotation(barplot = anno_barplot(DF), annotation_height = unit(30,"mm"))
hm = Heatmap(matrix(1:10,nrow=1), top_annotation = hb)
hm

I get a stacked barplot. What do you get?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM