# How to create Beta Diversity distance boxplot

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.

• 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
Jun 16, 2021 at 12:07

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().