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.

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)
#> [1] "Number of columns 329" #> [1] "Keeping 321 columns with column sums equal or above 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])
#> [1] "SAMPLE_Stool13" "SAMPLE_Stool36" "SAMPLE_Stool63" "SAMPLE_Stool120" #> [5] "SAMPLE_Stool147" "SAMPLE_Stool300" "SAMPLE_Stool196" "SAMPLE_Stool217"