kpAbline: kpAbline

Description Usage Arguments Details Value See Also Examples

View source: R/kpAbline.R

Description

This is the KaryoploteR version of the abline function to add horizontal or vertical lines to the plot.

Usage

1
kpAbline(karyoplot, chr=NULL, h=NULL, v=NULL, ymin=NULL, ymax=NULL, data.panel=1, r0=NULL, r1=NULL, ...)

Arguments

karyoplot

(a KaryoPlot object) This is the first argument to all data plotting functions of karyoploteR. A KaryoPlot object referring to the currently active plot.

chr

(a charecter vector) A vector of chromosome names specifying the chromosomes where the lines will be plotted. If NULL, the lines will be plotted in all chromosomes. (defaults to NULL)

h

(a numeric vector) A numeric vector with the heights where the horizontal lines will be plotted. If h is NULL, no horizontal lines will be plotted. (defaults to NULL)

v

(a numeric vector) A numeric vector with the positions (in base pairs) where the vertical lines will be plotted. If v is NULL, no vertical lines will be plotted. (defaults to NULL)

ymin

(numeric) The minimum value of y to be plotted. If NULL, it is set to the min value of the selected data panel. (defaults to NULL)

ymax

(numeric) The maximum value of y to be plotted. If NULL, it is set to the max value of the selected data panel. (defaults to NULL)

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 plotKaryotype. (defaults to 1)

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)

...

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.

Details

As with all other base-inspired low-level plotting functions in karyoploteR, the function has been designed to accept mostly the same parameters as the base one (see the package vignette for more information). In this case, however, the interface has been reduced and it is only possible to plot vertical and horizontal lines and it's not possible to provide an intercept and slope. In addition, the function accepts graphical parameters that are valid for the base function segments.

Value

Returns the original karyoplot object, unchanged.

See Also

plotKaryotype, kpSegments, kpLines

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
set.seed(1000)
data.points <- sort(createRandomRegions(nregions=1000, mask=NA))
mcols(data.points) <- data.frame(y=rnorm(1000, mean = 0.5, sd = 0.1))

kp <- plotKaryotype("hg19", plot.type=1, chromosomes=c("chr1", "chr2"))
kpDataBackground(kp, data.panel=1)

kpPoints(kp, data=data.points, pch=".", col="#2222FF", cex=3)

#Add horizontal lines at mean
kpAbline(kp, h=0.5, col="red")

#and at the 1 sd
kpAbline(kp, h=c(0.4, 0.6), col="orange", lwd=0.5)
#and 2 sd's
kpAbline(kp, h=c(0.3, 0.7), col="orange", lwd=0.5, lty=2)

#And add two vertical lines at specific chromosomal locations
kpAbline(kp, v=c(67000000, 190000000), chr="chr1")

Bioconductor-mirror/karyoploteR documentation built on July 4, 2017, 6:39 p.m.