最后发布时间:2024-02-15 19:09:21
library(tidyverse)
library(karyoploteR)
inputFile="input.txt"
# outFile="genome.pdf"
outFile = "genome.png"
rt = read_tsv("input.txt") |> as.data.frame()
#提取数据
data.points=makeGRangesFromDataFrame(rt)
mcols(data.points)=data.frame(y=rt[,4])
#可视化
ymin=quantile(rt[,4],0.1)
ymax=quantile(rt[,4],0.9)*2
# pdf(file=outFile, width=10, height=7)
png(filename = outFile, width = 8,height =8,units = "in",res = 300)
kp=plotKaryotype("hg38", plot.type=1)
kpDataBackground(kp, data.panel=1, color="white")
kpPoints(kp, data=data.points, pch=".", col="red", ymin=ymin, ymax=ymax, cex=6)
kpAddBaseNumbers(kp, tick.dist=10000000, minor.tick.dist=1000000)
dev.off()