rarefyFilter: Rarefaction combined with sample filtering

View source: R/rarefyFilter.R

rarefyFilterR Documentation

Rarefaction combined with sample filtering

Description

Rarefy a matrix to the given minimum count number column-wise using vegan's rrarefy function. If columns have less than the minimum count number, they are discarded.

Usage

rarefyFilter(x, min = 0)

Arguments

x

a matrix

min

minimum count to which x is to be rarefied (if equal to zero, the minimum column sum is taken as min)

Value

a list with the rarefied matrix (rar) and the indices of the columns that were kept (colindices)

Examples

data(david_stoolA_otus)
filtered=rarefyFilter(david_stoolA_otus,min=1000)
# the rarefied OTU table is stored in rar
stoolARar=filtered$rar
# print names of samples that were discarded because they had less than min reads
discarded=setdiff(1:ncol(david_stoolA_otus),filtered$colindices)
print(colnames(david_stoolA_otus)[discarded])

hallucigenia-sparsa/seqtime documentation built on Jan. 9, 2023, 11:53 p.m.