Hi Pedro,
Suppose all the DNA sequences are in a single matrix, say X, and you
have a vector (or factor) identifying the species of each sequence, say
SPECIES. So:
length(SPECIES) == nrow(X)
is TRUE. What you can do is to first compute all pairwise (raw) distances:
D <- dist.dna(X, "n")
and then build a logical vector identifying which distances were
computed between two sequences from the same species. Here's how you can
do that:
SAME.SP <- as.logical(as.dist(outer(SPECIES, SPECIES, "==")))
Now you can select the within-group distances with:
D[SAME.SP]
and the between-group distances:
D[!SAME.SP]
I don't know if this is what MEGA does, but with this procedure, you can
do what you want with the two subsets of distances: histograms, get the
means, summaries, etc. And if you want only the distances within a
specific species:
dist.dna(X[SPECIES == "Homo sapiens", ], "n")
HTH
Best,
Emmanuel
Le 18/02/2016 22:19, Pedro Paulo Goulart Taucce a écrit :
Hello, everyone!
Is there a way to estimate pairwise distances between and within groups of
sequences (in my case, each group is a species with lots of individuals)? I
used to do it with MEGA, but now I use Linux only and MEGA isn't getting
along with it.
The closest way I figured out is the function dist.dna from the ape
package. But I think it does not estimate distances between groups.
Thank you very much,
MSc Pedro P. G. Taucce
Universidade Estadual Paulista "Júlio de Mesquita Filho" - UNESP
Instituto de Biociências
Departamento de Zoologia, Jacarezário
Av. 24 A, 1515, Bairro Bela Vista
Rio Claro, SP, Brasil
CEP 13506-900
[[alternative HTML version deleted]]
_______________________________________________
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/