topk: Make filter fun. the most abundant 'k' taxa

Description Usage Arguments Value See Also Examples

View source: R/transform_filter-methods.R

Description

Make filter fun. the most abundant k taxa

Usage

1
topk(k, na.rm=TRUE)

Arguments

k

An integer, indicating how many of the most abundant taxa should be kept.

na.rm

A logical. Should NAs be removed. Default is TRUE.

Value

Returns a function (enclosure) that will return TRUE for each element in the most abundant k values.

See Also

topk, topf, topp, rm_outlierf

Examples

1
2
3
4
5
6
7
8
## Use simulated abundance matrix
set.seed(711)
testOTU <- otu_table(matrix(sample(1:50, 25, replace=TRUE), 5, 5), taxa_are_rows=FALSE)
f1  <- filterfun_sample(topk(2))
wh1 <- genefilter_sample(testOTU, f1, A=2)
wh2 <- c(TRUE, TRUE, TRUE, FALSE, FALSE)
prune_taxa(wh1, testOTU)
prune_taxa(wh2, testOTU)

Example output

OTU Table:          [2 taxa and 5 samples]
                     taxa are columns
    sp3 sp4
sa1  13  48
sa2  31  36
sa3  44  36
sa4  42  47
sa5  48  40
OTU Table:          [3 taxa and 5 samples]
                     taxa are columns
    sp1 sp2 sp3
sa1  15   7  13
sa2  22  16  31
sa3  17   4  44
sa4  32  29  42
sa5  23  33  48
Warning message:
system call failed: Cannot allocate memory 

phyloseq documentation built on Nov. 8, 2020, 6:41 p.m.