make_taxa_barplot prune taxa

Here it is demonstrated how to prune the taxonomy to contain phylum names only using

tab_phy <- Summarize.Taxa(count_tab, tax_tab)$Phylum %>%
# the following 4 lines of code prune the taxonomy to contain phylum names only
rownames_to_column("tax") %>%
filter(!grepl("NA", tax)) %>% # remove taxa without kingdom or phylum level annotation
mutate(tax = gsub("\[|\]", "", tax), # remove square brackets
tax = gsub("k__.*p__", "", tax)) %>%
column_to_rownames("tax")

Is it possible to prune the taxonomy to the genus level BUT also to the next taxonomic level (i.e. Family, Order) if Genus is not listed?

*sorry as a new user I can only add two files for upload in one post. Here is the feature table I have used.
table.qza (18.5 KB)

*** I have attached the files I am using for the above. My taxonomy table is different in that it does not have the prefix per tax assignment, as I did taxonomic assignment in another software. I have made taxa bar plot visualizations in qiime2/qiime2view using the below files.
metadata.tsv (698 Bytes)
taxonomy.qza (9.0 KB)

Hi @bailey,

Welcome to the :qiime2: forum!

Taking some @SoilRotifer advice here :slightly_smiling_face:

You could use RESCRIPt's edit-taxonomy action to edit the taxonomy to what you'd like to use, and generate what you need for plotting. You can use regular expressions too. You may need to run this a couple of times depending on what you want.

Hope this helps! Cheers :lizard:

3 Likes