library(grid)
library(circlize)
library(RColorBrewer)
library(ComplexHeatmap)
setwd("C:/Users/fordata/Downloads/Circos")
# 创建颜色调色板
coul <- colorRampPalette(brewer.pal(9, "Set3"))(12)
# 读取基因组数据
genome <- read.table('cir_len2.txt')
colnames(genome) <- c("chr","start","end")
# 初始化Circos图
circos.par(start.degree = 90 , gap.degree = 45 )
circos.par("canvas.xlim" = c(-1.5, 1.5), "canvas.ylim" = c(-1.5, 1.5))
# 打开一个新的PDF设备
pdf("output.pdf")
# 生成最外圈的刻度
circos.genomicInitialize(genome)
# 读取噬菌体序列数据
phage <- read.table('phage.txt')
colnames(phage) <- c("chr","start","end")
# 添加噬菌体序列的内圈
circos.genomicTrackPlotRegion(phage, ylim = c(0, 1), panel.fun = function(region, value, ...) {circos.rect(region$start, 0, region$end, 1, col = coul[1], border = NA)
})
#SNP
gene <- read.table('gene.txt')
colnames(gene) <- c("chr","start","end")
# 修改为色块形式
circos.genomicTrackPlotRegion(gene, ylim = c(0, 1), panel.fun = function(region, value, ...) {circos.rect(region$start, 0, region$end, 1, col = "red", border = NA)
})
# gc
#GC <- read.table('GC.txt')
#colnames(GC) <- c("chr","start","end","value")
#circos.genomicTrackPlotRegion(GC,track.height = 0.08, bg.border = NA,panel.fun = function(region, value, ...){# circos.genomicLines(region, value, type = "l",col='#9370DB',...)})dev.off()
circos.clear()