根據vcf檔案計算SNP密度并用circlize可視化結果
在這篇文章中遇到的問題是我想開個口子用來添加文字标簽,暫時還不知道如何實作
在 https://www.promptcloud.com/blog/data-visualization-text-mining-taylor-swift-song-lyrics/ 這篇文章裡找到了答案
可以通過
circos.par(gap.after())
來實作
例子
不開口
df<-read.table("SNPdensity.snpden",sep="\t",header=T)
head(df)
df<-df[,c(1,2,4)]
colnames(df)<-c("Chr","X","Y")
head(df)
df$X<-df$X/1000000
options(scipen=999)
library(circlize)
library(RColorBrewer)
col<-RColorBrewer::brewer.pal(8,"Paired")
circos.par(gap.after=c(2,2,2,2,4,4,4,30),"start.degree" = 90)
circos.initialize(factors=df$Chr,x=df$X)
circos.trackPlotRegion(factors=df$Chr,y=df$Y,
panel.fun=function(x,y){
circos.axis()
},track.height = 0.05)
for(i in 1:8){
highlight.sector(sector.index = paste0("LG",i),col=col[i])
circos.text(CELL_META$xcenter, CELL_META$ycenter,
labels = paste0("LG",i),
sector.index = paste0("LG",i),cex=0.5)
}
circos.trackPlotRegion(factors=df$Chr,y=df$Y)
circos.trackLines(df$Chr,df$X,df$Y,col=col)
circos.clear()
複制
image.png
開口
circos.par(gap.after=c(2,2,2,2,2,2,2,30),"start.degree" = 90)
circos.initialize(factors=df$Chr,x=df$X)
circos.trackPlotRegion(factors=df$Chr,y=df$Y,
panel.fun=function(x,y){
circos.axis()
},track.height = 0.05)
for(i in 1:8){
highlight.sector(sector.index = paste0("LG",i),col=col[i])
circos.text(CELL_META$xcenter, CELL_META$ycenter,
labels = paste0("LG",i),
sector.index = paste0("LG",i),cex=0.5)
}
circos.trackPlotRegion(factors=df$Chr,y=df$Y)
circos.trackLines(df$Chr,df$X,df$Y,col=col)
circos.clear()
複制
image.png
實作開口用到的函數是
circos.par(gap.after=c(2,2,2,2,2,2,2,30),"start.degree" = 90)
在開口處添加文字
circos.par(gap.after=c(2,2,2,2,2,2,2,30),"start.degree" = 75)
circos.initialize(factors=df$Chr,x=df$X)
circos.trackPlotRegion(factors=df$Chr,y=df$Y,
panel.fun=function(x,y){
circos.axis()
},track.height = 0.05)
for(i in 1:8){
highlight.sector(sector.index = paste0("LG",i),col=col[i])
circos.text(CELL_META$xcenter, CELL_META$ycenter,
labels = paste0("LG",i),
sector.index = paste0("LG",i),cex=0.5)
}
circos.text(x=-11,y=8,labels="染色體",sector.index = "LG1")
circos.trackPlotRegion(factors=df$Chr,y=df$Y)
circos.trackLines(df$Chr,df$X,df$Y,col=col)
circos.text(x=-10,y=11,labels="SNP密度",sector.index = "LG1")
circos.clear()
複制