plotKaryotype {karyoploteR} | R Documentation |
Create a new empty plot with a karyotype (the chromosome ideograms and chromosome names).
plotKaryotype(genome="hg19", plot.type=1, ideogram.plotter=kpAddCytobands, labels.plotter=kpAddChromosomeNames, chromosomes="auto", zoom=NULL, cytobands=NULL, plot.params=NULL, use.cache=TRUE, main=NULL, ...)
genome |
The genome to plot. It can be either a UCSC style genome name (hg19, mm10, etc), a GRanges object with the chromosomes as ranges or in general any genome specification accepted by |
plot.type |
The orientation of the ideogram and placing of the data panels. Values explained above.. (defaults to 1) |
ideogram.plotter |
The function to be used to plot the ideograms. Only one function is included with the package, |
labels.plotter |
The function to be used to plot the labels identifying the chromosomes. Only one function is included with the package, |
chromosomes |
The chromosomes to plot. Can be either a vector of chromosome names or a chromosome group name ("canonical", "autosomal", "all"). Setting it yo "auto" will select canonical for named genomes and no filtering for custom genomes. (defaults to "auto") |
zoom |
A GRanges object specifiyng a single region to zoom in. If not NULL, it takes precedence over |
cytobands |
A GRanges object (or anything accepted by |
plot.params |
An object obtained from |
use.cache |
|
main |
The text to be used as the title of the plot. NULL produces no title. (defaults to NULL) |
... |
The ellipsis can be used to pass in any additional parameter accepted by the internal functions used. |
This is the main function of karyoploteR
. It creates the basic empty plot with
the chromosome ideograms and returns the karyoplot object needed for all other plotting
functions. Both the basic plotting parameters (margins, sizes, etc.) and the specific
plotting functions for the ideograms and chromosome labels are customizable.
In particular, passing in a plot.params
object specifies the basic plotting
parameters to use and the ideogram.plotter
and labels.plotter
parameters
can be used to specify custom plotting functions for the ideogram and the chromosome
labels. It is also possible to specify the genome and a list with the chromosomes to
be plotted.
The plot.type
parameter specifies the type of karyoplot to create: the number
and positions of the data panels respect to the ideograms:
plot.type=1
Horizontal ideograms with a single data panel above them
plot.type=2
Horizontal ideograms with a two data panels, one above and one below them
More plot types are expected to come in the near future.
The KaryoPlot
object needed by the plotting functions.
getDefaultPlotParams
, kpPoints
set.seed(1000) rand.data <- createRandomRegions(genome="hg19", nregions=10000, length.mean=1, length.sd=0, mask=NA, non.overlapping=TRUE) mcols(rand.data) <- data.frame(y=rnorm(n=10000, mean = 0.5, sd=0.1)) #The simplest way, with all default parameters kp <- plotKaryotype() kpPoints(kp, rand.data, pch=".") #Or we can plot only a few chromosomes, with 2 data panels kp <- plotKaryotype(chromosomes = c("chr1", "chr2"), plot.type = 2) kpDataBackground(kp, data.panel = 1, color = "lightgreen") kpDataBackground(kp, data.panel = 2, color = "lightblue") kpPoints(kp, rand.data, pch=".", data.panel = 1) kpPoints(kp, rand.data, pch=".", data.panel = 2) #Or we can use a different organism, kp <- plotKaryotype(genome = "mm10") kp <- plotKaryotype(genome = "dm6") # Or we can change the plotting parameters. In this case, to create a smaller ideogram # and smaller data panel below it plot.params <- getDefaultPlotParams(plot.type=2) plot.params$ideogramheight <- 5 plot.params$data2height <- 50 kp <- plotKaryotype(chromosomes = c("chr1", "chr2"), plot.type = 2, plot.params = plot.params) kpDataBackground(kp, data.panel = 1, color = "lightgreen") kpDataBackground(kp, data.panel = 2, color = "lightblue") kpPoints(kp, rand.data, pch=".", data.panel = 1) kpPoints(kp, rand.data, pch=".", data.panel = 2) #Or we can remove the cytobands, passing an empty GRanges object kp <- plotKaryotype(cytobands = GRanges()) #Or remove the chromosome labels kp <- plotKaryotype(labels.plotter = NULL) kpPoints(kp, rand.data, pch=".") #In addition, it's possible to use maggrittr piping to chain the plotting calls library(magrittr) kp <- plotKaryotype() %>% kpDataBackground(color = "lightgreen") %>% kpPoints(rand.data, pch=".")