# A simple example from `ComplexHeatmap`
mat <- read.table(textConnection(
"s1,s2,s3
g1,snv;indel,snv,indel
g2,,snv;indel,snv
g3,snv,,indel;snv"
), row.names = 1, header = TRUE, sep = ",", stringsAsFactors = FALSE)
ggoncoplot(mat, map_width = c(snv = 0.5), map_height = c(indel = 0.9)) +
# Note that guide legends from `geom_tile` and `geom_bar` are different.
# Although they appear similar, the internal mechanisms won't collapse
# the guide legends. Therefore, we remove the guide legends from
# `geom_tile`.
guides(fill = "none") +
anno_top(size = 0.5) +
ggalign() +
geom_bar(aes(fill = value), data = function(x) {
subset(x, !is.na(value))
}) +
anno_right(size = 0.5) +
ggalign() +
geom_bar(aes(fill = value), orientation = "y", data = function(x) {
subset(x, !is.na(value))
}) &
scale_fill_brewer(palette = "Dark2", na.translate = FALSE)
Run the code above in your browser using DataLab