[R-sig-eco] Problem with Capscale and Phylobetadiversity distance matrix
Alexandre F. Souza
alexsouza.cb.ufrn.br at gmail.com
Wed Mar 18 22:08:40 CET 2015
Hello everyone,
I have a problem trying to use vegan's capscale() on a phylobetadiversity
distance matrix, reproduced below using the example:
library(psych) # For the PCA test involved
# Opens a full matrix of 245 x 245 phylobetadiversity distances
bnti.ses = read.csv(file.choose(), header = T, row.names=1);
dim(bnti.ses); # this gives the dimensions
bnti.ses[1:5,1:5]; # this gives a look at the first 5 rows and columns
# Test PCA scores
test = data.frame(replicate(10,sample(0:100,245,rep=TRUE)))
test
pca = principal(teste, nfactors = 3, covar = FALSE, scores = TRUE)
meta.pca.scores = pca$scores
rownames(meta.pca.scores)=rownames(bnti.ses)
## dbRDA
# betaNTI standard effect size
bnti.ses = bnti.ses + abs(min(bnti.ses));
bnti.ses = bnti.ses/max(bnti.ses);
range(bnti.ses);
identical(rownames(bnti.ses),colnames(bnti.ses)); # must be TRUE to proceed
identical(rownames(bnti.ses),rownames(meta.pca.scores)); # must be TRUE to
proceed
# Here is where the error occurs
bnti.ses.dbrda.int = capscale(as.dist(bnti.ses) ~ 1,data=meta.pca.scores);
bnti.ses.dbrda.full = capscale(as.dist(bnti.ses) ~ .,data=meta.pca.scores);
bnti.ses.select.rsq = ordiR2step(bnti.ses.dbrda.int, scope =
formula(bnti.ses.dbrda.full),direction = "both",pstep=10000, perm.max =
100000); bnti.ses.select.rsq;
I get the message:
Error in formula.default(object, env = baseenv()) : invalid formula
I tried the same code using the varespec and varechem example files present
in capscale's help and it worked. I checked the dimensions of the
phylobetadiversity matrix and they are ok (245 x 245). I tried to omit the
row names but the problem persists.
For me the very last test that should have worked was
bnti.ses = data.frame(replicate(245,sample(0:100,245,rep=TRUE)))
rownames(bnti.ses)=rownames(meta.pca.scores)colnames(bnti.ses)=rownames(bnti.ses)
and then working this artificial bnti.ses through the subsequent
standardization and capscale steps. However, I got the same error mesage
with this example.
Am I missing something, or is there a workaround?
Thanks,
Alexandre
--
Dr. Alexandre F. Souza
Professor Ajunto II
Universidade Federal do Rio Grande do Norte
CB, Departamento de Ecologia
Campus Universitário - Lagoa Nova
59072-970 - Natal, RN - Brasil
lattes: lattes.cnpq.br/7844758818522706
http://www.docente.ufrn.br/alexsouza
--
Dr. Alexandre F. Souza
Professor Ajunto II
Universidade Federal do Rio Grande do Norte
CB, Departamento de Ecologia
Campus Universitário - Lagoa Nova
59072-970 - Natal, RN - Brasil
lattes: lattes.cnpq.br/7844758818522706
http://www.docente.ufrn.br/alexsouza
[[alternative HTML version deleted]]
More information about the R-sig-ecology
mailing list