apex (version 1.0.2)

dist.multidna: Pairwise distances for multiple gene data

Description

This function computes pairwise genetic distances between individuals using genes in a multidna object. By default, one distance matrix (dist object) is created for each each, but a single distance can be derived by pooling all genes (argument pool=TRUE)

Usage

dist.multidna(x, pool = FALSE, genes = TRUE, ...)

Arguments

x
a multidna object.
pool
a logical indicating if all genes should be pooled (concatenated) to obtain a single distance matrix; defaults to FALSE.
genes
an optional vector indicating the genes to retain for the concatenation; any way to subset the list in x@dna is acceptable; by default, all genes are used.
...
further arguments passed to dist.dna.

Value

a list of dist objects (pool=FALSE) or a single dist object (pool=TRUE)

See Also

dist.dna

Examples

Run this code

## simple conversion with nicely ordered output
data(woodmouse)
genes <- list(gene1=woodmouse[,1:500], gene2=woodmouse[,501:965])
x <- new("multidna", genes)
x
plot(x)

## get separate distance matrix and pooled one
lD <- dist.multidna(x)
D <- dist.multidna(x, pool=TRUE)

## get corresponding NJ trees
ltrees <- lapply(lD, nj)
tree <- nj(D)

par(mfrow=c(3,1))
for(i in 1:2) plot(ltrees[[i]], main=names(ltrees)[i])
plot(tree, main="Pooled distances")

Run the code above in your browser using DataCamp Workspace