差異表達分析中通常需要利用箱線圖或者小提琴圖來對幾組具有差異的表達值進行可視化表示。
同時,基于T.test, wilcox.test等檢驗差異顯著性。
利用ggpubr包可以同時解決上面兩個問題。
exp1 <- rnorm(n=100,mean=10)
exp2 <- rnorm(n=100,mean=33)
data.input <- data.frame(exp = c(exp1,exp2),Type = c(rep('T',length(exp1)),rep('N',length(exp2))))
##ggviolin 繪制小提琴圖, add = 'boxplot', 在小提琴圖中同時加入箱線圖
ggviolin(data = data.input ,x='Type',y='exp',fill='Type',
? ? ? ? palette = c("#00AFBB","#FC4E07"),add = "boxplot",add.params = list(fill="white"))+
? stat_compare_means(comparisons=list(c('N','T')),label = "p.signif")
出現(xiàn)下圖:

也可以對多組數(shù)據(jù)同時進行處理:
data.input$From <- c(rep(c('A','B','C','D'),50))
通過設定facet.by='From',進行分組可視化分析
ggviolin(data = data.input ,x='Type',y='exp',fill='Type',ylim = c(5,40),
? ? ? ? palette = c("#00AFBB","#FC4E07"),facet.by = 'From',add = "boxplot",add.params = list(fill="white"))+
? stat_compare_means(comparisons=list(c('N','T')),label = "p.signif")
結果如下圖

將ggviolin替換為ggboxplot則為箱線圖和顯著性標注結果。
感謝ggpubr包,不同手動添加各種統(tǒng)計顯著性了。