meth_aggregate: Calculate region wise summary statistics

Description Usage Arguments Details Value Examples

View source: R/aggregate.R

Description

Will take a data.frame and apply a function ('fun') to 'value' within the groups defined by the 'id' column.

Usage

1
meth_aggregate(data, id, value, fun = mean, ...)

Arguments

data

a data.frame.

id

variable name, to be aggregated around.

value

variable name, contains the value to take mean over. Must be a single column.

fun

function, summary statistic function to be calculated. Defaults to 'mean'.

...

Additional arguments for the function given to the argument fun.

Details

Please note the ordering of the data will matter depending on the choice of aggregation function.

Value

A methcon object. Contains the aggregated data along with original data.frame and variable selections.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
meth_aggregate(fake_methylation, id = gene, value = meth, fun = mean)

meth_aggregate(fake_methylation, id = gene, value = meth, fun = var)

# custom functions can be used as well
mean_diff <- function(x) {
  mean(diff(x))
}

meth_aggregate(fake_methylation, id = gene, value = meth, fun = mean_diff)

methcon5 documentation built on Jan. 11, 2020, 9:39 a.m.