查看原文
其他

ggplotify - version 0.0.4

Y叔叔 YuLabSMU 2022-09-20


悄咪咪地更新了ggplotify,加入了eulerrComplexHeatmap的支持。上一次的支持是pheatmap,其实ComplexHeatmap可以看成是pheatmap的扩展版本。因为ComplexHeatmap的作者,曾经修改pheatmap,搞了个pheatmap2的包,后来改着改着,另起炉灶,写出了功能最复杂的热图工具,ComplexHeatmap,真的是功能很复杂,以至于很多小白都还在用pheatmap。

eulerr实例

library(eulerr)
library(magrittr)

df <- data.frame(A = c(110101),
                 B = c(001111),
                 C = c(101010))

u <- 
  df %>% 
  euler(.) %>%
  plot(.,
       main = "Test",
       quantities = TRUE,
       legend = list(side = "bottom")
  ) 


例子来自于:https://github.com/GuangchuangYu/ggplotify/issues/5

ComplexHeatmap实例

library(ComplexHeatmap)

p1 <- c(0.2, 0.2, 0.2, rep(0.02, 5), 0.15, 0.15)
p2 <- c(0.1, 0.1, 0.1, rep(0.02, 5), 0.3, 0.3)
n <- 10
dat1 <- rmultinom(n = n, size = 100, prob = p1)
dat2 <- rmultinom(n = n, size = 100, prob = p2)
dat <- cbind(dat1, dat2)

h <- Heatmap(dat, 
             cluster_rows = FALSE, 
             cluster_columns = FALSE, 
             show_column_names = FALSE,
             rect_gp = gpar(col = "white"),
             column_split = rep(LETTERS[1:2], each = 10))  


例子来自于:https://github.com/jokergoo/ComplexHeatmap/issues/316#issuecomment-518297612

ggplotify把它们统统变成ggplot

然后就可以用cowplot拼了。

library(ggplotify)

cowplot::plot_grid(
    as.ggplot(u), as.ggplot(h),
    labels = LETTERS[1:2], rel_widths=c(1.5))



ComplexHeatmap好像有好多对象,现在是支持Heatmap对象,如果别的对象,转不了的话,github上去提issue,我很乐意加入更多的支持。当然别的包出的图,有需求也可以提一下。

来了解一下

您可能也对以下帖子感兴趣

文章有问题?点此查看未经处理的缓存