Skip to content

Commit

Permalink
fix BF ratio
Browse files Browse the repository at this point in the history
  • Loading branch information
twbattaglia committed Oct 17, 2016
1 parent 1d437b0 commit dcb9492
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions R/bf_ratio.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ bf_ratio <- function(phylo){
phyla <- phyloseq::tax_glom(physeq = phylo, taxrank = "Phylum")

# Find relative abundances
phyla_rel <- phyloseq::transform_sample_counts(phyla, function(x) {x/sum(x)} )
phyla_rel <- phyloseq::transform_sample_counts(phyla, function(x) { x/sum(x) } )

# Keep B/F taxa
phyla_rel_bact <- suppressWarnings(phyloseq::otu_table(phyloseq::subset_taxa(phyla_rel, Phylum == "Bacteroidetes")))
phyla_rel_firm <- suppressWarnings(phyloseq::otu_table(phyloseq::subset_taxa(phyla_rel, Phylum == "Firmicutes")))
tax_table(phyla_rel)
phyla_rel_bact <- otu_table(subset_taxa(phyla_rel, Phylum == "Bacteroidetes"))
phyla_rel_firm <- suppressWarnings(otu_table(subset_taxa(phyla_rel, Phylum == "Firmicutes")))

# OTU
bf_ratio <- log2(phyla_rel_bact / phyla_rel_firm)
Expand Down

0 comments on commit dcb9492

Please sign in to comment.