nonConDist: Nearest non-conspecific and maximum intra-specific distances

Description Usage Arguments Details Value Author(s) Examples

Description

These functions give the distances to the nearest non-conspecific and furthest conspecific representatives for each individual in the dataset.

Usage

1
2
3
nonConDist(distobj, sppVector, propZero = FALSE, rmNA = FALSE)
maxInDist(distobj, sppVector, propZero = FALSE, rmNA = FALSE)
minInDist(distobj, sppVector, propZero = FALSE, rmNA = FALSE)

Arguments

distobj

Distance matrix.

sppVector

Species vector (see sppVector). Default of NULL.

propZero

Logical. TRUE gives the proportion of zero distances.

rmNA

Logical. TRUE ignores missing values in the distance matrix. Default of FALSE

Details

nonConDist returns the minimum inter-specific distance for each individual.

maxInDist returns the maximum intra-specific distance for each individual.

These two functions can be used to create a version of the barcoding gap.

minInDist returns the minimum intra-specific distance for each individual.

Value

If propZero=FALSE, a numeric vector giving the distance of the closest non-conspecific individual (nonConDist) or the most distant conspecific individual (maxInDist).

If propZero=TRUE, a single number giving the proportion of zero distances.

Author(s)

Samuel Brown <s_d_j_brown@hotmail.com>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
data(anoteropsis)
anoDist <- dist.dna(anoteropsis)
anoSpp <- sapply(strsplit(dimnames(anoteropsis)[[1]], split="_"), 
    function(x) paste(x[1], x[2], sep="_"))

nonConDist(anoDist, anoSpp)
nonConDist(anoDist, anoSpp, propZero=TRUE)

maxInDist(anoDist, anoSpp)
maxInDist(anoDist, anoSpp, propZero=TRUE)

#Barcoding gap
inter <- nonConDist(anoDist, anoSpp)
intra <- maxInDist(anoDist, anoSpp)
hist(inter-intra)

#An alternative way of plotting the gap
bnd <- cbind(data.frame(inter, intra))
ord <- bnd[order(bnd$inter),]
plot(ord$inter, type="n", ylab="Percent K2P distance", xlab="Individual")
segCol <- rep("gray50", length(ord$inter))
segCol[ord$inter-ord$intra < 0] <- "red"
segments(x0=1:length(ord$inter), y0=ord$inter, y1=ord$intra, col=segCol, lwd=6)

spider documentation built on May 2, 2019, 5:16 p.m.