genoapply: Apply a function over a 'genotypes' object, by sample or...

Description Usage Arguments Details Value Examples

Description

An homage to base R's apply family of functions.

Usage

1
2
genoapply(gty, margin = c(1, 2), expr = 1, fn = NULL, strip = FALSE,
  ...)

Arguments

gty

an object of class genotypes

margin

dimension of the array over which to apply expr (1=rows, 2=columns)

expr

an expression defining subsets of gty, either by markers (margin = 1) or samples (margin = 1)

fn

the function to apply over the subsets defined by expr

strip

logical; if TRUE, strip metadata before evaluating fn()

...

other arguments passed-through to fn()

Details

The grouping expression expr is evaluated in the parent environment by default. Use the dot function to get lazy evaluation like with subset() (see examples).

When fn() will involve heavy use of array slicing, use strip to avoid having to slice sample/marker metadata repeatedly.

Value

a list with one element per value of the grouping expression (expr); the value of that element is the return value of fn() applied to the subset of gty defined by expr

Examples

1
2
3
4
5
6
7
8
9
# lazy evaluation 1: apply over chromosomes
## Not run: 
genoapply(x, 1, .(chr), myfunction, extra.arg = TRUE)

## End(Not run)
## Not run: 
genoapply(x, 2, .(fid), myfunction, extra.arg = TRUE)

## End(Not run)

andrewparkermorgan/argyle documentation built on May 10, 2019, 11:08 a.m.