library(rgeogendiv)
BOLD (Barcode Of Life Database) is a database of Barcode DNA sequences of georeferenced specimen that closely approximate species.
We use the package bold
to download a set of georeferenced sequences for the Pomacanthidae taxon order request.
library(bold) taxonRequest <- "Pomacanthidae" resBold <- bold::bold_seqspec(taxon=taxonRequest, sepfasta=TRUE)
We filter and mutate georeferenced sequence dataset from boldsystems.org in order to produce a curated dataframe with rows as individual specimen and columns as specimen information. We add a new column sequence
with DNA sequences as string.
The function prepare_bold_res apply 5 filters :
marker_code
species_name
informationlat
or lon
coordinates information## filter and mutate preResBold <- prepare_bold_res(resBold, marker_code="COI-5P", species_names=TRUE, coordinates=TRUE, ambiguities=TRUE, min_length=420, max_length=720 )
The grid is composed of nested squares of siteSize
meters that we call site. By default, the grid is built on a worldmap in Behrmann projection. In this example we set a grid with sites with a diameter of 260 kilometers.
grid.sp <- grid_spatialpolygons(siteSize=260000)
specimenIntersectSites <- specimen_intersect_site(specimen.df=preResBold, grid.sp=grid.sp)
We gather together specimen from the same species located within the same site of the grid. Then sequences are aligned and nucleotide diversity is calculated for each species within each site.
nucdivSpecies <- nucleotide_diversity_species(specimen.df=preResBold, sequenceIntersectSites=specimenIntersectSites, MinimumNumberOfSequencesBySpecies=3 )
Once we got species nucleotide diversity, we calculate mean species nucleotide diversity by site of the worldmap grid.
nucdivSites <- nucleotide_diversity_sites(nucdivSpecies)
We assign a mean species nucleotide diversity value to each site in the worldmap grid.
nucdivGrid <- nucleotide_diversity_grid(nucdivSites, grid.sp)
Then, we can print the wordldmap grid of nucleotide diversity.
gg <- plot_grid(nucdivGrid) gg
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.