Hi all,
here is the function to calculate Nei-Li (1979) distance (or dissimilarity) for a binary matrix where columns are species and rows are alleles. It is a modification of "jaccard" function in package prabclus by Christian Hennig and Bernhard Hausdorf.

########################################
neidist<-function (regmat)
{
   nart <- ncol(regmat)
   jdist <- rep(0, nart * nart)
   dim(jdist) <- c(nart, nart)
   reg.col.sum <- apply(regmat, 2, sum)
   reg.aggrement <- t(regmat) %*% regmat
nedist <- 1 - (reg.aggrement+reg.aggrement)/((reg.col.sum - t(t(reg.aggrement) -
       reg.col.sum))+reg.aggrement)
   nedist
}
###############################################


Useful in AFLP or other dominant (0-1 response) markers analysis

Fiorello Toneatto

_______________________________________________
R-sig-genetics mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-genetics

Reply via email to