meanInRegions {regioneR} | R Documentation

## Mean In Regions

### Description

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

### Usage

    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

     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)

[Package regioneR version 1.16.5 Index]