一机隙、前言
今天也繼續(xù)分享一下使用R語言繪制云雨圖
,這個圖形的繪制在基于R 語言繪制柱狀圖教程混合整理教程中也有提及,如果感興趣可以自己看一下。
二、繪圖
導(dǎo)入相關(guān)的包
library(ggplot2)
#devtools::install_github("GuangchuangYu/gglayer")
library(gglayer)
###'@提供geom_flat_violin()函數(shù)
# install.packages("remotes")
# remotes::install_github("kholsteen/geneRal")
library(geneRal)
數(shù)據(jù)就使用上期的數(shù)據(jù)即可栽渴,如不知道,請看R語言精美圖形繪制系列 | 箱線圖繪制稳懒。
導(dǎo)入數(shù)據(jù)
y <- read.csv("inputdata.csv",headr = T)
#計算每個分組的平均值
y.mean <- aggregate(.~Var1,y,mean)
m <- y.mean$value
names(m) <- y.mean$Var1
#按平均值給分組排序闲擦,便于畫圖
y$Var1 <- factor(y$Var1, levels=names(sort(m)))
繪圖
- 基礎(chǔ)圖形
ggplot(y, aes(Var1, value, fill = Var1))+
geom_flat_violin()+
theme(legend.position = "none")
- 其他類型
ggplot(y, aes(Var1, value, fill = Var1))+
geom_flat_violin(position = position_nudge(x = .2, y = 0))+
geom_jitter(alpha = 0.1, width = 0.15) +
theme(legend.position = "none")
- 你需的類型
ggplot(y, aes(Var1, value, fill = Var1)) +
#scale_fill_brewer(palette="Set2") + #配色
guides(fill=FALSE) +
geom_flat_violin(position=position_nudge(x=.2)) +
#分散不重疊的點圖
#geom_jitter(aes(color=Var1), width=.15) + guides(color=FALSE) +
#堆疊的點圖
geom_dotplot(binaxis="y", stackdir="down", dotsize=.35) +
geom_boxplot(width=.1, position=position_nudge(x=.1)) +
geom_hline(aes(yintercept=0.75), linetype="dashed") + #畫一條虛線
coord_flip() + # x、y坐標軸互換
xlab("") + ylab("") +
theme(axis.text.x = element_text(family = "Arial", size = 16, face = "bold"),
axis.text.y = element_text(family = "Arial", size = 16, face = "bold")) +
theme_bw() +
theme(panel.border=element_rect(size=1)) #邊框粗細
參考:
- https://verytoolz.com/blog/664564561c/
- https://zhuanlan.zhihu.com/p/384928683
- https://blog.csdn.net/weixin_42655515/article/details/111167105
往期文章:
1. 最全WGCNA教程(替換數(shù)據(jù)即可出全部結(jié)果與圖形)
2. 精美圖形繪制教程
3. 轉(zhuǎn)錄組分析教程
- 1.課程介紹
- 2.第一章 Linux基礎(chǔ)
- 3.第一章 生信軟件安裝
- 4.第二章 轉(zhuǎn)錄組數(shù)據(jù)的下載
- 5.第三章 參考基因組序列和注釋文件的下載
- 6.轉(zhuǎn)錄組上游分析教程 | 第四章 數(shù)據(jù)過濾
- 7.第四章 Hisat2進行數(shù)據(jù)比對
- 8.第四章 Bowtie2進行數(shù)據(jù)比對
- 9.第四章 BWA進行數(shù)據(jù)比對
- 10.第四章 Tophat2比對
- 11.第五章 無參考基因組的轉(zhuǎn)錄組分析
- 12.第六章 轉(zhuǎn)錄本定量分析
小杜的生信筆記场梆,主要發(fā)表或收錄生物信息學的教程墅冷,以及基于R的分析和可視化(包括數(shù)據(jù)分析,圖形繪制等)或油;分享感興趣的文獻和學習資料!!
本文由mdnice多平臺發(fā)布