CCA plot

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

CCA plot

Maria Kernecker
Hi, I have a couple questions about fitting environmental (land use
factors, plant species presence-absence, and soil variables) constraints to
my CCA biplot. 1. After successfully plotting species and site scores in my
CCA, I have been trying to insert the biplot arrows of the environmental
constraints in my data set using the text() function. When I do that, the
plot changes completely. Is there some code or a sample script you could
let me know about? 2. I would like to include only the environment
constraints that are significant at conf=0.95, but am not sure that I can
do that in a CCA biplot. I was hoping that this way I could make my plot
less crowded.
Thanks!

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: CCA plot

Gavin Simpson
On Tue, 2012-11-27 at 15:35 -0500, Maria Kernecker wrote:
> Hi, I have a couple questions about fitting environmental (land use
> factors, plant species presence-absence, and soil variables) constraints to
> my CCA biplot. 1. After successfully plotting species and site scores in my
> CCA, I have been trying to insert the biplot arrows of the environmental
> constraints in my data set using the text() function. When I do that, the
> plot changes completely. Is there some code or a sample script you could
> let me know about?

I'm not sure what you tried but this works for me:

require(vegan)
data(varespec)
data(varechem)
## Common but bad way: use all variables you happen to have in your
## environmental data matrix
vare.cca <- cca(varespec ~ ., data = varechem)

## build up plot
plot(vare.cca, display = c("sites","species"), scaling = 3)
## add the biplot arrows (though this could be done in the plot() call
text(vare.cca, scaling = 3, display = "bp")

>  2. I would like to include only the environment
> constraints that are significant at conf=0.95, but am not sure that I can
> do that in a CCA biplot. I was hoping that this way I could make my plot
> less crowded.

One way would be:

sig <- anova(vare.cca, by = "term")
## get ones with p values less than or equal to some threshold
ind <- with(sig, head(`Pr(>F)` <= 0.05, -1))

## now get the bp scores
scrs <- scores(vare.cca, display = "bp", scaling = 3)
## and take the ones that are signif
scrs <- scrs[ind, ]

## draw plot and add them
plot(vare.cca, display = c("sites","species"), scaling = 3)
## scale then as per vegan
mul <- vegan:::ordiArrowMul(scrs)
arrows(0, 0, scrs[,1] * mul, scrs[,2] * mul, length = 0.05,
       col = "blue")
text(scrs * mul * 1.1, labels = rownames(scrs), cex = 0.9,
     col = "blue")

Not that I recommend this "pruning" a CCA...

HTH

G

--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 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
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

______________________________________________
[hidden email] 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.