How to add convex hulls to beta diversity graphs using phyloseq

25 Views Asked by At

I have fungal community data, I use the phyloseq package in R to handle the data. I have created some beta diversity graphs and would like to add convex hulls to the plots to help visualise community crossover.

The best I have managed is the following code:

all_beta <- plot_ordination(pseq_rmcv, ord.nmds.bray, color="hostG", title="Bray NMDS")

all_beta + geom_point(size=2) + facet_wrap(vars(site), scales = "free") + geom_polygon(aes(fill=hostG, alpha = 0.2))

This results in the following plot:

NMDS plots

The issue being the way the points are joined, I would like to create a polygon that connects only the outermost points of each Genus.

I think a solution is that I could use chull() to find the coordinates of the outermost points and provide them in geom_polygon(). The specific issue I have is that I cannot find how to grab these coordinates when working with the phyloseq package.

I am ordinating my data with the following code:

ord.nmds.bray <- phyloseq::ordinate(pseq_rmcv, method="NMDS")

0

There are 0 best solutions below