# Taxonomy Table Using R Studio

**URL:** https://forum.qiime2.org/t/taxonomy-table-using-r-studio/29231
**Category:** Other Bioinformatics Tools
**Tags:** taxonomy, qiime2r
**Created:** [February 13, 2024, 1:06am UTC](https://forum.qiime2.org/t/taxonomy-table-using-r-studio/29231 "2024-02-13T01:06:00Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![2Black\_Cats](https://forum.qiime2.org/user_avatar/forum.qiime2.org/2black_cats/32/16450_2.png) [@2Black\_Cats](https://forum.qiime2.org/u/2Black_Cats)
#### Post date: [February 13, 2024, 1:06am UTC](https://forum.qiime2.org/t/taxonomy-table-using-r-studio/29231/1 "2024-02-13T01:06:00Z")

</div>

Hi! After a little trial and error, I was able to create a taxonomy table using qiime2R in R Studio, which looks great. My only concern now is that I want the taxonomic classification in the legend to just have the specific taxa classification that I'm focusing on for that specific chart (i.e., Phyla, Family, etc.). My current code includes the entire string of the classification from Kingdom to whatever classification I'm going to. Here is an example of the code I'm using at the Phyla level:

metadata\<-read\_q2metadata("metadata.tsv")  
SVs\<-read\_qza("table.qza")$data  
taxonomy\<-read\_qza("taxonomy.qza")$data %\>% parse\_taxonomy()  
taxonomy$Kingdom \<- gsub("^d\_\_", "", taxonomy$Kingdom)

#Phyla  
taxasums\<-summarize\_taxa(SVs, taxonomy)$Phylum  
taxa\_barplot(taxasums, metadata, "Treatment")

Any advice is greatly appreciated!

---

<div class="post-metadata">

### Author: ![colinbrislawn](https://forum.qiime2.org/user_avatar/forum.qiime2.org/colinbrislawn/32/6221_2.png) [@colinbrislawn](https://forum.qiime2.org/u/colinbrislawn)
#### Post date: [February 15, 2024, 10:32pm UTC](https://forum.qiime2.org/t/taxonomy-table-using-r-studio/29231/2 "2024-02-15T22:32:52Z")

</div>

Hey, did you get this figured out?

When I make taxonomy for bar plots, I usually make a new data frame column and add in just the levels that I want.

```R
# base R
taxonomy$newColumn <- paste(taxonomy$Kingdom, taxonomy$Phylum)

# using tidyverse
taxonomy <- taxonomy %>%
  mutate(newColumn = paste(Kingdom, Phylum))

```
