otu.tab.clean <-
function(biom, lib.size.cut.off = 1000, mean.prop.cut.off = mean.prop.cut.off) {
otu.tab <- otu_table(biom)
tax.tab <- tax_table(biom)
tree <- phy_tree(biom)
sam.dat <- sample_data(biom)
lib.size <- colSums(otu.tab)
ind.low.lib.size <- which(lib.size > lib.size.cut.off)
lib.size <- lib.size[ind.low.lib.size]
otu.tab <- otu.tab[,ind.low.lib.size]
sam.dat <- sam.dat[ind.low.lib.size,]
prop.otu.tab <- otu.tab
for (i in 1:length(lib.size)) {
prop.otu.tab[,i] <- otu.tab[,i]/lib.size[i]
}
mean.prop <- rowMeans(prop.otu.tab)
ind.low.mean.prop <- which(mean.prop >= mean.prop.cut.off)
taxa <- rownames(otu.tab)[ind.low.mean.prop]
biom <- merge_phyloseq(otu.tab, tax.tab, tree, sam.dat)
biom <- prune_taxa(taxa, biom)
return(biom)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.