Drawing arrows on a PCOA plot that represent metadata variables

Hi all,

I am interested in making a figure like this:

Where I have either an NMDS or a PCOA biplot (or loading plot I've seen it called), where the arrows represent the strength and direction of certain metadata variables that explain microbiome variation. In my case I have a factor, diet, where I would like different arrows representing the levels of my diet factor. So an herbivory arrow, a carnivory arrow and so forth, pointing to each cluster on my PCOA. I've seen ways to do this for numerical variables but not categorical. If anyone can point me in the right direction I would be forever indebted!

Hi, Sam!

I guess the simplest option would be to use q2-songbird. You may find quite a detailed tutorial in the GitHub repo.

Good luck!

1 Like

Hi @crusher083,

Thanks for the pointer. I see that they are able to plot numerical variables but I'll look into trying to fit categorical variables.

And if anyone knows a way to plot arrows representing categorical variables on a UNFIRAC PCOA please let me know!

The manual of the songbird also explains how to handle categorical variables - see repo:


Totally missed that. Thank you that is super helpful

Hi @Sam_Degregori,

I think my first recommendation would be to see if you can identify labeling based on the available tools. That, said, you could probably trick the system if you code your categorical variables as 0 and 1. (I tend to use Patsy in python; there may be something similar in R or your other favorite software.) Import that table as FeatureTable[Frequency], convert to relative frequency and then maybe look at what your options are with qiime diversity pcoa-biplot.

I might also look at options in emperor itself without the biplot. You can show about 3 metadata categories pretty easily (color, size, shape). You could also try side by side biplots colored by different variables.


Hi Justine,

Thanks for the info. The 0s and 1s trick sounds doable so I'll give that a shot. I did something similar for running MRMs before.

1 Like