# make\_taxa\_barplot prune taxa

**URL:** https://forum.qiime2.org/t/make-taxa-barplot-prune-taxa/30926
**Category:** Other Bioinformatics Tools
**Created:** [July 24, 2024, 4:17am UTC](https://forum.qiime2.org/t/make-taxa-barplot-prune-taxa/30926 "2024-07-24T04:17:52Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![bailey](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/b/8491ac/32.png) [@bailey](https://forum.qiime2.org/u/bailey)
#### Post date: [July 24, 2024, 4:17am UTC](https://forum.qiime2.org/t/make-taxa-barplot-prune-taxa/30926/1 "2024-07-24T04:17:52Z")

</div>

[Here](https://forum.qiime2.org/t/creation-of-barplot-with-excel/17245/8) 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?**

---

<div class="post-metadata">

### Author: ![bailey](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/b/8491ac/32.png) [@bailey](https://forum.qiime2.org/u/bailey)
#### Post date: [July 24, 2024, 4:30pm UTC](https://forum.qiime2.org/t/make-taxa-barplot-prune-taxa/30926/2 "2024-07-24T16:30:02Z")

</div>

\*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](https://forum.qiime2.org/uploads/short-url/elBPT3vcNE37zyqKTteBRVGAUUu.qza) (18.5 KB)

---

<div class="post-metadata">

### Author: ![bailey](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/b/8491ac/32.png) [@bailey](https://forum.qiime2.org/u/bailey)
#### Post date: [July 24, 2024, 4:30pm UTC](https://forum.qiime2.org/t/make-taxa-barplot-prune-taxa/30926/3 "2024-07-24T16:30:08Z")

</div>

\*\*\* 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](https://forum.qiime2.org/uploads/short-url/bmyYSr64kTXVhmnzZpGAHNDsT6i.tsv) (698 Bytes)  
[taxonomy.qza](https://forum.qiime2.org/uploads/short-url/stAE6uTNowClEsljJaAfLgmCXMB.qza) (9.0 KB)

---

<div class="post-metadata">

### Author: ![lizgehret](https://forum.qiime2.org/user_avatar/forum.qiime2.org/lizgehret/32/17128_2.png) [@lizgehret](https://forum.qiime2.org/u/lizgehret)
#### Post date: [July 24, 2024, 11:17pm UTC](https://forum.qiime2.org/t/make-taxa-barplot-prune-taxa/30926/6 "2024-07-24T23:17:54Z")

</div>



---

<div class="post-metadata">

### Author: ![lizgehret](https://forum.qiime2.org/user_avatar/forum.qiime2.org/lizgehret/32/17128_2.png) [@lizgehret](https://forum.qiime2.org/u/lizgehret)
#### Post date: [July 29, 2024, 6:19pm UTC](https://forum.qiime2.org/t/make-taxa-barplot-prune-taxa/30926/8 "2024-07-29T18:19:21Z")

</div>

Hi @bailey,

Welcome to the :qiime2: forum!

> [@bailey](#):
>
> 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?

Taking some @SoilRotifer advice here 🙂

You could use RESCRIPt's [edit-taxonomy action](https://forum.qiime2.org/t/processing-filtering-and-evaluating-the-silva-database-and-other-reference-sequence-data-with-rescript/15494#heading--sixteenth-header) 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 🦎

---

<div class="post-metadata">

### Author: ![lizgehret](https://forum.qiime2.org/user_avatar/forum.qiime2.org/lizgehret/32/17128_2.png) [@lizgehret](https://forum.qiime2.org/u/lizgehret)
#### Post date: [July 29, 2024, 6:19pm UTC](https://forum.qiime2.org/t/make-taxa-barplot-prune-taxa/30926/9 "2024-07-29T18:19:26Z")

</div>


