Closed ixxmu closed 3 weeks ago
❝本节分享nature communications论文中的雷达图绘制,论文提供了分析的数据及代码,但是经过测试存在代码报错,应该是R包版本的问题,小编在论文源代码的基础上做了修改后可以正常运行。根据个人对数据的理解来进行绘图与原文有所不同,仅供参考,具体的内容请参考论文。
Prophage-encoded antibiotic resistance genes are enriched in human-impacted environments
❝https://zenodo.org/records/13301199 # transmission risk内含有源数据及源代码
❝此图使用ggradar2包可轻松绘制,绘制过程非常的简单只要整理好数据即可。与原图相比,未设置分面背景色,此步骤可由ggh4x包完成。此外关于图例的设置也是非常考验基本功,最简便的方法大概单独绘制出图例在添加到图中。
library(tidyverse)
#devtools::install_github("xl0418/ggradar2",dependencies=TRUE)
library(ggradar2)
library(ggplot2)
library(gridExtra)
data.Aquatic.organism <- read.delim('Aquatic organism pARG transmission risk.txt',header = T,row.names = 1)
data.food <- read.delim('food pARG transmission risk.txt',header = T,row.names = 1)
data.huamn <-read.delim('human pARG transmission risk.txt',header = T,row.names = 1)
data.Insects <- read.delim('insects pARG transmission risk.txt',header = T,row.names = 1)
data.animal.husbandry <- read.delim('livertock pARG transmission risk.txt',header = T,row.names = 1)
data.Plant <- read.delim('plant pARG transmission risk.txt',header = T,row.names = 1)
data.Seawater <- read.delim('seawater pARG transmission risk.txt',header = T,row.names = 1)
data.Sediment <- read.delim('sediments pARG transmission risk.txt',header = T,row.names = 1)
data.soil <- read.delim('Soil pARG transmission risk.txt',header = T,row.names = 1)
data.Wild.animal <- read.delim('wildlife pARG transmission risk.txt',header = T,row.names = 1)
data.Surface.water <- read.delim('Fresh water pARG transmission risk.txt',header = T,row.names = 1)
facettest <- bind_rows(data.food,data.animal.husbandry,data.huamn,
data.soil,data.Sediment,data.Wild.animal,
data.Surface.water,data.Aquatic.organism,
data.Insects,data.Seawater,data.Plant) %>%
mutate(facet1=c("food prophageARGs","animal.husbandry prophageARGs",
"human prophageARGs","soil prophageARGs","Sediment prophageARGs",
"Wild.animal prophageARGs","Surface.water prophageARGs",
"Aquatic.organism prophageARGs",
"Insects prophageARGs","Seawater prophageARGs",
"Plant prophageARGs")) %>%
mutate(id=c("food","animal.husbandry","human","soil","Sediment",
"Wild.anima","Surface.water", "Aquatic.organism",
"Insects","Seawater","Plant")) %>%
rownames_to_column(var="name") %>% select(-name) %>%
column_to_rownames(var="id")
ggradar2(facettest,multiplots = TRUE,
base.size=10,
axis.label.size=3.2,
grid.label.size =3,
group.line.width = 0.5,
gridline.label = seq(0, 100,50),
stripbackground = TRUE,
plot.legend=F,
group.point.size=2,
background.circle.colour =("#C7E6F0"))+
# group.colours=c("#78A8C6","#BEBADA","#8DD3C7",
# "#F37D74","#BEE0BE","#F5C2D9",
# "#A0CE3A","#9D9E98","#AA7CB6",
# "#F2E27B","#FCB461"),
# group.fill.colours=c("#78A8C6","#BEBADA","#8DD3C7",
# "#F37D74","#BEE0BE","#F5C2D9",
# "#A0CE3A","#9D9E98","#AA7CB6",
# "#F2E27B","#FCB461"))+
theme(strip.text = element_text(color="black",face="bold",size=8))
❝本节介绍到此结束,有需要学习R数据可视化的朋友欢迎到淘宝店铺:R语言数据分析指南,购买小编的R语言可视化文档(2024版),购买将赠送2023年的绘图文档内容。目前此文档(2023+2024)已经更新上传200案例文档,每个案例都附有相应的数据和代码,并配有对应的注释文档,方便大家学习和参考。
2024更新的绘图内容将同时包含数据+代码+注释文档+文档清单,2023无目录仅有数据文件夹,小编只分享案例文档,不额外回答问题,无答疑服务,零基础不推荐买。
所选案例图均属于个性化分析图表完全适用于论文发表,内容异常丰富两年累计发布案例图200+,2024年6月起提供html版注释文档更加直观易学。文档累计上千人次购买拥有良好的社群交流体验。R代码结构清晰易懂,为防止中文乱码提供单独的注释文档
R代码结构清晰易懂,为防止中文乱码2024年6月起提供单独html注释文档
https://mp.weixin.qq.com/s/Xo4GN6oQ8nSnW2Ei3hJyfg