查看原文
其他

ggplot 绘制分半小提琴图+统计检验

JunJunLab 老俊俊的生信笔记 2022-08-15

没关注?伸出手指点这里---

1引言

今天分享一个绘制 分半小提琴图 的代码,当然网上也有很多教程。

2数据

# 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

3绘图

# 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(00.0010.010.051),
                                      symbols = c("***""**""*""NS")),label = "p.signif",
                     label.y = 7,size = 5)

4结尾




  老俊俊生信交流群 ,QQ,


老俊俊微信:


知识星球:



今天的分享就到这里了,敬请期待下一篇!

最后欢迎大家分享转发,您的点赞是对我的鼓励肯定

如果觉得对您帮助很大,赏杯快乐水喝喝吧!



  






Ribo-seq 可视化进阶

PCA 主成分分析详解

ggplot 绘制旋转的相关性图

Rsamtools 批量处理 bam 文件

GSEApy 做富集分析及可视化

pysam 读取 bam 文件准备 Ribo-seq 质控数据

sankeywheel 绘制唯美桑基图

ggplot 绘制小提琴图+箱线图+统计检验

Ribo-seq 数据上游分析

关于序列提取的问题思考

◀...

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

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