Hi Vojtěch,

The trouble comes from boot.phylo() which resamples the columns of the data matrix with replacement: this may result in a bootstrap sample without population column and loci2genind() doesn't like it. The trick is to delete this column from the original "loci" object, and then reassign it within the estimation process so that loci2genind() works.

pop <- LOCI$population
LOCI$population <- NULL

foo <- function(X) {
    X$population <- pop
    nj(dist(loci2genind(X)))
}

Then the following should work:

NJ <- foo(LOCI)
BOOT <- boot.phylo(phy=NJ, x=LOCI, FUN=foo, B=1000)

BTW, I don't know if using dist() on a "genind" object is something really meaningful. Maybe you want to use another distance function from adegenet or another packae (eg, poppr). Anyway, the above trick will be useful in all cases since nj() only needs a distance matrix.

Best,

Emmanuel

Le 21/01/2016 14:30, Vojtěch Zeisek a écrit :
Hello,
I have probably very simple problem, but I can't find the solution... :-( I
wish to make bootstraped tree of attached microsatellite diploid data. It
works fine with DNA sequences and I was using same code last year and it was
working. :-)

library(pegas)
library(ape)
LOCI <- read.loci("ssrs.txt", header=TRUE, loci.sep="\t", allele.sep="/",
col.pop=2, col.loci=3:14, row.names=1)
# Looks OK
GENIND <- loci2genind(LOCI)
DIST <- dist(x=GENIND, method="euclidean", diag=TRUE, upper=TRUE)
NJ <- nj(DIST)
BOOT <- boot.phylo(phy=NJ, x=LOCI, FUN=function(X) nj(dist(loci2genind(X))),
B=1000)
   |=
|   1%Error in df2genind(as.matrix(x[, attr(x, "locicol")]), sep = "[/\\|]",
:
   length of factor pop differs from nrow(X)

Any idea what could went wrong?
Thank You,
Vojtěch



_______________________________________________
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


_______________________________________________
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/

Reply via email to