論文是
Environmental factors shaping the gut microbiome in a Dutch population
數(shù)據(jù)和代碼的github主頁鏈接
https://github.com/GRONINGEN-MICROBIOME-CENTRE/DMP
這個(gè)也是數(shù)據(jù)代碼的下載鏈接,可以看目錄結(jié)構(gòu)
https://zenodo.org/record/5910709#.YmAcp4VBzic
今天的推文重復(fù)一下論文中的figure1b

image.png
數(shù)據(jù)集

image.png
這里誤差線的范圍是平均值加減標(biāo)準(zhǔn)差,數(shù)據(jù)提前算好,整理到csv文件中
讀取數(shù)據(jù)
library(readr)
dat01<-read_csv("newdataset/MockData_Fig_1B_microbiome_rarefaction_datatable.csv")
head(dat01)
分組折線圖
library(ggplot2)
ggplot(data=dat01,aes(x=nr,y=spec.nr.mn,color=Taxon))+
geom_line(size=1.5,linetype=dat01$linetype)

image.png
添加誤差線
ggplot(data=dat01,aes(x=nr,y=spec.nr.mn,color=Taxon))+
geom_line(size=1.5,linetype=dat01$linetype)+
geom_errorbar(aes(ymin=spec.nr.mn-spec.nr.sd,
ymax=spec.nr.mn+spec.nr.sd),
size=1.05, colour="black")

image.png
再疊加一層散點(diǎn)圖
ggplot(data=dat01,aes(x=nr,y=spec.nr.mn,color=Taxon))+
geom_line(size=1.5,linetype=dat01$linetype)+
geom_errorbar(aes(ymin=spec.nr.mn-spec.nr.sd,
ymax=spec.nr.mn+spec.nr.sd),
size=1.05, colour="black")+
geom_point(shape=21,size=1.75,fill="white")

image.png
更改坐標(biāo)軸標(biāo)題
ggplot(data=dat01,aes(x=nr,y=spec.nr.mn,color=Taxon))+
geom_line(size=1.5,linetype=dat01$linetype)+
geom_errorbar(aes(ymin=spec.nr.mn-spec.nr.sd,
ymax=spec.nr.mn+spec.nr.sd),
size=1.05, colour="black")+
geom_point(shape=21,size=1.75,fill="white")+
xlab("Number of samples") + ylab("Number of features")
最后是美化調(diào)整細(xì)節(jié)
ggplot(data=dat01,aes(x=nr,y=spec.nr.mn,color=Taxon))+
geom_line(size=1.5,linetype=dat01$linetype)+
geom_errorbar(aes(ymin=spec.nr.mn-spec.nr.sd,
ymax=spec.nr.mn+spec.nr.sd),
size=1.05, colour="black")+
geom_point(shape=21,size=1.75,fill="white")+
xlab("Number of samples") + ylab("Number of features")+
scale_color_manual(values = c("#56B4E9", "#009E73", "#0072B2", "#D55E00", "#CC79A7", "#E69F00"))+
theme_bw()+
theme(text = element_text(size = 17))

image.png
制作封面圖
ggplot(data=dat01,aes(x=nr,y=spec.nr.mn,color=Taxon))+
geom_line(size=1.5,linetype=dat01$linetype)+
geom_errorbar(aes(ymin=spec.nr.mn-spec.nr.sd,
ymax=spec.nr.mn+spec.nr.sd),
size=1.05, colour="black")+
geom_point(shape=21,size=1.75,fill="white")+
xlab("Number of samples") + ylab("Number of features") -> p1
print(p1)
ggplot(data=dat01,aes(x=nr,y=spec.nr.mn,color=Taxon))+
geom_line(size=1.5,linetype=dat01$linetype)+
geom_errorbar(aes(ymin=spec.nr.mn-spec.nr.sd,
ymax=spec.nr.mn+spec.nr.sd),
size=1.05, colour="black")+
geom_point(shape=21,size=1.75,fill="white")+
xlab("Number of samples") + ylab("Number of features")+
scale_color_manual(values = c("#56B4E9", "#009E73", "#0072B2", "#D55E00", "#CC79A7", "#E69F00"))+
theme_bw()+
theme(text = element_text(size = 17)) -> p2
print(p2)
library(patchwork)
p1+p2

image.png
今天推文的示例數(shù)據(jù)和代碼可以在公眾號后臺留言
20220509獲取
歡迎大家關(guān)注我的公眾號
小明的數(shù)據(jù)分析筆記本
小明的數(shù)據(jù)分析筆記本 公眾號 主要分享:1、R語言和python做數(shù)據(jù)分析和數(shù)據(jù)可視化的簡單小例子;2、園藝植物相關(guān)轉(zhuǎn)錄組學(xué)、基因組學(xué)、群體遺傳學(xué)文獻(xiàn)閱讀筆記;3、生物信息學(xué)入門學(xué)習(xí)資料及自己的學(xué)習(xí)筆記!