最近在搜集好看的图的时候,看到了一幅下面这样的图:
图来自文献:《
Benzo[a]pyrene stress impacts adaptive strategies and ecological functions of earthworm intestinal viromes
》。
简单搜索了一下,
这种图因为上部分的密度曲线像一朵云,下面的三点像云层下面下着的雨,形象的叫云雨图!
它用于展示多个数据集的分布:
结合了小提琴展示的数据密度区域,箱线图展示的四分位数,以及散点图展示的具体的每一个点的分布!
又学到了~
图注:
Fig. 3 Composition and lifestyle of earthworm gut virome. G Abundance (Log10 RPKM) of prophage.
学习绘制
搜了一个学习资料:
https://jtr13.github.io/cc21fall2/raincloud-plot-101-density-plot-or-boxplotwhy-not-do-both.html
下面来看看怎么绘制吧!
首先需要安装包
半个扁平的小提琴来自包:https://github.com/PsyTeachR/introdataviz, 后面用到的函数为:geom_flat_violin
# you may have to install devtools first with
# install.packages("devtools")
devtools::install_github("psyteachr/introdataviz")
library(introdataviz)
加载一下其他所需要的包:
library(tidyverse)
library(magrittr)
library(ggplot2)
library(reshape2)
library(ggsci)
读取数据
我这里用了一个基因表达矩阵,每一行为一个基因,每一列为一个样本:示例数据可以找我,微信:Biotree123,后面放到github上面:
https://github.com/zhangj1115/example_data
df <- read.table("Expression.txt",header = T,sep = "\t"