Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge kpPoints and kpPlotBigWig, the r0 r1 of kpPoints cannot be set correctly #149

Open
HMU-ChaoWang opened this issue Mar 28, 2024 · 0 comments

Comments

@HMU-ChaoWang
Copy link

I want to use an karyoploteR to cheak the chip seq peak at a specific location, as well as the snp significance at that region. So I use kpPoints and kpPlotBigWig, but the exact figure location of kpPoints cannot be determined by parameters r0,r1. The data and code are as follows:

image

pp <- getDefaultPlotParams(plot.type=1)
pp$leftmargin <- 0.15
pp$topmargin <- 15
pp$bottommargin <- 15
pp$ideogramheight <- 5
pp$data1inmargin <- 10
pp$data1outmargin <- 0

kp <- plotKaryotype(zoom = gene.region, cex=3, plot.params = pp)
kpAddBaseNumbers(kp, tick.dist = 50000, minor.tick.dist = 5000,
                 add.units = TRUE, cex=0.8, tick.len = 5)

kpPlotGenes(kp, data=genes.data, r0=0, r1=0.05, gene.name.cex = 0.8)
kpPlotRegions(kp, data=c(enhancer.region), col="#C1FFC1", r0=0.2, r1=1)
kpPlotRegions(kp, data=c(enhancer.region), col="#FFC125", r0=0.18, r1=0.19)



total.tracks <- length(H3K27ac)+3
out.at <- autotrack(1:length(H3K27ac), total.tracks, margin = 0.3, r0=0.2)
kpAddLabels(kp, labels = "H3K27ac", r0 = out.at$r0, r1=out.at$r1, cex=2,
            srt=90, pos=1, label.margin = 0.14)


for(i in seq_len(length(H3K27ac))) {
  bigwig.file <- paste0("/data/H3K27AC/", H3K27ac[i])
  at <- autotrack(i, length(H3K27ac), r0=out.at$r0, r1=out.at$r1, margin = 0.1)
  kp <- kpPlotBigWig(kp, data=bigwig.file, ymax="visible.region",
                     r0=at$r0, r1=at$r1, col = "cadetblue2")
  computed.ymax <- ceiling(kp$latest.plot$computed.values$ymax)
  kpAxis(kp, ymin=0, ymax=computed.ymax, tick.pos = computed.ymax, 
         r0=at$r0, r1=at$r1, cex=0.8)
  kpAddLabels(kp, labels = names(H3K27ac)[i], r0=at$r0, r1=at$r1, 
              cex=0.8, label.margin = 0.035)
}


out.at <- autotrack((length(H3K27ac)+1):total.tracks, total.tracks, margin = 0.3, r0=0.2)
kpAddLabels(kp, labels = "SNP_sig", r0 = out.at$r0, r1=out.at$r1,
            cex=1, srt=90, pos=1, label.margin = 0.14)

at <- autotrack(1,1, r0=out.at$r0, r1=out.at$r1, margin = 0.1)
kpAxis(kp,  r0=at$r0, r1=at$r1, ymax=ceiling(max(file_point$FDR)), ymin=0)
kpPoints(kp, chr = file_point$chr, x=file_point$pos, y=file_point$FDR,
         #ymin=0,#ymax=20,
         col="red",r0=at$r0, r1=at$r1,cex=0.5)

the results as follows:
image

When I change the "at" of KpPoints, the kpAxis and graph don't match:

at <- autotrack(1,3, r0=out.at$r0, r1=out.at$r1, margin = 0.1)
kpAxis(kp,  r0=at$r0, r1=at$r1, ymax=ceiling(max(file_point$FDR)), ymin=0)
kpPoints(kp, chr = file_point$chr, x=file_point$pos, y=file_point$FDR,
         #ymin=0,#ymax=20,
         col="red",r0=at$r0, r1=at$r1,cex=0.5)

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant