# How to group rarefaction curves by metadata

I'm trying to generate a rarefaction curve plot from a phyloseq object. I'm using the function ggrare using rarecurve function from the vegan package:

The function rarecurve allow the ploting of all the samples but I can't group the samples by metadata variable

Here is my code for the rarefaction curve plot

pRare <- ggrare(epi_physeq_3.5ans, step = 100,color = "cluster_3a", label = "cluster_3a")
plot(pRare)

#epi_physeq_3.5ans : phyloseq object


This give me the curve for all samples with different colors according to the cluster_3a variable.

Howerver I want to plot only 2 curves wich are the average species richness with standar error bars for each group.

Something like from : https://doi.org/10.1038/srep08397

I can't find any package in R that allow grouping samples for plotting rarefaction curves.

Do you know any package or any idea of how that can be done ?

• Maybe there isn't any but you can use the data from vegan to draw yourself the lines (however, note that it might be better/easier if you used geom_smooth)
– llrs
Jun 21 at 15:49