没关注?伸出手指点这里---
今天分享一个绘制 分半小提琴图 的代码,当然网上也有很多教程。
# devtools::install_github("psyteachr/introdataviz")
library(tidyverse)
library(ggpubr)
library(ggsci)
library(introdataviz)
df <- read.csv('YTHDF1_mRNA_pancan_dist.csv') %>%
filter(tissue %in% c('ACC','BLCA','KICH','KIRC','PCPG','PRAD','READ','UCS'))
colnames(df)
# [1] "tpm" "tissue" "type2" "sample" "dataset"
# check
head(df)
# tpm tissue type2 sample dataset
# 1 4.804 KIRC normal TCGA-B2-5641-11 TCGA
# 2 4.333 READ normal GTEX-WQUQ-2526-SM-4MVNO GTEX
# 3 4.583 PRAD tumor TCGA-EJ-7125-01 TCGA
# 4 4.485 PRAD tumor TCGA-KK-A7B3-01 TCGA
# 5 4.783 KIRC tumor TCGA-BP-4765-01 TCGA
# 6 3.806 KIRC tumor TCGA-CZ-5459-01 TCGA
# plot
ggplot(df,aes(x = tissue,y = tpm,fill = type2)) +
# split violin
geom_split_violin(alpha = .5, trim = F,color = NA,width = 1) +
# mean point
stat_summary(fun = "mean", geom = "point",position = position_dodge(0.2)) +
# errorbar
stat_summary(fun.data = "mean_sd", geom = "errorbar", width = .15,
size = 0.3,
position = position_dodge(0.2)) +
theme_bw(base_size = 16) +
theme(axis.text.x = element_text(angle = 90,color = 'black',hjust = 1),
legend.position = 'top') +
# scale_fill_brewer(palette = 'Set1') +
scale_fill_jco(name = '') +
ylim(1,8) +
# 添加显著性标记
stat_compare_means(aes(group=type2),
symnum.args=list(cutpoints = c(0, 0.001, 0.01, 0.05, 1),
symbols = c("***", "**", "*", "NS")),label = "p.signif",
label.y = 7,size = 5)
欢迎加入生信交流群。加我微信我也拉你进 微信群聊 老俊俊生信交流群
哦,数据代码已上传至QQ群,欢迎加入下载。
群二维码:
老俊俊微信:
知识星球:
所以今天你学习了吗?
最后欢迎大家分享转发,您的点赞是对我的鼓励和肯定!
如果觉得对您帮助很大,赏杯快乐水喝喝吧!
往期回顾
◀pysam 读取 bam 文件准备 Ribo-seq 质控数据
◀...