Learn R Programming

spider

Overview

The official GitHub repository for the R package "SPecies IDentity and Evolution in R" (spider).

spider provides functions for the analysis of species limits and DNA barcoding data. Included are functions for generating important summary statistics from DNA barcode data, assessing specimen identification efficacy, testing and optimizing divergence threshold limits, assessment of diagnostic nucleotides, and calculation of the probability of reciprocal monophyly. Additionally, a sliding window function offers opportunities to analyse information across a gene, often used for marker design in degraded DNA studies. Further information on the package has been published in Brown et al. (2012).

For an introduction to the package, visit our spider tutorial and manual. Over time, the tutorial will be expanded and moved into GitHub vignettes and project pages.

If you are interested in previous versions (before v1.5.0) of the spider source code, check out our old repository hosted at r-forge.

Installation

Stable CRAN version:

install.packages("spider")

Or development version from GitHub:

devtools::install_github("boopsboops/spider")

Examples

Here, we will do a quick "best close match" analysis (Meier et al., 2006) on a Anoteropsis wolf spider dataset (Vink & Paterson, 2003) to see how well DNA barcodes can identify individuals in a simulated identification scenario.

# load up the data
library("spider")
data(anoteropsis)
# make a quick species vector (unique species name for each individual) from the taxon labels
anoSpp <- sapply(strsplit(rownames(anoteropsis), split="_"), function(x) paste(x[1], x[2]))
head(anoSpp, n=4)
#> [1] "Artoria flavimanus" "Artoria separata" "Anoteropsis adumbrata" "Anoteropsis adumbrata"
# get some statistics about the sequence lengths
seqStat(anoteropsis)
#> Min    Max   Mean Median Thresh 
#> 395    409    408    409     33
# make a distance matrix from raw p-distances
anoDist <- ape::dist.dna(anoteropsis, model="raw", pairwise.deletion=TRUE)
# calculate identification success based on a 1% interspecific threshold
table(bestCloseMatch(distobj=anoDist, sppVector=anoSpp, threshold=0.01))
#> correct incorrect     no id 
#>      11         2        20 

Current contributors

Meta

Copy Link

Version

Install

install.packages('spider')

Monthly Downloads

435

Version

1.5.1

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Rupert Collins

Last Published

May 9th, 2025

Functions in spider (1.5.1)

maxInDist

Nearest non-conspecific and maximum intra-specific distances
monophyly

Species monophyly over a tree
nucDiag

Nucleotide diagnostics for species alignments
minInDist

Nearest non-conspecific and maximum intra-specific distances
paa

Population Aggregate Analysis
nearNeighbour

Measures of identification accuracy
read.BOLD

Downloads DNA sequences from the Barcode of Life Database (BOLD)
polyBalance

Balance of a phylogenetic tree with polytomies
plot.haploAccum

Plotting haplotype accumulation curves
rankSlidWin

Rank a 'slidWin' object.
rmSingletons

Detect and remove singletons
rnucDiag

Nucleotide diagnostics for species alignments
monophylyBoot

Species monophyly over a tree
search.BOLD

Downloads DNA sequences from the Barcode of Life Database (BOLD)
slideBoxplots

Boxplots across windows
sarkar

Dummy sequences illustrating the categories of diagnostic nucleotides
plot.ordinDNA

Plot an 'ordinDNA' object
plot.slidWin

Plot a 'slidWin' object
slideAnalyses

Sliding window analyses
tajima.K

Calculate Tajima's K index of divergence
sppDistMatrix

Mean intra- and inter-specific distance matrix
tclust

Clustering by a threshold
threshID

Measures of identification accuracy
sppVector

Species Vectors
stats.BOLD

Downloads DNA sequences from the Barcode of Life Database (BOLD)
slideNucDiag

Sliding nucleotide diagnostics
slidingWindow

Create windows along an alignment
rosenberg

Rosenberg's probability of reciprocal monophyly
read.GB

Download sequences from GenBank with metadata.
tree.comp

Tree comparisons
titv

Number of pairwise transitions and transversions in an alignment.
spider-package

Species Identity and Evolution in R
salticidae

Cytochrome oxidase I (COI) sequences of world-wide species of Salticidae
seeBarcode

Create illustrative barcodes
sppDist

Intra and inter-specific distances
seqStat

Sequence statistics
threshOpt

Threshold optimisation
tiporder

Orders tip labels by their position on the tree.
woodmouse

Cytochrome b Gene Sequences of Woodmice
anoteropsis

Cytochrome oxidase I (COI) sequences of New Zealand _Anoteropsis_ species
checkDNA

Check a DNA alignment for missing data
chaoHaplo

Chao estimator of haplotype number
heatmapSpp

Visualise a distance matrix using a heatmap
cgraph

Complete graph
blockAlignment

Make all sequences the same length
dolomedes

Cytochrome oxidase I (COI) sequences of New Zealand _Dolomedes_ species
bestCloseMatch

Measures of identification accuracy
haploAccum

Haplotype accumulation curves
dataStat

Taxa statistics
ordinDNA

Calculates a Principal Components Ordination of genetic distances
is.ambig

Missing bases in alignments
localMinima

Determine thresholds from a density plot
nonConDist

Nearest non-conspecific and maximum intra-specific distances