Navigating MOSAIC
Vignette #1 - Navigating MOSAIC
Welcome to the MOSAIC database, a database of functional traits for comparative demography. The database, user, guide, and additional information can be found and http://mosaicdatabase.web.ox.ac.uk.
MOSAIC is a database that aggregates existing databases and adds new records for functional traits that currently do not have a database established. In this vignette, we will show you how to download the dataset, search records, and relate MOSAIC records with COMADRE, COMPADRE, and PADRINO databases.
Optional clearance of working space.
rm(list = ls()) # Clear your environment
if(!is.null(dev.list())) dev.off() # Clear plots/graphics
cat("\014") # Clear console
Downloading MOSAIC
MOSAIC can be downloaded as an S4 object by running the below code in R. S4 data objects in R are an object oriented system in the R language that allow control of constituent data fields Similar to S3 objects (which use the “$” operator). S4 are comprised of objects that can be searched with the “@” operator or slots, discussed in more detail below.
remotes::install_github("mosaicdatabase/Rmosaic") library(Rmosaic)
mosaic <- mos_fetch("v1.0.0")
Basics of manually navigating MOSAIC
Mosaic traits can be searched using the “@” operator. Attribute names searched this way are analogous to the columns of a dataframe in a relational database structure.
Once downloaded, you should be able to type statements mosaicdatabase@[insertfield] (where [insertfield] is a particular trait). If you are working in Rstudio, after the “@” a drop-down of the slots (traits) should autopopulate.
# Three examples of querying traits (easiest for navigation)
mosaic@biomass
mosaic@height
mosaic@volancy
The species corresponding with each index can be queried by prompting:
# Three examples of querying traits (easiest for navigation)
mosaic@species
Data in mosaic can also be access using slots. Slots are the recommended mode of searching the database - though it has the disadvantage of not enabling the autopopulation of the attributes contained in the database (traits must be spelled out manually).
# You can also search these by slot (recommended)
slot(mosaic, "biomass")
slot(mosaic, "height")
slot(mosaic, "volancy")
Within each trait object, there are eight fields in mosaic. The first of field is called “values” and contains the data. Values are unitless values (either numeric or factorial) that are reported in units described in the Mosaic User Guide http://mosaicdatabase.web.ox.ac.uk/user-guide. The metadata is organised into additional attributes, reflecting the individual elements of the metadata for a given record, including the authors, journal, year of publication, databases from which data are sourced (if applicable)
mosaic@metaTaxa maps the complete taxanomic classification structure of a species - from Kingdom to species for taxonomic clustering.
The other six attributes - “author”, “year”, “journal,”doi“,”database“, and”mosaic" - are metadata corresponding with each value record. For instance:
mosaic@species[[2]] # For this species, let us look at volancy (flight capacity) value
mosaic@volancy@value[[2]] # or, equivalently:
slot(slot(mosaic, "volancy"), "value")[[2]]
Corresponds with the following metadata
mosaic@volancy@author[[2]] # for "Acinonyx jubatus"
slot(slot(mosaic, "volancy"), "author")[[2]] # Author of the source publication
slot(slot(mosaic, "volancy"), "year")[[2]] # And year of the source publication
slot(slot(mosaic, "volancy"), "journal")[[2]] # The journal of the source publication
#etc.
Using MOSAIC functions to quickly access files
A series of convenience functions can be sourced from the MOSAIC GitHub page to facilitate navigating and working with the mosaic database that can be accessed by running the follwing script.
source_url("https://raw.githubusercontent.com/mosaicdatabase/mosaicdatabase/main/navMosaic_46.R")
Below we highlight some of the basic queries for which the mosaic functions can assist.
Is a species included in Mosaic?
spp_check("Fritillaria biflora")
## [1] TRUE
spp_check("Pagophilus groenlandicus")
## [1] FALSE
Can I see all records for a given trait?
traitAllSpp("biomass") # Only the first five records are shown for space
## [1] "NDY" "50578" "ND" "52500" "351000" "62000"
Can I see an overview of all records for a given species?
singSppTraitSummary("Aepyceros melampus")
## biomass height growthdet regen dimorph matsyst hermaph seqherm
## 1 52500 NDY Determinate NDY Dimorphic Non-monogamous Gonochorous NDY
## dispcap disptype modedisp dispclass volancy
## 1 Natal Dispersal Active Motile Adult Non-volant
## aquadep
## 1 Terrestrial, Water Habitat Independent
Can I see all records for more than one species?
sppAllTrait(c("Acinonyx jubatus", # you can also pass lists or dataframes to this command
"Acropora downingi",
"Aepyceros melampus",
"Alces alces",
"Alligator mississippiensis"))
## sppnames biomass height growthdet regen dimorph
## 1 Acinonyx jubatus 50578 NDY Determinate NDY Dimorphic
## 2 Acropora downingi ND NDY NDY Regenerative NDY
## 3 Aepyceros melampus 52500 NDY Determinate NDY Dimorphic
## 4 Alces alces 351000 NDY Determinate NDY Dimorphic
## 5 Alligator mississippiensis 62000 NDY Determinate Regenerative NDY
## matsyst hermaph seqherm dispcap disptype modedisp
## 1 Non-monogamous Gonochorous NDY Natal Dispersal Active Motile
## 2 NDY Hermaphroditic NDY Natal Dispersal Passive Water currents
## 3 Non-monogamous Gonochorous NDY Natal Dispersal Active Motile
## 4 Non-monogamous Gonochorous NDY Natal Dispersal Active Motile
## 5 Non-monogamous Gonochorous NDY Natal Dispersal Active Motile
## dispclass volancy aquadep
## 1 Juvenile Non-volant Terrestrial, Water Habitat Independent
## 2 Juvenile Non-volant Marine
## 3 Adult Non-volant Terrestrial, Water Habitat Independent
## 4 Juvenile Non-volant Terrestrial, Facultative Freshwater Dependent
## 5 Adult and Juvenile Non-volant Terrestrial, Obligative Freshwater Dependent
Can I get a breakdown of counts/frequency of trait values?
traitFrequency("volancy")
## counts freq
## NDY 1329 NA
## Non-volant 82 0.882
## Semi-volant 1 0.011
## Volant 10 0.108
traitFrequency("growthdet")
## counts freq
## Determinate 31 0.596
## Indeterminate 21 0.404
## NDY 1370 NA
traitFrequency("hermaph")
## counts freq
## Dioecious 24 0.108
## Gonochorous 106 0.475
## Hermaphroditic 72 0.323
## Hermaphroditic & Gonochorous 1 0.004
## Monoecious 20 0.090
## NDY 1199 NA
Can I get all metadata for one or more traits?
metadata("volancy", 14)
## author year journal database mosaic
## 1 Campos, Z. et al. 2006 The Herpetological Journal NDY NDY
multiMetaRecords("volancy", c(14:20))
## author year
## 1 Ekerna, L. S. & Cords, M. 2007
## 2 Zimmerman, S. J. et al. 2019
## 3 Jack, K. M., Sheller, C. & Fedigan, L. M. 2012
## 4 DFO 2013
## 5 Torres, R. T. et al. 2017
## 6 NDY NDY
## 7 Campos, Z. et al. 2006
## journal
## 1 Animal Behaviour
## 2 The Condor
## 3 American Journal of Primatology
## 4 Canadian Science Advisory Secretariat Central and Arctic Region Science Advisory Report
## 5 Oryx
## 6 NDY
## 7 The Herpetological Journal
## database mosaic
## 1 NDY NDY
## 2 NDY NDY
## 3 NDY NDY
## 4 NDY NDY
## 5 NDY NDY
## 6 NDY NDY
## 7 NDY NDY