kpPlotLoess: kpPlotLoess

Description Usage Arguments Details Value See Also Examples

View source: R/kpPlotLoess.R

Description

Plot a LOESS smoothed line with confidence intervals given a list of points.

Usage

1
kpPlotLoess(karyoplot, data=NULL, chr=NULL, x=NULL, y=NULL, conf.interval=0.95, span=0.5, data.panel=1, r0=NULL, r1=NULL, ymin=NULL, ymax=NULL, col="black", lty=1, lwd=1, ci.col="#888888AA", ci.border=NA, ci.border.lty=1, ci.border.lwd=1, clipping=TRUE, ...)

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.

data

(a GRanges) A GRanges object with the data. If data is present, chr will be set to seqnames(data) and x to the midpoints of the rages in data. If no parameter y is specified and data has a column named y or value this column will be used to define the y value of each data point. (defaults to NULL)

chr

(a charecter vector) A vector of chromosome names specifying the chromosomes of the data points. If data is not NULL, chr is ignored. (defaults to NULL)

x

(a numeric vector) A numeric vector with the positions (in base pairs) of the data points in the chromosomes. If data is not NULL, x is ignored. (defaults to NULL)

y

(a numeric vector) A numeric vector with the values of the data points. If y is not NULL, it is used instead of any data column in data. (defaults to NULL)

conf.interval

The confidence interval to plot. If a number in (0,1), the confidence interval is plotted. Else, no confidence interval is plotted. (defaults to 0.95)

span

A parameter to control the smoothing level. It is passed to underlying function loess. (deafults to 0.5)

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)

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)

col

The color of the fitting line. (defaults to "black")

lty

The line type (dashed, dotted...) of the fitting line (defaults to 1, solid)

lwd

The line width of the fitting line (defaults to 1)

ci.col

The color of the area representing the confidence interval. If NA no CI is plotted. (defaults to #888888AA, transparent gray)

ci.border

The color of line marking the border of the confidence interval. If NA, it's not plotted. (defaults to NA)

ci.border.lty

The line type of line marking the border of the confidence interval. (defaults to 1, solid)

ci.border.lwd

The line width of line marking the border of the confidence interval. (defaults to 1)

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.

Details

Given a set of data points (specified in any way accepted by kpPoints), plot a LOESS smoothed line with optional confidence intervals. LOESS is computed independently per each chromosome and data points are sorted before fitting. It is possible to adjust the confidence interval with conf.interval and setting it to NULL or NA will plot no CI. It is also possible to control the smoothing level with span. In addition to the standard plotting parameters, it is possible to control independently the color of the fitting line and CI area and CI borders. It is also possible to adjust the line type and line width of the fitting line and CI border.

Value

Returns the original karyoplot object, unchanged.

See Also

plotKaryotype, kpPoints, kpLines, kpPlotRibbon

Examples

1
2
3
4
5
6
7
set.seed(1000)

dd <- data.frame(chr="chr1", x=1:48*5e6, y=rnorm(n=48, 0.5, 0.1 ))

kp <- plotKaryotype(chromosomes="chr1")
kpPoints(kp, chr=dd$chr, x=dd$x, y=dd$y)
kpPlotLoess(kp, chr=dd$chr, x=dd$x, y=dd$y, col="red", conf.interval = 0.99, ci.col = "#FAAAAAAA")

karyoploteR documentation built on Nov. 8, 2020, 5:52 p.m.