This is a quick guide to getting started with the two main functions.
You can install the stable released version of
{NicheBarcoding}
from GitHub with:
# install.packages("devtools")
::install_github("Yangcq-Ivy/NicheBarcoding") devtools
or directly install from CRAN with:
install.packages("NicheBarcoding")
This package provides three primary actions:
NBSI
and NBSI2
functions execute the main
identification integrating both DNA barcoding and ecological niche
modeling.extractSpeInfo
, niche.Model.Build
,
pseudo.present.points
and pseudo.absent.points
functions are the extractable intermediate steps of NBSI
and NBSI2
that execute information extraction, niche
modeling and pseudo points generation.monophyly.prop
, spe.mantel.test
and
niche.PCA
functions execute the analysis of the
characteristics of reference or/and query datasets, including the
phylogenetic monophyletic proportion, the correlation between
interspecific pairwise genetic distance and ecological distance, and the
principal component analysis of ecological niche between datasets.rm(list=ls())
library(NicheBarcoding)
Load the example bioclimatic layers first.
data(en.vir)
data(bak.vir)
or if you want to download the complete bioclimatic layers from
online worldclim
,
run:
<-raster::getData("worldclim",download=FALSE,var="bio",res=2.5)
envir<-raster::brick(envir)
en.vir
# Generate random background points
<-dismo::randomPoints(mask=en.vir,n=5000,ext=NULL,extf=1.1,
backexcludep=TRUE,prob=FALSE,
cellnumbers=FALSE,tryf=3,warn=2,
lonlatCorrection=TRUE)
<-raster::extract(en.vir,back) bak.vir
Here, users can start running the main functions from three different scenarios below.
This is the typical situation for most users, where the users have DNA barcodes of species under study for both reference and query samples, with coordinates of species / samples recorded from their own collections.
#################################################################
### Scenario 0
### NBSI DNA barcodes + coordinates of species distribution
### available (using online climate data)
#################################################################
library(ape)
data(LappetMoths)
<-LappetMoths$ref.seq
ref.seq<-LappetMoths$que.seq
que.seq
<-NBSI(ref.seq,que.seq,ref.add=NULL,
NBSI.outindependence=TRUE,
model="RF",variables="ALL",
en.vir=en.vir,bak.vir=bak.vir)
NBSI.out
In addition, the coordinates collected from GBIF
or published
literature can also be included through the ref.add
parameter.
When you have an additional reference coordinates information, run:
<-LappetMoths$ref.add
ref.add
<-NBSI(ref.seq,que.seq,ref.add=ref.add,
NBSI.out2independence=TRUE,
model="RF",variables="SELECT",
en.vir=en.vir,bak.vir=bak.vir)
NBSI.out2
In this case, users may already have species identified by another barcoding method.
They attempt to further confirm their identifications with niche models built by environmental data.
The function NBSI2
is especially designed for this
purpose.
#################################################################
### Scenario 1
### NBSI2 species identified by other methods or barcodes +
### coordinates of species distribution available
### (for using online climatic data)
#################################################################
data(LappetMoths)
<-LappetMoths$barcode.identi.result
barcode.identi.result<-LappetMoths$ref.infor
ref.infor<-LappetMoths$que.infor
que.infor
<-NBSI2(ref.infor=ref.infor,que.infor=que.infor,
NBSI2.outbarcode.identi.result=barcode.identi.result,
model="RF",variables="SELECT",
en.vir=en.vir,bak.vir=bak.vir)
NBSI2.out
Sometimes users may have species identified by other methods or barcodes alone, or their own environmental data collected by themselves (or alternative online sources).
Obviously, users no longer need to provide species distribution data (coordinates), or use the online environmental data in this case.
They should prepare two environmental datasets for both reference and query samples.
#################################################################
### Scenario 2
### NBSI2 species identified by other methods or barcodes +
### users possessing their own environmental data
#################################################################
data(LappetMoths)
<-LappetMoths$barcode.identi.result
barcode.identi.result<-LappetMoths$ref.env
ref.env<-LappetMoths$que.env
que.env
<-NBSI2(ref.env=ref.env,que.env=que.env,
NBSI2.out2barcode.identi.result=barcode.identi.result,
model="RF",variables="ALL",
en.vir=en.vir,bak.vir=bak.vir)
NBSI2.out2
Complete examples can also be found in the help documentation of each functions.
Users can also read the manual to learn more.
To cite {NicheBarcoding}
, use:
Yang, C. Q., X. H. Li, M. C. Orr, A. B. Zhang (2021). NicheBarcoding: An R package for species identification using DNA barcodes integrated with Environmental Niche Models. R package version 1.0. https://github.com/Yangcq-Ivy/NicheBarcoding
We thank reviewer ldecicco-USGS for comments on an early version of the package.
This work was was supported by China National Funds for Distinguished Young Scientists (to Zhang, Grant No. 31425023), by Natural Science Foundation of China (to Zhang, Grant No. 31071963 and 31272340), Program for Changjiang Scholars and Innovative Research Team in University (IRT13081), and Science and Technology Foundation Project (2012FY110803).