論文
MiDAS 4: A global catalogue of full-length 16S rRNA gene sequences and taxonomy for studies of bacterial communities in wastewater treatment plants
https://www.nature.com/articles/s41467-022-29438-7
數(shù)據(jù)鏈接
https://figshare.com/articles/dataset/Dueholm2021a_data_zip/16566408/1
代碼鏈接
https://github.com/msdueholm/MiDAS4
今天的推文重復(fù)一下論文中的Figure4a

論文中沒有直接提供這個作圖數(shù)據(jù),需要運行一系列代碼獲得,這里我不介紹前面獲取作圖數(shù)據(jù)的代碼了,感興趣的可以自己去找來代碼試試,如果運行的話需要比較大的內(nèi)存
作圖數(shù)據(jù)部分截圖

讀取數(shù)據(jù)
library(ggrepel)
library(tidyverse)
library(ggplot2)
library(ggtext)
library(ggrepel)
gV134<-read_csv("fig4a.csv")
作圖代碼
p <- ggplot(gV134,
aes_string(x = "V13_mean_abundance",
y= "V4_mean_abundance",
fill="Bias"),
color="black") +
geom_point(size = 2,shape=21) +
geom_abline(size = 0.5) +
geom_text_repel(data =
filter(gV134,
gV134$FC>1 & gV134$V4_mean_abundance>0.1),
aes(label = Genus),
#vjust = 1.5,
colour="grey30") +
geom_text_repel(data =
filter(gV134,
gV134$FC<(-1) & gV134$V13_mean_abundance>0.1),
aes(label = Genus),
#vjust = 1.5,
colour="grey30") +
xlab("Mean V13 amplicon genus read abundance (%)") +
ylab("Mean V4 amplicon genus read abundance (%)") +
scale_x_log10(limits=c(0.001,2)) +
scale_y_log10(limits=c(0.001,2)) +
theme_bw() +
theme(legend.position = "none",
plot.title = element_markdown())+
scale_fill_manual(values = c('Equally detected'="#898989",
'More abundant with V1-V3'="#2a7cb6",
'More abundant with V4'="#d41b21"))+
labs(title="352 genera equally abundant <span style = 'color:#898989;'>(gray)</span><br/>
112 genera more abundant with V4 <span style = 'color:#d41b21;'>(red)</span><br/>
111 genera more abundant with V1-V3 <span style = 'color:#2a7cb6;'>(blue)</span>")
p

這里遇到的問題是添加的文本標簽有點多,彼此之間會有重疊,使用ggrepel這個R包也調(diào)節(jié)不出比較好的效果,只能出圖后再編輯圖片了
這里標題的文本只有一部分添加了顏色,可以借助ggtext這個R包的markdown語法實現(xiàn)
示例數(shù)據(jù)和代碼可以自己到論文中下載
歡迎大家關(guān)注我的公眾號
小明的數(shù)據(jù)分析筆記本
小明的數(shù)據(jù)分析筆記本 公眾號 主要分享:1、R語言和python做數(shù)據(jù)分析和數(shù)據(jù)可視化的簡單小例子;2、園藝植物相關(guān)轉(zhuǎn)錄組學、基因組學、群體遺傳學文獻閱讀筆記;3、生物信息學入門學習資料及自己的學習筆記!