Reputation: 57
I am trying to perform an NMDS ordination on a large data set with well over 50 sample points across different time points and varying collection points. Each sample point has thousands of OTUs sequenced/assembled for it.
I understand that one way of adding ellipses is to manually add 'meta-data' which can be incorporated into the NMDS plot, as shown in this question.
However, I would like to add ellipses without having to go through the tedious and potentially error-prone process of manually adding meta-data as shown in the aforementioned question.
Is there any way that I can somehow 'automate' this process? My sample points are all titled in the same format, one typical example is '12.14.2011.NP'. 'NP' stands for one of the sample sites.
I would like to know how I can create ellipses for all of the 'NP' points- and all of the other different sample sites too. The are all named by a particular acronym.
Thanks.
Upvotes: 1
Views: 235
Reputation: 3682
If you have a variable with levels, names or other identifiers for ellipses, you can use those. If these identifiers are embedded in other strings, you should remove the unnecessary parts. See gsub
, substring
, strsplit
to manipulate the strings. If all your names are of the type you gave, and you want to remove numbers and dots and leave characters, this will work:
gsub('[0-9.]', '', '12.14.2011.NP')
or for all names in data frame mydata
:
gsub('[0-9.]', '', rownames(mydata))
Upvotes: 1