其他
ggplotify - version 0.0.4
悄咪咪地更新了ggplotify
,加入了eulerr
和ComplexHeatmap
的支持。上一次的支持是pheatmap,其实ComplexHeatmap可以看成是pheatmap的扩展版本。因为ComplexHeatmap的作者,曾经修改pheatmap,搞了个pheatmap2的包,后来改着改着,另起炉灶,写出了功能最复杂的热图工具,ComplexHeatmap,真的是功能很复杂,以至于很多小白都还在用pheatmap。
eulerr实例
library(eulerr)
library(magrittr)
df <- data.frame(A = c(1, 1, 0, 1, 0, 1),
B = c(0, 0, 1, 1, 1, 1),
C = c(1, 0, 1, 0, 1, 0))
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,我很乐意加入更多的支持。当然别的包出的图,有需求也可以提一下。