Add annotation color bar to ggplot
1
0
Entering edit mode
da.de ▴ 20
Last seen 9 months ago
Austria

Hi,

I want to add annotation color to a normal ggplots2 figure (barplot) like it is used for example in pheatmap.

pheatmap(assay(ntd)[select,], cluster_rows=FALSE, show_rownames=FALSE, cluster_cols=FALSE, annotation_col=df)

For a pheatmap I add a df for annoation_col.
How can I do it for other figures?

Thanks for your help, best Dagmar

ggplot2 annotation • 1.9k views
0
Entering edit mode
TriS ▴ 200
@tris-5635
Last seen 2.3 years ago
United States

good examples are posted here

generally you have a data.frame that looks like

library(ggplot2)
d <- data.frame(value=sample(1:100,20),
names=rep(c("a","b","c","d"),each=5),
groups=rep(c("fancy","non-fancy"),each=10))

and then you can plot coloring/annotating based on group

ggplot(d, aes(x=names,y=value,fill=groups)) + geom_bar(stat="identity")

0
Entering edit mode

I have a bar plot with 150 samples of different groups. Some of them are negative. If I color the bars I do not see the difference between the groups, that's why I wanted to add the annotation like it is used in pheatmap. Just to show that all groups are represented equally