Description Usage Arguments Details Value Note See Also Examples
Plots the the given polygons along the genome
1 |
karyoplot |
(a |
data |
(a |
chr |
(a charecter vector) A vector of chromosome names specifying the chromosomes of the data points. If |
x |
(a numeric vector) A numeric vector with the positions (in base pairs) of the data points in the chromosomes. If |
y |
(a numeric vector) A numeric vector with the values of the data points. If |
ymin |
(numeric) The minimum value of |
ymax |
(numeric) The maximum value of |
data.panel |
(numeric) The identifier of the data panel where the data is to be plotted. The available data panels depend on the plot type selected in the call to |
r0 |
(numeric) r0 and r1 define the vertical range of the data panel to be used to draw this plot. They can be used to split the data panel in different vertical ranges (similar to tracks in a genome browser) to plot differents data. If NULL, they are set to the min and max of the data panel, it is, to use all the available space. (defaults to NULL) |
r1 |
(numeric) r0 and r1 define the vertical range of the data panel to be used to draw this plot. They can be used to split the data panel in different vertical ranges (similar to tracks in a genome browser) to plot differents data. If NULL, they are set to the min and max of the data panel, it is, to use all the available space. (defaults to NULL) |
clipping |
(boolean) Only used if zooming is active. If TRUE, the data representation will be not drawn out of the drawing area (i.e. in margins, etc) even if the data overflows the drawing area. If FALSE, the data representation may overflow into the margins of the plot. (defaults to TRUE) |
... |
The ellipsis operator can be used to specify any additional graphical parameters. Any additional parameter will be passed to the internal calls to the R base plotting functions. |
This is one of the functions from karyoploteR implementing the adaptation to the genome context
of basic plot functions from R base graphics.
Given a set of positions on the genome (chromosome, base and y), it plots the polygons
defined by taking these position as vertices.
Data can be provided via a GRanges
object (data
), independent
parameters for chr, x and y or a combination of both. A number of parameters can be used
to define exactly where and how the polygon is drawn. In addition, via the ellipsis operator
(...
), kpPolygon
accepts any parameter valid for polygon
(e.g. border
, density
, fillOddEven
, ...)
Returns the original karyoplot object, unchanged.
IMPORTANT: kpPolygon
allows the creation of polygons
encompassing multilple chromosomes. In some cases, when plotting only some
of the chromosomes or when zooming, the default data filtering automatically
discards some points before plotting, altering the polygon shape. See example
below.
plotKaryotype
, kpLines
, kpPoints
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
set.seed(1000)
x <- c(1,2,5,9,13,20,15,11,7,3)*10000000
y <- c(0,1,0.8,0.2,0.5,0.2,1,0.3,0.1,0.2)
kp <- plotKaryotype("hg19", plot.type=2, chromosomes=c("chr1", "chr2"))
kpDataBackground(kp, data.panel=1)
kpDataBackground(kp, data.panel=2)
kpPolygon(kp, chr="chr1", x=x, y=y, col="red")
kpPolygon(kp, chr="chr1", x=x, y=y, col="orange", r0=0.2, r1=0.8, density=30)
#use kpPolygon to draw triangles at the specified positions
chr2.x <- c(1,3,7,26,48,79,120, 124, 128)*1000000
for(x in chr2.x) {
kpPolygon(kp, chr="chr2", x=c(x-2000000, x+2000000, x), y=c(1,1,0), r0=0, r1=0.3, col="lightblue")
}
#Effect of data filtering
dp <- toGRanges(data.frame(rep(paste0("chr", (1:2)), 3), 10e6*1:6, 10e6*1:6+5e5, y=c(0,0,1,1,0,0)))
kp <- plotKaryotype(chromosomes=c("chr1", "chr2"))
kpPolygon(kp, dp)
kp <- plotKaryotype(chromosomes=c("chr2"))
kpPolygon(kp, dp)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.