Articles - R packages

karyoploteR: Plot Karyotype and Visualize Genomic Data

karyoploteR is an R/Bioconductor package to to plot virtually anything along the genome.


Code R :

Basic workflow to create a karyoplot:

1) start with an empty plot with no data apart from the ideograms themselves using the function plotKaryotype() .

2) add the data plots as required. To add the data there are functions based on the R base graphics: kpPoints(), kpLines(), kpSegments(), kpRects(), … - that can be used to plot virtually anything along the genome and other functions at a higher level useful to plot more specific genomic data types -e.g. kpPlotRegions(), kpPlotCoverage(), …-.

A simple example is to plot a set of regions representing copy-number gains and losses using the kpPlotRegions() function:

Code R :
  gains <- makeGRangesFromDataFrame(data.frame(chr=c("chr1", "chr5", "chr17", "chr22"), start=c(1, 1000000, 4000000, 1),
                      end=c(5000000, 3200000, 80000000, 1200000)))
  losses <- makeGRangesFromDataFrame(data.frame(chr=c("chr3", "chr9", "chr17"), start=c(80000000, 20000000, 1),
                       end=c(170000000, 30000000, 25000000)))
  kp <- plotKaryotype(genome="hg19")
  kpPlotRegions(kp, gains, col="#FFAACC")
  kpPlotRegions(kp, losses, col="#CCFFAA")

Read more: karyoploteR