<ol>
<li><p>You can use <code>as.data.frame()</code> or <code>as_tibble()</code> to convert/coerce your matrix to a data frame or a tibble respectively (Technically a tibble is also a data frame). From there you should be fine with <code>ggplot()</code>.</p>
</li>
<li><p>I would not use a &quot;dynamite plot&quot; (this is a box plot with error bars like the one in your question), that type of plots conceal the data! <a href="https://simplystatistics.org/2019/02/21/dynamite-plots-must-die/" rel="nofollow noreferrer">This post</a> explains why and remedies.</p>
</li>
</ol>

CC BY-SA 4.0
2021-06-16T19:41:27.543Z
2021-06-17T10:38:50.197Z
2021-06-17T10:38:50.197Z
haci
<p>I'm trying to generate boxplot from Beta diversity boxplot between two conditions from a phyloseq object.</p>
<p>I have a Morisita-horn distance generated by vegdist fonction :</p>
<pre><code>vegdist&lt;-vegdist(t(otu_table(physeq_genus_3a)), method=&quot;horn&quot;)#matrice distance Morisita-horn
vegdist&lt;-as.matrix(vegdist)
</code></pre>
<p>Now I have a matrix and I would like to somewhat create a mean distance boxplot of the Morisita-horn index winthin two condition like the graph below.</p>
<p>I wanted to do a simple boxplot with ggplot but beacause it is a matrix and not a dataframe, I can't do it.</p>
<p>Any help or suggestions would be more than welcome.</p>
<p><a href="https://i.sstatic.net/8bUl6.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/8bUl6.jpg" alt="enter image description here" /></a></p>

CC BY-SA 4.0
2021-06-16T12:07:01.447Z
Could you please show a bit more of your data, or another test dataset? It would be greate if you could provide enough that we could use it to create a bar plot with error bars.
gringer
<r><microbiology><graphs><phyloseq>
How to create Beta Diversity distance boxplot
# How to create Beta Diversity distance boxplot

(Asked by: username_0 on 2021-06-16)

I'm trying to generate boxplot from Beta diversity boxplot between two conditions from a phyloseq object.
I have a Morisita-horn distance generated by vegdist fonction :
vegdist<-vegdist(t(otu_table(physeq_genus_3a)), method="horn")#matrice distance Morisita-horn
vegdist<-as.matrix(vegdist)

Now I have a matrix and I would like to somewhat create a mean distance boxplot of the Morisita-horn index winthin two condition like the graph below.
I wanted to do a simple boxplot with ggplot but beacause it is a matrix and not a dataframe, I can't do it.
Any help or suggestions would be more than welcome.

**Tags:** r, microbiology, graphs, phyloseq
> **Comments:**
> **username_1**: Could you please show a bit more of your data, or another test dataset? It would be greate if you could provide enough that we could use it to create a bar plot with error bars.  

---

## 1 answers

### Answer by username_2 on 2021-06-16. Score: 1

1. You can use `as.data.frame()` or `as_tibble()` to convert/coerce your matrix to a data frame or a tibble respectively (Technically a tibble is also a data frame). From there you should be fine with `ggplot()`.
2. I would not use a "dynamite plot" (this is a box plot with error bars like the one in your question), that type of plots conceal the data! [This post](https://simplystatistics.org/2019/02/21/dynamite-plots-must-die/) explains why and remedies.


---

