[R] labeling loading vectors in vegan

Gavin Simpson gavin.simpson at ucl.ac.uk
Tue Jul 31 14:09:34 CEST 2012


On Fri, 2012-07-27 at 11:52 -0700, Gordon Holtgrieve wrote:
> Hello,
> 
> I am using vegan to do an NMDS plot and I would like to suppress the labels
> for the loading vectors. Is this possible?  Alternatively, how can I avoid
> overlap?

Hi Gordon,

You seem to be trying to fit the species scores as a weighted sum a la
PCA. Usually we add species scores as weighted averages of the site
scores in NMDS. metaMDS() handles the latter for you:

require(vegan)
data(varespec)
data(varechem)

mod <- metaMDS(varespec)
plot(mod)

and you can get the "species" scores directly via:

scrs <- scores(mod, display = "species")

> head(scrs)
              NMDS1       NMDS2
Cal.vul -0.16696628 -0.07418638
Emp.nig  0.05870236  0.10673232
Led.pal  0.88640043 -0.10135959
Vac.myr  0.71139281 -0.10964309
Vac.vit  0.04389918  0.09996126
Pin.syl -0.02588978  0.2963255

There isn't a nice way to fiddle with the plotting of "envfit" objects
that will stop overlap as most of the potential functions don't work
with "envfit" objects.

This would be easier if you worked with the WA species scores as we
could do

plot(mod)
ordipointlabel(mod, display = "species", add = TRUE,
               col = "forestgreen")

where the latter function will do its best to avoid overlap.

Making "envfit" objects work in the same way will require a good amount
of rewriting various functions which is not something I will have time
to do for a few months, but I will add it to the TODO list and discuss
with Jari about how to proceed.

Feel free to contact me off-list if you require further help with this.

All the best,

Gavin


> Many thanks for the help.
> 
> 
> Example code:
> #perform NMDS using metaMDS() function
> spe.nmds<-metaMDS(data, distance='bray',k=2 , engine = "isoMDS",
> autotransform=F, trymax=1000)
> 
>  #calculate the loading (i.e., variable weights) on each NMDS axis
> vec.sp<-envfit(spe.nmds$points, data, perm=1000, choices=c(1:2))
> 
> #plot data in ordination
> ordiplot(spe.nmds, choices=c(1:2), type='text', display="sites", xlab="Axis
> 1", ylab="Axis 2")
> 
> #plot loading vectors
> plot(vec.sp, p.max=0.05, col='blue')
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%



More information about the R-help mailing list