meanInRegions: Mean In Regions

Description Usage Arguments Value See Also Examples

View source: R/meanInRegions.R

Description

Returns the mean of a value defined by a region set over another set of regions.

Usage

1
meanInRegions(A, x, col.name=NULL, ...)

Arguments

A

a region set in any of the accepted formats by toGRanges (GenomicRanges, data.frame, etc...)

x

a region set in any of the accepted formats with an additional column with a value associated to every region. Regions in x can be points (single base regions).

col.name

character indicating the name of the column. If NULL and if a column with the name "value" exist, it will be used. The 4th column will be used otherwise (or the 5th if 4th is the strand).

...

any additional parameter needed

Value

It returns a numeric value that is the weighted mean of "value" defined in x over the regions in A. That is, the mean of the value of all regions in x overlapping each region in A weighted according to the number of bases overlapping.

See Also

permTest

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
 A <- data.frame("chr1", c(1, 10, 20, 30), c(12, 13, 28, 40))
 
 positions <- sample(1:40,30)
 
 x <- data.frame("chr1", positions, positions, rnorm(30,4,1))
 
 meanInRegions(A, x)
 
 x <- GRanges(seqnames=x[,1],ranges=IRanges(x[,2],end=x[,2]),mcols=x[,3])
 
 meanInRegions(A, x)
 

regioneR documentation built on Nov. 8, 2020, 5 p.m.