meth_aggregate {methcon5}R Documentation

Calculate region wise summary statistics

Description

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

Usage

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

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)

[Package methcon5 version 0.1.0 Index]