Nevil Amos
2010-Sep-21 14:40 UTC
[R] partial dbRDA or CCA with two distance objects in Vegan.
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). many thanks Nevil Amos ACB Monash University references (Geffen, E., M. J. Anderson, et al. (2004). "Climate and habitat barriers to dispersal in the highly mobile grey wolf." Molecular Ecology 13(8): 2481-2490.) LEGENDRE, P. and M.-J. FORTIN (2010). "Comparison of the Mantel test and alternative approaches for detecting complex multivariate relationships in the spatial analysis of genetic data." Molecular ecology resources early copy online Snippet from analysis script: > Gen_Dist<-dist.genpop(mygenpop,method=2,diag=F,upper=F) > str(Gen_Dist) Class 'dist' atomic [1:666] 0.866 0.757 0.813 0.872 0.887 ... ..- attr(*, "Labels")= Named chr [1:37] "4879" "4883" "4884" "4885" ... .. ..- attr(*, "names")= chr [1:37] "01" "02" "03" "04" ... ..- attr(*, "Size")= int 37 ..- attr(*, "call")= language dist.genpop(x = mygenpop, method = 2, diag = F, upper = F) ..- attr(*, "Diag")= logi FALSE ..- attr(*, "Upper")= logi FALSE ..- attr(*, "method")= chr "Edwards" > str(geog) Class 'dist' atomic [1:666] 6.61 4.19 14.6 16.71 16.68 ... ..- attr(*, "Size")= int 37 ..- attr(*, "Labels")= chr [1:37] "2" "5" "6" "7" ... ..- attr(*, "Diag")= logi FALSE ..- attr(*, "Upper")= logi FALSE ..- attr(*, "method")= chr "euclidean" ..- attr(*, "call")= language dist(x = XY) > myDbRDA<-cca(Gen_Dist ~ Latitude+Longitude+Condition(Clade),data = mydata) > myDbRDA<-cca(Gen_Dist ~ Latitude+Longitude+Condition(geog),data = mydata) Error in weighted.mean.default(newX[, i], ...) : 'x' and 'w' must have the same length
Jari Oksanen
2010-Sep-21 15:34 UTC
[R] partial dbRDA or CCA with two distance objects in Vegan.
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