Thanks a lot, Bernat ! It look fabulous ... I will get back to you soon !
Dear all,
please would you advise if there is any package already built (possibly in R/BioC) that could help with the following data visualization :
we have a set of SNV, CNV, SV from many cancer samples
we would like to display the SNV and the CNV along the chromosome coordinates (on the linear scale, ie. HORIZONTALLY)
we would like to display the SV, especially TRANSLOCATIONS, as VERTICAL LINES connecting the breakpoints on the chromosomes that are represented HORIZONTALLY
thank you very much,
-- bogdan
2 answers
Hi Bogdan,
In R you can create a plot like the one you decribe with karyoploteR.
Here's a small example with random data (random positions in the genome created with createRandomRegions from the package regioneR). You can add additional data, use a different genome, change color and sizes and in general customize the plot in many ways using this package. You can find a short tutorial and some more complex examples at karyoploteR's tutorial and examples page.
library(regioneR)
library(karyoploteR)
set.seed(12345)
#Create example data
gains <- createRandomRegions(nregions = 10, length.mean = 10e6, length.sd = 10e6, genome = "hg19", mask=NULL)
losses <- createRandomRegions(nregions = 10, length.mean = 10e6, length.sd = 10e6, genome = "hg19", mask=NULL)
snv <- createRandomRegions(nregions = 200, length.mean = 1, length.sd = 0, genome = "hg19", mask=NULL)
snv.cols <- sample(x = c("red", "blue", "gold", "orchid", "palegreen"), 200, replace = TRUE)
sv.origin <- createRandomRegions(nregions = 10, length.mean = 1, length.sd = 0, genome = "hg19", mask=NULL)
sv.end <- createRandomRegions(nregions = 10, length.mean = 1, length.sd = 0, genome = "hg19", mask=NULL)
#Create the plot
png("example.png", width=1500, height=1500)
kp <- plotKaryotype(cex=2)
#Plot the SNVs as points (use different colors to represent different mutation types)
kpPoints(kp, data=snv, y=0, r0=0.1, r1=0.1, col=snv.cols, cex = 2)
#plot gains (orange) and losses (green)
kpPlotRegions(kp, data=gains, r0=0.3, r1=0.8, col="#FF7744", border = NA)
kpPlotRegions(kp, data=losses, r0=0.3, r1=0.8, col="#77FF44", border = NA)
#Plot the links representing the SVs
kpPlotLinks(kp, data=sv.origin, data2 = sv.end, col="black")
dev.off()
And that will create this image

Hope this helps
Dear Benat, thank you also for the example below that you have graciously shared !
png("example_oneline.png", width=1500, height=800)
pp <- getDefaultPlotParams(plot.type=3)
pp$data2height <- 50
kp <- plotKaryotype(cex=2, plot.type=3, plot.params = pp, labels.plotter = NULL, ideogram.plotter = NULL)
kpAddCytobandsAsLine(kp)
kpAddChromosomeNames(kp, srt=45, cex=2)
#Plot the SNVs as points (use different colors to represent different mutation types)
kpPoints(kp, data=snv, y=0, r0=0.1, r1=0.1, col=snv.cols, cex = 2, data.panel = 2)
#plot gains (orange) and losses (green)
kpPlotRegions(kp, data=gains, r0=0.3, r1=1, col="#FF7744", border = NA, data.panel=2)
kpPlotRegions(kp, data=losses, r0=0.3, r1=1, col="#77FF44", border = NA, data.panel = 2)
#Plot the links representing the SVs
kpPlotLinks(kp, data=sv.origin, data2 = sv.end, col="black")
dev.off()
Log in to answer this question.