topf: Make filter fun. that returns the top f fraction of taxa in a...

Description Usage Arguments Value See Also Examples

View source: R/transform_filter-methods.R

Description

As opposed to topp, which gives the most abundant p fraction of observed taxa (richness, instead of cumulative abundance. Said another way, topf ensures a certain fraction of the total sequences are retained, while topp ensures that a certain fraction of taxa/species/OTUs are retained.

Usage

1
topf(f, na.rm=TRUE)

Arguments

f

Single numeric value between 0 and 1.

na.rm

Logical. Should we remove NA values. Default TRUE.

Value

A function (enclosure), suitable for filterfun_sample, that will return TRUE for each element in the taxa comprising the most abundant f fraction of individuals.

See Also

topk, topf, topp, rm_outlierf

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
t1 <- 1:10; names(t1)<-paste("t", 1:10, sep="")
topf(0.6)(t1)
## 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(topf(0.4))
(wh1 <- genefilter_sample(testOTU, f1, A=1))
wh2 <- c(TRUE, TRUE, TRUE, FALSE, FALSE)
prune_taxa(wh1, testOTU)
prune_taxa(wh2, testOTU)

Example output

   t1    t2    t3    t4    t5    t6    t7    t8    t9   t10 
FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE  TRUE  TRUE 
  sp1   sp2   sp3   sp4   sp5 
FALSE FALSE  TRUE  TRUE FALSE 
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

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