花样热图- ggmatrix

wentao

2019/12/29

这是厚哥今天新出炉的热乎的产品,我进行了测试,大家也来做一个尝试

厚缊 业余的R语言可视化重度患者个人博客:houyun.xyz邮箱:houyunhuang@163.com转载本文(包括长期转载账号)必须联系厚缊授权

写在前面:

马上19年的余额不足两天了,2020年终将到,我这段时间也是非常忙碌,希望我可以在回家之前将这两篇文章搞定。后面本来有一个工程,想在过年之前给大家来一个新年贺礼,想来一月份可能没有时间继续做了,就让赵向阳同学尽快封装起来,作为元旦礼物来回馈大家:扩增子分析V.01.exe

今天我们来了解一下花式热图 ggmatrix

这得益于厚哥写的几个图层,下面我们来尝试一下,注意ggcor我发现一个月前的都不可运行了,还是老老实实更新一下。

# install.packages("devtools")
devtools::install_github("houyunhuang/ggmatrix")
devtools::install_github("houyunhuang/ggcor")
library(ggmatrix)
# devtools::install_github("houyunhuang/ggcor")
library(ggcor)
ggmat(mtcars = mtcars) + geom_triangle(aes(fill = mtcars))

m1 <- matrix(rnorm(400, mean = 9), nrow = 20)
m2 <- matrix(rnorm(400, mean = -4), nrow = 20)
ggmat(m1 = m1, m2 = m2) +
geom_triangle(aes(fill.upper = m1, fill.lower = m2)) +
scale_fill_upper_gradientn(colours = c("red", "white", "blue")) +
scale_fill_lower_gradientn(colours = c("#E9A3C9", "#F7F7F7", "#A1D76A"))

ggmat(m1 = m1, m2 = m2, cluster = TRUE) +
geom_triangle(aes(fill.upper = m1, fill.lower = m2)) +
scale_fill_upper_gradientn(colours = c("red", "white", "blue")) +
scale_fill_lower_gradientn(colours = c("#E9A3C9", "#F7F7F7", "#A1D76A")) +
theme_cor() +
coord_fixed()

# ?geom_square

ggmat(m1 = m1) + geom_square(aes(fill = m1, r0 = m1)) +
scale_fill_gradient2n(colours = RColorBrewer::brewer.pal(11, "RdBu"),
midpoint = mean(m1)) +
scale_radius_area(midpoint = mean(m1))

ggmat(m1 = m1) + geom_ellipse2(aes(fill = m1, r0 = m1)) +
scale_fill_gradient2n(colours = RColorBrewer::brewer.pal(11, "RdBu"),
midpoint = mean(m1)) +
scale_radius_area(midpoint = mean(m1))

(0)

相关推荐