apply_functions: Apply-type methods

cgApplyR Documentation

Apply-type methods

Description

These functions are apply-type functions for ContactGroup objects.

Usage

cgApply(cg, FUN, mc.cores=1, ...)
cgBandApply(cg, FUN, nbands=NULL, mc.cores=1, bstart=2, ...)

Arguments

cg

A ContactGroup object.

FUN

A function to be applied. For cgApply this function should operate on a square matrix. For cgBandApply this function should operate on a band, ie. a vector (see band).

mc.cores

The number of cores to be used. Defaults to 1

bstart

The first band to apply a function to. Defaults to 2. Only applicable to cgBandApply.

nbands

The last band to apply a function to. Default is nrow(cg) - 1. Only applicable to cgBandApply.

...

Passed to mclapply.

Details

These methods make it easy to apply functions to either all contact matrices or a set of bands in all contact matrices. Both methods accept a function FUN. For cgApply, the first argument should be cg, the contact group itself. For cgBandApply, the first argument should also be cg, and the second argument should be a specific band number. Additionally, the bands to be iterated are specified through bstart:nbands: bstart indicates the starting band, and nbands indicates the last band.

Value

For cgApply, a ContactGroup object. For cgBandApply, a list whose elements are the returned value of FUN.

See Also

ContactGroup, getBandMatrix, band

Examples

data(cgEx)
cgEx.1 <- cgApply(cgEx, FUN=function(xx){ xx + 1 })
band.matrix.list <- cgBandApply(cgEx, FUN=getBandMatrix, bstart=2, nbands=5)

hansenlab/bnbc documentation built on Feb. 4, 2024, 7:20 a.m.