microViz
microViz copied to clipboard
dominant taxa in each sample
I have two issues.
- on the figure attached. some samples clearly have a dominant genera but it is labelled 'other' on the bar. e.g the last sample on the figure is dominated by Pseudomonas but it is labelled 'other' 2)There seems to be 2 samples in which 2 genera have at least 30% abundance threshold. (Streptococcus, Haemophilus). One labelled Haemophilus and the other Streptococcus. Is it possible to name such samples as e.g Streptococcus-Haemophilus dominant
ps <- ps_calc_dominant( ps = POb_bac_filtered, rank = "Genus", threshold = 0.30, var = "dominant_genus", n_max = 17, none = "diverse", other = "other" )
with(sample_data(ps), table(dominant_genus)) dominant_genus Actinobacillus Alloprevotella Brachybacterium Cloacibacterium 1 4 1 1 Corynebacterium diverse Fusobacterium Haemophilus 2 697 6 4 Lautropia Moraxella Neisseria Pasteurellaceae Genus 1 15 5 1 Porphyromonas Prevotella Pseudomonas Staphylococcus 7 9 9 5 Streptobacillus Streptococcus 1 29 ps_subset <- subset_samples(ps, dominant_genus != "diverse")
ps_subset %>% ps_filter(Spn == "Pos") %>% ps_calc_dominant(rank = "Genus") %>% comp_barplot(tax_level = "Genus", label = "dominant_Genus", n_taxa = 17) + coord_flip()

threshold <- 0.3
ps %>%
tax_transform("compositional", rank = "Genus") %>%
otu_get() %>%
as.data.frame() %>%
as_tibble() %>%
mutate(Streptoccocus_and_Haemophilus = Streptococcus + Haemophilus) %>%
mutate(S_and_H_dominate_together = if_else(
condition = Strep_and_Haemo > threshold & Streptococcus <= threshold & Haemophilus <= threshold,
true = TRUE, false = FALSE
)) %>%
select(S_and_H_dominate_together, Strep_and_Haemo, Streptococcus, Haemophilus)
Oops I did not read your second question correctly
There seems to be 2 samples in which 2 genera have at least 30% abundance threshold
but still, you would have to do this manually, there's no built in functionality for this