用R语言的circlize包复现一下Microbiome期刊中的圈图
## 论文> Heritability and recursive influence of host genetics on the rumen microbiota drive body weight variance in male Hu sheep lambs
复现论文中的fig2
!(https://cdn.nlark.com/yuque/0/2024/png/657790/1717989817163-56898418-dbc8-4502-b1ff-c51608a511b7.png#averageHue=%23f2f1f1&clientId=ud01bbb4c-5e60-4&from=paste&height=876&id=ucb128534&originHeight=876&originWidth=1512&originalType=binary&ratio=1&rotation=0&showTitle=false&size=1089051&status=done&style=none&taskId=u29cc6003-afa5-41ad-a360-4f12792a378&title=&width=1512)
没有找到论文中提供的数据,我们自己来构造数据,如何利用otu表格把数据整理成作图需要用的格式,这个今天的推文不做介绍,今天的推文只介绍已经有了作图需要用到的数据后如何作图。
(others phylum 这个英文表述是不是有问题?有没有大佬可以解释一下?)
## 首先是最外圈的数据
!(https://cdn.nlark.com/yuque/0/2024/png/657790/1717991133457-5187f44e-d60a-4d39-8a12-c517fa9fa4c9.png#averageHue=%23f1f0f0&clientId=ud01bbb4c-5e60-4&from=paste&height=307&id=uaef68d1b&originHeight=307&originWidth=1210&originalType=binary&ratio=1&rotation=0&showTitle=false&size=25256&status=done&style=none&taskId=u9a16457f-d4cb-457b-ac22-6beecbe7384&title=&width=1210)
最外圈文字的数据
!(https://cdn.nlark.com/yuque/0/2024/png/657790/1717991066442-56e941d9-c42a-4aa2-ab05-10a2d0b284d5.png#averageHue=%23f3f1f0&clientId=ud01bbb4c-5e60-4&from=paste&height=407&id=u515dc5b0&originHeight=407&originWidth=924&originalType=binary&ratio=1&rotation=0&showTitle=false&size=38799&status=done&style=none&taskId=u0dca2de6-fabe-4dec-a761-e5797e725c5&title=&width=924)
## 第二圈数据
!(https://cdn.nlark.com/yuque/0/2024/png/657790/1717991919771-fffe4f7e-3995-44ae-bd4d-5d2096275efe.png#averageHue=%23f3f1ef&clientId=ud01bbb4c-5e60-4&from=paste&height=465&id=udb8abd67&originHeight=465&originWidth=270&originalType=binary&ratio=1&rotation=0&showTitle=false&size=13617&status=done&style=none&taskId=u02a112a9-ce98-4a3a-b1ee-28b8ff4e91f&title=&width=270)
## 第三圈的数据
与第二圈的数据格式一致
## 第四圈的数据
!(https://cdn.nlark.com/yuque/0/2024/png/657790/1717994976244-c838270a-a2f0-448b-9f83-122438cc271e.png#averageHue=%23f6f4f4&clientId=ud01bbb4c-5e60-4&from=paste&height=461&id=ubea2efc6&originHeight=461&originWidth=701&originalType=binary&ratio=1&rotation=0&showTitle=false&size=30419&status=done&style=none&taskId=ub48ecd98-1f79-44c5-a591-7669e9dac72&title=&width=701)
## 第五圈的数据
利用第三圈的数据生成
## 最里层连线的数据
!(https://cdn.nlark.com/yuque/0/2024/png/657790/1717998363792-8b2b13bc-f43d-4ce6-9582-03eaf3680dac.png#averageHue=%23f5f3f1&clientId=ud01bbb4c-5e60-4&from=paste&height=658&id=u808b63be&originHeight=658&originWidth=484&originalType=binary&ratio=1&rotation=0&showTitle=false&size=40364&status=done&style=none&taskId=udad60e9d-f1c7-4a80-bc3e-195cf08830e&title=&width=484)
## 完整的代码
```
library(circlize)
library(readxl)
library(tidyverse)
library("RColorBrewer")
dat01<-read_excel("2024.data/20240610/data01.xlsx")
dat01 %>%
mutate(phylum=factor(phylum,levels = phylum)) -> dat01
dat02<-read_excel("2024.data/20240610/data02.xlsx")
dat02
dat03<-read_excel("2024.data/20240610/data03.xlsx")
dat03
dat04<-read_excel("2024.data/20240610/data04.xlsx")
dat04
dat05<-read_excel("2024.data/20240610/data05.xlsx")
dat05
dat06.mat<-dat03 %>% pull(y) %>% as.matrix(ncol=1)
dat06.mat
data07<-read_excel("2024.data/20240610/data07.xlsx")
data07
brk<-seq(0,30,2)
brk
circos.par(start.degree =86,clock.wise = T)
## 热图的圈参考链接 https://jokergoo.github.io/circlize_book/book/circos-heatmap.html
circos.heatmap.initialize(dat06.mat,
split = factor(dat06$phylum,
levels = dat06$phylum %>% unique()))
circos.initialize(factors = dat01$phylum,
xlim = matrix(c(dat01$start,dat01$numberofgenera),ncol=2))
## 第一圈文字
circos.genomicLabels(dat02,side = "outside",labels.column = 4)
## 第一圈灰色背景
circos.trackPlotRegion(dat01$phylum,
ylim = c(0, 10),
track.height = 0.05,
bg.border = NA,
#ylim=CELL_META$ylim,
panel.fun = function(x, y) {
circos.text(mean(CELL_META$xlim),mean(CELL_META$ylim),
get.cell.meta.data("sector.index"))
},
bg.col='#EEEEEE6E')
## 第一圈线段
for (chromosome in dat02$phylum){
circos.segments(sector.index = chromosome,
x0=dat02$start,
x1=dat02$end,
y0=-2,y1=12,col="red")
}
## 第一圈刻度
for (chromosome in dat01$phylum){
circos.axis(sector.index = chromosome,
h = 12,
major.at = brk,
minor.ticks = 0,
labels = FALSE)
}
## 第二圈
circos.trackPlotRegion(dat01$phylum,
ylim = c(0, 100),
track.height = 0.1,
bg.col = '#EEEEEE6E',
bg.border = "black")
for (chromosome in dat03$phylum){
circos.points(sector.index = chromosome,
x=dat03$x,
y=dat03$y,
col="red",
pch=19)
}
## 第三圈
circos.trackPlotRegion(dat01$phylum,
ylim = c(0, 100),
track.height = 0.1,
bg.col = '#EEEEEE6E',
bg.border = NA)
for (chromosome in dat04$phylum){
circos.lines(sector.index = chromosome,
x=dat04$x,
y=dat04$y,
col="#559a90",
area=TRUE,
border=NA,
type="I")
}
## 第四圈
circos.trackPlotRegion(dat01$phylum,
ylim = c(0, 100),
track.height = 0.05,
bg.col = '#EEEEEE6E',
bg.border = "black")
for (chromosome in dat05$phylum){
circos.points(sector.index = chromosome,
x=dat05$x,
y=dat05$y,
col="red",
pch=dat05$shape)
}
## 第五圈
circos.heatmap(dat06.mat,
col = colorRamp2(breaks = c(0, 50, 100),
col = brewer.pal(n = 3, name = "RdBu")),
track.height=0.1)
## 最内圈的连线
for (i in 1:nrow(data07)){
circos.link(sector.index1=data07$phylum01,
point1=data07$x01,
sector.index2=data07$phylum02,
point2=data07$x02)
}
circos.clear()
```
出图结果
!(https://cdn.nlark.com/yuque/0/2024/png/657790/1717998724874-3a1528f9-b449-450d-a351-4f89c1fff0a3.png#averageHue=%23f9f3f1&clientId=ud01bbb4c-5e60-4&from=paste&height=899&id=u321fd51a&originHeight=899&originWidth=892&originalType=binary&ratio=1&rotation=0&showTitle=false&size=139926&status=done&style=none&taskId=ueb4e436a-d4be-4dbf-99f4-a2276e8a21e&title=&width=892)
图例的部分可能需要借助AI来拼图了
**欢迎大家关注我的公众号**
**小明的数据分析笔记本**
> 小明的数据分析笔记本 公众号 主要分享:1、R语言和python做数据分析和数据可视化的简单小例子;2、园艺植物相关转录组学、基因组学、群体遗传学文献阅读笔记;3、生物信息学入门学习资料及自己的学习笔记!
>
页:
[1]