[R] partial dbRDA or CCA with two distance objects in Vegan.
Gavin Simpson
gavin.simpson at ucl.ac.uk
Tue Sep 21 19:02:41 CEST 2010
On Wed, 2010-09-22 at 02:34 +1000, Nevil Amos wrote:
> Thanks for that, just to confirm I therefore need to use:
> #if
> #geogdist is a geographic distance matrix
> #gen_dist is a genetic distance matrix
> #env_var are environmental variables
>
> mypcnm<-pcnm(geogdist)
>
>
> mydbRDA<-capscale(gen_dist~env_var+Condition(mypcnm$vectors))
A cleaner way to extract the vectors is to use the scores method for
pcnm objects:
scores(mypcnm)
gives the same as
mypcnm$vectors
but avoids the ugly $ subsetting and allows for the vegan developers to
call $vectors something different if we feel like it :-)
But to answer your main Q, yes, AFAIU, that is how you should do the
analysis. You might also want to think about whether you should retain
all /m/ pcnm components? Some later components will represent nothing
more than random variation in the response (or be indistinguishable from
random variation) and maybe shouldn't be included as spatial structure.
I.e. do:
mod <- capscale(gen_dist ~ scores(mypcnm))
anova(mod, by = "axis")
See which axes are "significant", for purposes of this example assume
the first 10, then use them in your condition model:
mydbRDA <- capscale(gen_dist ~ env_var +
Condition(scores(mypcnm, choices = 1:10)))
Anyway, just a thought. And if I'm talking rubbish Jari will no doubt
correct me in short order ;-)
G
> cheers
>
>
> Nevil
>
>
>
>
>
> On 22/09/2010 1:34 AM, Jari Oksanen wrote:
> > On 21/09/10 17:40 PM, "Nevil Amos"<nevil.amos at gmail.com> wrote:
> >
> >> I am trying to use the cca/rda/capscale functions in vegan to analyse
> >> genetic distance data ( provided as a dist object calculated using
> >> dist.genpop in package adegenet) with geographic distance partialled out
> >> ( provided as a distance object using dist function in veganthis method
> >> is attempting to follow the method used by Geffen et al 2004 as
> >> suggested by Legendre and . FORTIN (2010).
> >>
> >> I cannot see how to introduce the Conditioning ( partialled) second dist
> >> matrix. as you can see from the code snippet below, the two dist
> >> objects are of the same dimensions. - I get an error using capscale:
> >> Error in qr.fitted(Q, Xbar) :
> >> 'qr' and 'y' must have the same number of rows
> >> or cca
> >> Error in weighted.mean.default(newX[, i], ...) :
> >> 'x' and 'w' must have the same length
> >> when using a conditioning distance object instead of a variable (Clade)
> >> of the same length as the constraints ( Latitude and Longitude)
> >>
> >> I would be grateful, for any pointers on this, ie which test is the
> >> appropriate one to use ( I believe capscale since it is "similar to
> >> distance-based redundancy analysis (Legendre& Anderson 1999)") and
> >> whether this test is indeed equivalent to the approach suggested by
> >> Legendre&Fortin, (Geffen et al used DISTLM).
> >>
> > Nevil,
> >
> > You cannot use cca() for dissimilarity data. If you have dissimilarity data,
> > you must use capscale() which runs db-RDA. Even there, your constraints
> > (variables on the right hand side of the formula) must be rectangular data
> > and not dissimilarities. AFAIK, people have changed their dissimilarities
> > into a PCNM structure when they want to partial out the distance effect.
> > That is one of the few original possibilities since data must be rectangular
> > (rows and columns).
> >
> > Cheers, jari oksanen
> >
>
> ______________________________________________
> 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