# Phyloseq graph using Q2 ASV code : how to get the real Phylum or Genus name?

**URL:** <https://forum.qiime2.org/t/phyloseq-graph-using-q2-asv-code-how-to-get-the-real-phylum-or-genus-name/13731>\
**Category:** Other Bioinformatics Tools\
**Created:** [February 22, 2020, 2:35pm UTC](https://forum.qiime2.org/t/phyloseq-graph-using-q2-asv-code-how-to-get-the-real-phylum-or-genus-name/13731 "2020-02-22T14:35:06Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![MathiasLR](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@MathiasLR](https://forum.qiime2.org/u/MathiasLR)\
**Post date:** [February 22, 2020, 2:35pm UTC](https://forum.qiime2.org/t/phyloseq-graph-using-q2-asv-code-how-to-get-the-real-phylum-or-genus-name/13731/1 "2020-02-22T14:35:07Z")

</div>

Hello!

I have used Q2 a lot lately and I want to use some features of Phyloseq illustration in R now but I have very often a problem with the code names used by Q2 that looks like "2ec862esddlr88965a8855d665er2245" which is not helping for the analysis.  
I am wondering whether during my exportation of Q2 object to Phyloseq object I can do something about it so I won't get these ugly name ;-)!

This codes for instance:

```R
clean_physeq2essai_phylum = phyloseq::tax_glom(clean_physeq2essai, "Phylum")
phyloseq::psmelt(clean_physeq2essai_phylum) %>%
  ggplot(data = ., aes(x = Group_Timepoint, y = Abundance)) +
  geom_boxplot(outlier.shape = NA) +
  geom_jitter(aes(color = OTU), height = 0, width = .2) +
  labs(x = "", y = "Abundance\n") +
  facet_wrap(~ OTU, scales = "free")

```

Gives my that

 ![plot](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/2X/c/cc3af0dd418e11c8fc538e2a04619577c29cd5ef.png)

---

<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 23, 2020, 11:52pm UTC](https://forum.qiime2.org/t/phyloseq-graph-using-q2-asv-code-how-to-get-the-real-phylum-or-genus-name/13731/2 "2020-02-23T23:52:41Z")

</div>

Hello Mathias! Welcome back,

Can you post the output of this line?

```R
phyloseq::psmelt(clean_physeq2essai_phylum) %>% head()

```

That will tell us all the columns of the R data.frame(), and one of those columns _should_ be an informative taxonomy name like Phylum, and we can pass that column name to ggplot.

I think we are really close to solving it... 🕵️‍♀️

Colin

P.S. I've put your code inside of a `code block`. They're cool

---

<div class="post-metadata">

**Author:** ![MathiasLR](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@MathiasLR](https://forum.qiime2.org/u/MathiasLR)\
**Post date:** [February 24, 2020, 1:37pm UTC](https://forum.qiime2.org/t/phyloseq-graph-using-q2-asv-code-how-to-get-the-real-phylum-or-genus-name/13731/3 "2020-02-24T13:37:21Z")

</div>

Hello Colin,

Thanks for your reply… I know I am not at the perfect forum for this type of question… I was afraid I would be blocked 😉  
So here is the output 🙂 :  
OTU Sample Abundance ATB\_VEHICULE Group\_ATB Timepoint Num\_mice SameMice2Timepoints Group\_mice  
71 62d492efc804b7f173b5286cffca8603 MS35 0.8745698 ATB Long D10 70 YES ABLong\_D10  
59 62d492efc804b7f173b5286cffca8603 MS32 0.8688360 ATB Short D10 40 YES ABShort\_D10  
94 9c79cbb243d988ebe749b6d2753696ed MS1 0.8471313 VEHICULE None D\_Bef24 A NO Ctrl\_Dbef24  
55 62d492efc804b7f173b5286cffca8603 MS31 0.8471070 ATB Short D10 38 YES ABShort\_D10  
130 9c79cbb243d988ebe749b6d2753696ed MS7 0.8447736 VEHICULE None D\_Bef24 G NO Ctrl\_Dbef24  
120 9c79cbb243d988ebe749b6d2753696ed MS3 0.8400406 VEHICULE None D\_Bef24 C NO Ctrl\_Dbef24  
Group\_Timepoint accurate\_group Kingdom Phylum  
71 D10\_Abx 5\_D10\_Abx D\_0\_\_Bacteria D\_1\_\_Proteobacteria  
59 D10\_Abx 5\_D10\_Abx D\_0\_\_Bacteria D\_1\_\_Proteobacteria  
94 D0\_no\_Abx 1\_D-24\_no\_abx D\_0\_\_Bacteria D\_1\_\_Bacteroidetes  
55 D10\_Abx 5\_D10\_Abx D\_0\_\_Bacteria D\_1\_\_Proteobacteria  
130 D0\_no\_Abx 1\_D-24\_no\_abx D\_0\_\_Bacteria D\_1\_\_Bacteroidetes  
120 D0\_no\_Abx 1\_D-24\_no\_abx D\_0\_\_Bacteria D\_1\_\_Bacteroidetes

So yes there is indeed the “Phylum” column… but sorry I don’t know how to put the right wording to replace the “ugly” name by the phylum in the figure !!! ☹  
Thank you for your help.

Best,  
Mathias

---

<div class="post-metadata">

**Author:** ![MathiasLR](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@MathiasLR](https://forum.qiime2.org/u/MathiasLR)\
**Post date:** [February 24, 2020, 2:22pm UTC](https://forum.qiime2.org/t/phyloseq-graph-using-q2-asv-code-how-to-get-the-real-phylum-or-genus-name/13731/4 "2020-02-24T14:22:54Z")

</div>

Ok ok ! I am back... your suggestion was enough to put me on the right track!  
I feel ashamed that I did not think about that 🙄  
I just have to change OTU for Phylum... da!  
Many thanks Colin !

Here is the code modified:

```R
clean_physeq2essai_phylum = phyloseq::tax_glom(ps_rel_abund, "Phylum")
phyloseq::psmelt(clean_physeq2essai_phylum) %>%
  ggplot(data = ., aes(x = accurate_group, y = Abundance)) +
  geom_boxplot(outlier.shape = NA) +
  geom_jitter(aes(color = Phylum), height = 0, width = .2) +
  labs(x = "", y = "Abundance\n") +
  facet_wrap(~ Phylum, scales = "free")

```

---

<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 24, 2020, 2:31pm UTC](https://forum.qiime2.org/t/phyloseq-graph-using-q2-asv-code-how-to-get-the-real-phylum-or-genus-name/13731/5 "2020-02-24T14:31:20Z")

</div>

Hello Mathias,

You got this!

Here's how ggplot works:  
ggplot maps metadata **columns** , to **aesthetics** using the `aes()` function.  
Note that Group\_Timepoint, Abundance, and OTU are all columns in your dataframe.

```auto
aes(x = Group_Timepoint, position on the x axis
 y = Abundance, position on the y axis 
OTU = color of each point

```

But you can map these out any way that you want! Try this 👇

```R
phyloseq::psmelt(clean_physeq2essai_phylum) %>%
  ggplot(aes(x = Group_Timepoint, y = Abundance, size = Abundance)) +
  geom_boxplot(outlier.shape = NA) +
  geom_jitter(aes(color = Phylum), height = 0, width = .2) +
  labs(x = "", y = "Abundance\n") +
  facet_wrap(~ Phylum, scales = "free")

```

So basically I've replaced OTU with Phylum, so that it uses the data in the other column.

Why are the sizes different? 🙀 Did you notice I snuck in `size = Abundance` to the aes() function? You should probably take that out... but you can also edit the other settings too!

Colin

---

<div class="post-metadata">

**Author:** ![MathiasLR](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@MathiasLR](https://forum.qiime2.org/u/MathiasLR)\
**Post date:** [February 24, 2020, 2:56pm UTC](https://forum.qiime2.org/t/phyloseq-graph-using-q2-asv-code-how-to-get-the-real-phylum-or-genus-name/13731/6 "2020-02-24T14:56:57Z")

</div>

Great Colin!  
"size = Abundance" is a nice touch! I'll keep it.  
Many thanks for your efficiency!  
👍

---

<div class="post-metadata">

**Author:** ![MathiasLR](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@MathiasLR](https://forum.qiime2.org/u/MathiasLR)\
**Post date:** [February 24, 2020, 10:56pm UTC](https://forum.qiime2.org/t/phyloseq-graph-using-q2-asv-code-how-to-get-the-real-phylum-or-genus-name/13731/7 "2020-02-24T22:56:52Z")

</div>

Hey Colin,

I have a tiny little question... what would I have to do if I want to show only one Phylum like "D\_1\_Proteobacteria"?

Well got my answer alone... (it was too late yesterday 🙂 ) it is a simple "subset" like:

```R
ggplot(subset(q, Family == "D_1_Proteobacteria"), aes(x = Group_Timepoint, y = Abundance, size = Abundance)) +
  geom_boxplot(outlier.shape = NA) +
  geom_jitter(aes(color = Family), height = 0, width = .2) +
  labs(x = "", y = "Abundance\n") +
  theme(axis.text.x = element_text(angle = 40, hjust = 1))

```

Cheers! 🙂  
Mat

---

<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 25, 2020, 8:18pm UTC](https://forum.qiime2.org/t/phyloseq-graph-using-q2-asv-code-how-to-get-the-real-phylum-or-genus-name/13731/8 "2020-02-25T20:18:13Z")

</div>

Hello Mat,

Glad you found the answer!

All the packages in the Tidyverse have a 'Right Way' 👈 to do stuff like this, and it uses `filter()` instead of `subset()`:

```R
phyloseq::psmelt(clean_physeq2essai_phylum) %>%
  filter(Family == "D_1_Proteobacteria") %>%
  ggplot(aes(x = Group_Timepoint, y = Abundance, size = Abundance)) + ...

```

But you can do what you want! 😛

Colin

---

<div class="post-metadata">

**Author:** ![system](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/3X/2/1/21af5fe23cb6f4579467c66a9ed94e55274ca7bd.svg) [@system](https://forum.qiime2.org/u/system)\
**Post date:** [March 28, 2020, 2:18am UTC](https://forum.qiime2.org/t/phyloseq-graph-using-q2-asv-code-how-to-get-the-real-phylum-or-genus-name/13731/9 "2020-03-28T02:18:19Z")

</div>

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
