Skip to main content

31  AusTraits tutorial

31.1 Introduction

With more than 1.8 million data records, AusTraits is Australia’s largest plant trait database, created using the {traits.build} R package

This tutorial introduces:

Note

This chapter is the extended, worked walkthrough of exploring and wrangling data, using AusTraits as the example database. The austraits package chapter is a more concise tour of the same functions — extract_, join_, summarise_, plotting, and pivoting — and applies to any traits.build database, not only AusTraits. Read that chapter for a quick reference; read this one for step-by-step examples.

To access more information about traits.build, see traits.build-book

Or you can visit the Github repositories for individual packages/data repos:

31.2 Download AusTraits data

Before you begin, download and source essential packages and functions.

# Packages need to be installed the first time you use them.
# They are commented out here, so they aren't reinstalled each time you run the code, 
# but install any packages you require the first time you run this tutorial.

#install.packages("readr", "tidyr", "dplyr", "stringr", "remotes")
library(readr)
library(tidyr)
library(dplyr)
library(stringr)

#remotes::install_github("traitecoevo/austraits", dependencies = TRUE, upgrade = "ask")
#remotes::install_github("traitecoevo/traits.build", dependencies = TRUE, upgrade = "ask")

library(austraits)    # functions for exploring a traits.build database, available at Github repo
# XX library(traits.build) # additional functions for exploring a traits.build database, available at Github repo

#source("https://raw.githubusercontent.com/traitecoevo/traits.build-book/master/data/extra_functions.R")
source("data/extra_functions.R")

Then download (or build) the latest AusTraits database, using one of the methods described here.

This tutorial uses the most recent AusTraits release, version 8.0.0

most_recent <- austraits::get_versions() %>%
  dplyr::pull("doi") %>%
  dplyr::first()

most_recent
[1] "10.5281/zenodo.24543275"
austraits <- austraits::load_austraits(doi = most_recent)
doi '10.5281/zenodo.24543275' is version 8.0.0
Downloading your traits.build database to 'data/austraits'
Loading data from 'data/austraits/austraits-8.0.0.rds'

31.3 A first look at data

If you’re not familiar with AusTraits, you may want to begin by exploring the breadth and depth of data within the database. The database can be explored by trait name, species, or genus using either austraits functions or dplyr functions.

How many taxa have leaf_N_per_dry_mass data in AusTraits?

(austraits %>% 
  austraits::extract_trait(trait_name = "leaf_N_per_dry_mass"))$traits %>%
  dplyr::distinct(taxon_name) %>% nrow()
[1] 2392

How are these data distributed across datasets?

austraits::plot_trait_distribution_jitter(database = austraits, trait_name = "leaf_N_per_dry_mass", y_axis_category = "dataset_id")

How much data exist for other nitrogen traits?

austraits::lookup_trait(austraits, "_N_") -> N_traits

austraits %>% 
  austraits::extract_trait(trait_name = N_traits) %>% 
  austraits::summarise_database(var = "trait_name") %>%
  dplyr::arrange(-n_taxa)
# A tibble: 17 × 5
   trait_name                           n_records n_dataset n_taxa percent_total
   <chr>                                    <int>     <int>  <int>         <dbl>
 1 leaf_N_per_dry_mass                      12937       100   2392      0.666   
 2 leaf_N_per_area                           4195        34    992      0.216   
 3 leaf_senesced_N_per_dry_mass               544        10     82      0.028   
 4 wood_N_per_dry_mass                        554         9     70      0.0285  
 5 bark_N_per_dry_mass                        416         6     50      0.0214  
 6 seed_N_per_seed_dry_mass                    47         6     42      0.00242 
 7 leaf_rubisco_N_per_total_leaf_N             68         1     29      0.0035  
 8 leaf_thylakoid_N_per_total_leaf_N           70         1     29      0.0036  
 9 stem_N_per_dry_mass                        157         3     28      0.00808 
10 root_N_per_dry_mass                        238         4     25      0.0123  
11 fruit_N_per_dry_mass                        31         5     22      0.0016  
12 leaf_cell_wall_N_per_cell_wall_dry_…        29         1     22      0.00149 
13 leaf_cell_wall_N_per_leaf_N                 29         1     22      0.00149 
14 leaf_N_resorption                           86         1     14      0.00443 
15 wood_dead_N_per_dry_mass                     9         3      7      0.000463
16 bark_dead_N_per_dry_mass                     2         1      2      0.000103
17 flower_N_per_dry_mass                       10         2      2      0.000515

How many “hydraulic” traits are in AusTraits? How much data exist for these traits?

austraits::lookup_trait(austraits, "hydraulic") -> hydraulic_traits

austraits %>% 
  austraits::extract_trait(trait_name = hydraulic_traits) %>%
  austraits::summarise_database(var = "trait_name") %>%
  dplyr::arrange(-n_taxa)
# A tibble: 8 × 5
  trait_name                            n_records n_dataset n_taxa percent_total
  <chr>                                     <int>     <int>  <int>         <dbl>
1 stem_vessel_diameter_hydraulic              750        11    272        0.283 
2 sapwood_specific_hydraulic_conductiv…       567        12    200        0.214 
3 leaf_specific_hydraulic_conductivity        479        11    171        0.181 
4 sapwood_specific_hydraulic_conductiv…       294         5    120        0.111 
5 stem_hydraulic_conductivity                 264         6     53        0.0998
6 hydraulic_safety_margin_50                   56         3     41        0.0212
7 hydraulic_safety_margin_88                   48         3     34        0.0181
8 stem_specific_hydraulic_conductivity        188         5     17        0.0711

Where have trait data for Acacia aneura been collected?

data <-
  austraits %>%
     austraits::extract_taxa(taxon_name = "Acacia aneura") %>%
     austraits::join_location_coordinates()

data$traits %>% austraits::plot_locations("taxon_name")

Where have data for Hibbertia species been collected?

data <-
  austraits %>%
     austraits::extract_taxa(genus = "Hibbertia") %>%
     austraits::join_location_coordinates() %>%
     austraits::join_taxa(var = "genus")

data$traits %>% austraits::plot_locations("genus")

31.4 The database structure

The {traits.build} R package is the workflow that builds AusTraits from its component datasets.

The database is output as a list, a collection of relational tables, described in detail here.

A traits.build data object includes both the relational data tables and additional tables documenting database metadata and a traits dictionary.

austraits
── This is 8.0.0 of AusTraits: a curated plant trait database for the Australian
ℹ This database is built using traits.build version 3.0.0
ℹ Its tables follow traits.build data model 1.4.0
ℹ This database contains a total of 2450777 records, for 38472 taxa and 631
  traits.
── This object is a 'list' with the following components: ──
• traits: A table containing measurements of traits.
• locations: A table containing observations of location/site characteristics
associated with information in `traits`. Cross referencing between the two
dataframes is possible using combinations of the variables `dataset_id`,
`location_name`.
• contexts: A table containing observations of contextual characteristics
associated with information in `traits`. Cross referencing between the two
dataframes is possible using combinations of the variables `dataset_id`,
`link_id`, and `link_vals`.
• methods: A table containing details on methods with which data were
collected, including time frame and source. Cross referencing with the `traits`
table is possible using combinations of the variables `dataset_id`,
`trait_name`.
• excluded_data: A table of data that did not pass quality test and so were
excluded from the master dataset.
• taxonomic_updates: A table of all taxonomic changes implemented in the
construction of AusTraits. Changes are determined by comparing against the APC
(Australian Plant Census) and APNI (Australian Plant Names Index).
• taxa: A table containing details on taxa associated with information in
`traits`. This information has been sourced from the APC (Australian Plant
Census) and APNI (Australian Plant Names Index) and is released under a CC-BY3
license.
• contributors: A table of people contributing to each study.
• identifiers: A table of identifiers that cross-references observations
between datasets or with other data resources such as museum or herbarium
specimens.
• sources: Bibtex entries for all primary and secondary sources in the
compilation.
• definitions: A copy of the definitions for all tables and terms. Information
included here was used to process data and generate any documentation for the
study.
• schema: A copy of the schema for all tables and terms. Information included
here was used to process data and generate any documentation for the study.
• metadata: Metadata associated with the dataset, including title, creators,
license, subject, funding sources.
• build_info: A description of the computing environment used to create this
version of the dataset, including version number, git commit and R
session_info.
ℹ To access a component, try using the $ e.g. database$traits

Traits table

The core AusTraits table is the traits table. It is in “long” format, with each row documenting a single trait measurement.

austraits$traits %>% dplyr::slice(1:20)
# A tibble: 20 × 26
   dataset_id source_id taxon_name         observation_id trait_name value unit 
   <chr>      <chr>     <chr>              <chr>          <chr>      <chr> <chr>
 1 ABRS_1981  ABRS_1981 Acanthocarpus can… 0001           leaf_comp… simp… <NA> 
 2 ABRS_1981  ABRS_1981 Acanthocarpus can… 0001           seed_leng… 3     mm   
 3 ABRS_1981  ABRS_1981 Acanthocarpus hum… 0002           leaf_comp… simp… <NA> 
 4 ABRS_1981  ABRS_1981 Acanthocarpus par… 0003           leaf_comp… simp… <NA> 
 5 ABRS_1981  ABRS_1981 Acanthocarpus pre… 0004           leaf_comp… simp… <NA> 
 6 ABRS_1981  ABRS_1981 Acanthocarpus pre… 0004           seed_leng… 4     mm   
 7 ABRS_1981  ABRS_1981 Acanthocarpus pre… 0004           seed_leng… 5     mm   
 8 ABRS_1981  ABRS_1981 Acanthocarpus rob… 0005           leaf_comp… simp… <NA> 
 9 ABRS_1981  ABRS_1981 Acanthocarpus rup… 0006           leaf_comp… simp… <NA> 
10 ABRS_1981  ABRS_1981 Acanthocarpus rup… 0006           seed_leng… 2.5   mm   
11 ABRS_1981  ABRS_1981 Acanthocarpus ver… 0007           leaf_comp… simp… <NA> 
12 ABRS_1981  ABRS_1981 Acer pseudoplatan… 0008           leaf_phen… deci… <NA> 
13 ABRS_1981  ABRS_1981 Acidonia microcar… 0009           leaf_comp… comp… <NA> 
14 ABRS_1981  ABRS_1981 Callitris acumina… 0010           leaf_comp… simp… <NA> 
15 ABRS_1981  ABRS_1981 Callitris arenaria 0011           leaf_comp… simp… <NA> 
16 ABRS_1981  ABRS_1981 Callitris pyramid… 0012           leaf_comp… simp… <NA> 
17 ABRS_1981  ABRS_1981 Adenanthos acanth… 0013           leaf_comp… simp… <NA> 
18 ABRS_1981  ABRS_1981 Adenanthos apicul… 0014           leaf_comp… simp… <NA> 
19 ABRS_1981  ABRS_1981 Adenanthos apicul… 0014           leaf_leng… 5     mm   
20 ABRS_1981  ABRS_1981 Adenanthos apicul… 0014           leaf_leng… 20    mm   
# ℹ 19 more variables: entity_type <chr>, value_type <chr>,
#   basis_of_value <chr>, replicates <chr>, basis_of_record <chr>,
#   life_stage <chr>, population_id <chr>, individual_id <chr>,
#   repeat_measurements_id <chr>, temporal_context_id <chr>, location_id <chr>,
#   entity_context_id <chr>, plot_context_id <chr>, treatment_context_id <chr>,
#   collection_date <chr>, measurement_remarks <chr>, method_id <chr>,
#   method_context_id <chr>, original_name <chr>

The columns include:

  • core columns
    • dataset_id
    • taxon_name
    • trait_name
    • value (trait value)
  • entity metadata
    • entity_type
    • life_stage
  • value metadata
    • value_type
    • unit
    • basis_of_value
    • replicate
    • basis_of_record
  • additional metadata
    • collection_date
    • measurement_remarks
  • identifiers for specific observations, individuals, etc.
    • observation_id
    • individual_id
    • population_id
    • repeat_measurements_id
  • identifiers that provide links to ancillary tables with additional metadata
    • location_id
    • treatment_context_id
    • plot_context_id
    • entity_context_id
    • temporal_context_id
    • method_context_id
    • method_id
    • source_id

Ancillary data tables

The remaining metadata accompanying each trait record is recorded across multiple relational tables.

These include: 

  • austraits$locations 
  • austraits$contexts 
  • austraits$methods 
  • austraits$taxa 
  • austraits$taxonomic_updates 
  • austraits$contributors 

Like the core traits table, each is in ‘long’ format.

The tables locations, contexts, methods, taxa and taxonomic_updates include metadata that links seamlessly to individual rows within traits.

A collection of join_ functions within austraits join the ancillary tables to the traits table, based on columns shared across tables.

table metadata in table columns that link to austraits$traits
locations location name, location properties, latitude, longitude dataset_id, location_id
contexts context name, context category (method context, temporal, entity context, plot, treatment), context property dataset_id, link_id (identifier to link to: method_context_id, temporal_context_id, entity_context_id, plot_context_id, treatment_context_id), link_vals (identifier value to link to)
methods dataset description, dataset sampling strategy, trait collection method, data collectors, data curators, dataset citation, source_id & citation dataset_id, trait_name, method_id
taxa genus, family, scientific name, APC/APNI taxon concept/taxon name identifiers taxon_name
taxonomic_updates original name (name submitted), aligned name (typos removed; standardised syntax), identifiers for aligned name dataset_id, taxon_name, original_name
contributors people who contributed data, including their ORCIDs, affiliations, roles dataset_id

31.5 Exploring AusTraits

With 2450777 rows of trait values in the main traits table, knowing how to explore the contents is essential.

The R package {austraits} offers a collection of functions to explore and wrangle AusTraits data – or indeed any data using the traits.build format.

The austraits package chapter covers these functions as well.

Function categories include:

  • summarise and lookup functions: These functions offer summaries by taxon name or trait, summarising taxa per trait (or other variable), datasets per trait, and observations per trait.

  • filtering functions: These functions begin with the word extract and filter all of the relational tables simultaneously.

  • join functions: These functions allow columns from the relational tables to be joined to the core traits table.

  • pivot functions: These functions allow the traits table to be pivoted to wide format.

  • plotting functions: These functions offer a means of rapidly visualising AusTraits data, either plotting collection locations on a map of Australia or plotting trait values by dataset.

austraits.R function reference

Reference guide to: austraits functions

Summarising data: data coverage

There are two function families for summarising AusTraits data:

  • lookup_()
  • summarise_database()

Use the function summarise_database to output summaries of total records, datasets with records, and taxa with records across families, genera or traits:

austraits::summarise_database(database = austraits, var = "trait_name") %>% dplyr::slice(100:130)
# A tibble: 31 × 5
   trait_name                        n_records n_dataset n_taxa percent_total
   <chr>                                 <int>     <int>  <int>         <dbl>
 1 flower_filament_length                   15         1      8   0.00000612 
 2 flower_gynoecium_phyllotaxis            252         2    247   0.000103   
 3 flower_gynoecium_placentation           804         2    756   0.000328   
 4 flower_length                           654         3    254   0.000267   
 5 flower_lifespan                         194         6     44   0.0000792  
 6 flower_nectar_production                193        10    182   0.0000788  
 7 flower_nectar_sugar_concentration         4         2      4   0.00000163 
 8 flower_nectar_volume                      1         1      1   0.000000408
 9 flower_orientation                       65         1     65   0.0000265  
10 flower_ovary_fusion                     333         2    320   0.000136   
# ℹ 21 more rows
austraits::summarise_database(database = austraits, var = "family") %>% dplyr::slice(1:20)
# A tibble: 20 × 5
   family           n_records n_dataset n_taxa percent_total
   <chr>                <int>     <int>  <int>         <dbl>
 1 Acanthaceae           6598        72    157    0.0027    
 2 Achariaceae            179        16      3    0.0000733 
 3 Actinidiaceae          216        18      3    0.0000884 
 4 Adoxaceae                5         1      1    0.00000205
 5 Agapanthaceae          155        17     11    0.0000634 
 6 Aizoaceae             5862        82    110    0.0024    
 7 Akaniaceae             197        20      1    0.0000806 
 8 Alismataceae          1057        37     20    0.000433  
 9 Alliaceae              686        23     19    0.000281  
10 Alseuosmiaceae         273        16      4    0.000112  
11 Alstroemeriaceae       200        17      2    0.0000818 
12 Amaranthaceae        15430       105    277    0.00631   
13 Amaryllidaceae        1854        41     56    0.000759  
14 Anacardiaceae         3065        79     27    0.00125   
15 Anarthriaceae          792        34      9    0.000324  
16 Annonaceae            4953        59     64    0.00203   
17 Aphanopetalaceae       223        27      3    0.0000913 
18 Apiaceae             16455       121    195    0.00673   
19 Apocynaceae          20270       136    241    0.0083    
20 Apodanthaceae          114        13      4    0.0000467 
austraits::summarise_database(database = austraits, var = "genus") %>% dplyr::slice(1:20)
# A tibble: 20 × 5
   genus          n_records n_dataset n_taxa percent_total
   <chr>              <int>     <int>  <int>         <dbl>
 1 (Dockrillia            3         2      1    0.00000123
 2 Abelia                40         8      3    0.0000164 
 3 Abelmoschus          412        23      8    0.000169  
 4 Abildgaardia         312        18      6    0.000128  
 5 Abrodictyum          168        16      3    0.0000688 
 6 Abroma                71         9      2    0.0000291 
 7 Abrophyllum          283        24      3    0.000116  
 8 Abrotanella          216        22      4    0.0000884 
 9 Abrus                243        28      3    0.0000995 
10 Abutilon            3230        62     53    0.00132   
11 Acacia            149561       252   1810    0.0612    
12 Acaciella             87         6      3    0.0000356 
13 Acaena              1336        53     14    0.000547  
14 Acalypha             860        25     15    0.000352  
15 Acanthocarpus       1048        25      9    0.000429  
16 Acanthocereus         33         6      1    0.0000135 
17 Acanthocladium        55        14      1    0.0000225 
18 Acanthospermum       173        18      2    0.0000708 
19 Acanthus             326        23      4    0.000133  
20 Acca                   4         1      1    0.00000164

Since this function summarises the variable selected for ALL of AusTraits, you may want to first filter the data before summarising by “taxon_name” – or even “trait_name”.

Alternatively, you can look up traits that contain a specific search term:

austraits::lookup_trait(database = austraits, term = "leaf") %>% length()
[1] 261
austraits::lookup_trait(database = austraits, term = "leaf")[1:30]
 [1] "leaf_compoundness"                   
 [2] "leaf_phenology"                      
 [3] "leaf_length"                         
 [4] "leaf_width"                          
 [5] "leaf_margin"                         
 [6] "leaf_shape"                          
 [7] "leaf_lamina_posture"                 
 [8] "leaf_base_shape"                     
 [9] "leaf_lobation"                       
[10] "leaf_phyllotaxis"                    
[11] "leaf_glaucousness"                   
[12] "leaf_arrangement"                    
[13] "leaf_margin_posture"                 
[14] "leaf_pendulousness"                  
[15] "leaf_N_per_dry_mass"                 
[16] "leaf_area"                           
[17] "leaf_delta13C"                       
[18] "leaf_mass_per_area"                  
[19] "leaf_photochemical_reflectance_index"
[20] "leaf_water_band_index"               
[21] "leaf_dry_matter_content"             
[22] "leaf_critical_temperature_maximum"   
[23] "leaf_maximum_temperature"            
[24] "leaf_thickness"                      
[25] "leaf_water_use_efficiency_intrinsic" 
[26] "leaf_critical_temperature_minimum"   
[27] "leaf_fluorescence_fv_over_fm"        
[28] "leaf_chlorophyll_content_SPAD"       
[29] "leaf_fluorescence_quantum_yield"     
[30] "leaf_ice_nucleation_temperature"     
austraits::lookup_trait(database = austraits, term = "_N_") 
 [1] "leaf_N_per_dry_mass"                    
 [2] "leaf_N_per_area"                        
 [3] "wood_N_per_dry_mass"                    
 [4] "leaf_senesced_N_per_dry_mass"           
 [5] "bark_N_per_dry_mass"                    
 [6] "fruit_N_per_dry_mass"                   
 [7] "seed_N_per_seed_dry_mass"               
 [8] "stem_N_per_dry_mass"                    
 [9] "wood_dead_N_per_dry_mass"               
[10] "flower_N_per_dry_mass"                  
[11] "leaf_N_resorption"                      
[12] "leaf_cell_wall_N_per_cell_wall_dry_mass"
[13] "leaf_cell_wall_N_per_leaf_N"            
[14] "root_N_per_dry_mass"                    
[15] "leaf_rubisco_N_per_total_leaf_N"        
[16] "leaf_thylakoid_N_per_total_leaf_N"      
[17] "bark_dead_N_per_dry_mass"               
 # elemental contents use their symbol and are *almost* always in the middle of a trait name
austraits::lookup_trait(database = austraits, term = "photo")
 [1] "plant_photosynthetic_organ"                             
 [2] "leaf_photochemical_reflectance_index"                   
 [3] "leaf_photosynthetic_nitrogen_use_efficiency_saturated"  
 [4] "leaf_photosynthetic_phosphorus_use_efficiency_saturated"
 [5] "leaf_photosynthetic_rate_per_area_maximum"              
 [6] "leaf_photosynthetic_rate_per_area_saturated"            
 [7] "leaf_photosynthetic_rate_per_dry_mass_maximum"          
 [8] "leaf_photosynthetic_rate_per_dry_mass_saturated"        
 [9] "leaf_photosynthesis_Jmax_per_area_25C"                  
[10] "leaf_photosynthesis_Vcmax_per_area"                     
[11] "leaf_photosynthesis_Jmax_per_area"                      
[12] "leaf_photosynthetic_rate_per_area_ambient"              
[13] "photosynthetic_pathway"                                 
[14] "leaf_photosynthesis_Jmax_per_mass"                      
[15] "leaf_photosynthesis_Vcmax_per_mass"                     
[16] "leaf_photosynthetic_nitrogen_use_efficiency_maximum"    
[17] "leaf_photosynthetic_phosphorus_use_efficiency_maximum"  
[18] "leaf_photosynthesis_Jmax_over_Vcmax_25C"                
[19] "leaf_photosynthesis_Vcmax_per_area_25C"                 
[20] "bark_photosynthetic_status"                             

Also visit the AusTraits Plant Dictionary to learn more about the traits included in AusTraits, https://w3id.org/APD.

You can also search the locations and contexts tables for location_properties and/or context_properties included as metadata for many trait measurements:

austraits::lookup_location_property(database = austraits, term = "soil")
  [1] "soil type"                                        
  [2] "soil P, total (mg/kg)"                            
  [3] "soil C, total (%)"                                
  [4] "soil N, total (%)"                                
  [5] "soil delta13C (permil)"                           
  [6] "soil delta15N (permil)"                           
  [7] "soil pH (H2O)"                                    
  [8] "soil P, SE total (mg/kg)"                         
  [9] "soil clay (%)"                                    
 [10] "soil sand (%)"                                    
 [11] "soil silt (%)"                                    
 [12] "soil P, extractable (mg/kg)"                      
 [13] "soil exchangeable Al (mg/kg)"                     
 [14] "soil exchangeable Fe (mg/kg)"                     
 [15] "soil organic carbon (%)"                          
 [16] "soil pH (CaCl2)"                                  
 [17] "soil carbonates content (%)"                      
 [18] "soil cation exchange capacity (cmol/kg)"          
 [19] "soil Si, available (mg/kg dry soil)"              
 [20] "soil conductivity (dS/m)"                         
 [21] "soil K (mg/kg)"                                   
 [22] "soil P, total"                                    
 [23] "soil pH"                                          
 [24] "soil_type"                                        
 [25] "soil P, description"                              
 [26] "soil Al, total (mg/kg)"                           
 [27] "soil Ca, total (mg/kg)"                           
 [28] "soil Co, total (mg/kg)"                           
 [29] "soil Cr, total (mg/kg)"                           
 [30] "soil Fe, total (mg/kg)"                           
 [31] "soil Mg, total (mg/kg)"                           
 [32] "soil Mn, EDTA-extractable (mg/kg)"                
 [33] "soil Mn, total (mg/kg)"                           
 [34] "soil Ni, total (mg/kg)"                           
 [35] "soil N, total (ppm)"                              
 [36] "soil N, total (g/100g)"                           
 [37] "soil P, Resin (mg/kg)"                            
 [38] "soil P, inorganic (mg/kg)"                        
 [39] "soil P, organic (mg/kg)"                          
 [40] "soil conductivity (uS/cm)"                        
 [41] "soil bulk density (g/cm3)"                        
 [42] "soil cation exchange capacity (meq/kg)"           
 [43] "soil depth to gravel or laterite (m)"             
 [44] "soil pH, 1-10 cm"                                 
 [45] "soil texture"                                     
 [46] "soil water holding capacity (v/v)"                
 [47] "soil nutrient summary"                            
 [48] "soil"                                             
 [49] "soil Al (mg/kg)"                                  
 [50] "soil Ca (mg/kg)"                                  
 [51] "soil P, available (ppm)"                          
 [52] "incubated soil NH4 content (mg/kg)"               
 [53] "soil N:P"                                         
 [54] "soil NH4 content (mg/kg)"                         
 [55] "soil NO3 content"                                 
 [56] "soil TEB (cmol/kg)"                               
 [57] "soil age"                                         
 [58] "soil disolved organic nitrogen"                   
 [59] "soil exchangeable Al (cmol/kg)"                   
 [60] "soil exchangeable Ca (cmol/kg, meq/100g)"         
 [61] "soil exchangeable Ca (mg/kg)"                     
 [62] "soil exchangeable Fe (cmol/kg, meq/100g)"         
 [63] "soil exchangeable K (cmol/kg, meq/100g)"          
 [64] "soil exchangeable K (mg/kg)"                      
 [65] "soil exchangeable Mg (cmol/kg, meq/100g)"         
 [66] "soil exchangeable Mg (mg/kg)"                     
 [67] "soil exchangeable Mn (cmol/kg, meq/100g)"         
 [68] "soil exchangeable Mn (mg/kg)"                     
 [69] "soil exchangeable Na (cmol/kg, meq/100g)"         
 [70] "soil exchangeable Na (mg/kg)"                     
 [71] "soil Ca (cmol/kg)"                                
 [72] "soil Fe (mg/kg)"                                  
 [73] "soil Mg (mg/kg)"                                  
 [74] "soil Mn (mg/kg)"                                  
 [75] "soil P, Olsen (mg/kg)"                            
 [76] "soil organic content (%)"                         
 [77] "soil organic matter (%)"                          
 [78] "soil N, total (mg/g)"                             
 [79] "soil temperature (C)"                             
 [80] "soil nutrient status"                             
 [81] "soil P, total ICP"                                
 [82] "soil N, Kjeldahl (mg/kg)"                         
 [83] "soil N, oxidised (mg/kg)"                         
 [84] "soil water content (%)"                           
 [85] "soil P, Collwell"                                 
 [86] "soil exchangeable Cu (mg/kg)"                     
 [87] "soil exchangeable S (mg/kg)"                      
 [88] "soil exchangeable Zn (mg/kg)"                     
 [89] "soil series"                                      
 [90] "soil K"                                           
 [91] "soil depth class"                                 
 [92] "soil morphology"                                  
 [93] "soil P, soluble (ug/kg)"                          
 [94] "soil P, total (ug/kg)"                            
 [95] "soil profile description"                         
 [96] "soil texture (subsoil)"                           
 [97] "soil texture (surface)"                           
 [98] "soil N, total (mg/kg)"                            
 [99] "soil effective cation exchange capacity (cmol/kg)"
[100] "soil C:N"                                         
[101] "soil C:P"                                         
[102] "soil notes"                                       
austraits::lookup_location_property(database = austraits, term = "temperature")
 [1] "temperature, max (C)"                             
 [2] "temperature, MAT (C)"                             
 [3] "temperature, future summer max (C)"               
 [4] "temperature, mean annual max (C)"                 
 [5] "temperature, mean annual min (C)"                 
 [6] "temperature, monthly max (C)"                     
 [7] "temperature, monthly min (C)"                     
 [8] "temperature, mean summer max (C)"                 
 [9] "temperature, mean winter max (C)"                 
[10] "temperature, max MAT (C)"                         
[11] "temperature, min MAT (C)"                         
[12] "temperature, mean winter min (C)"                 
[13] "temperature, mean daily max annual (deg C)"       
[14] "temperature, mean daily min annual (deg C)"       
[15] "temperature variation (C)"                        
[16] "soil temperature (C)"                             
[17] "temperature, mean max (C)"                        
[18] "temperature, mean min (C)"                        
[19] "temperature, mean daily max (C)"                  
[20] "temperature, mean daily min (C)"                  
[21] "temperature, mean yearly max (C)"                 
[22] "temperature, summer mean (C)"                     
[23] "temperature, winter mean (C)"                     
[24] "temperature seasonality (SD x 100)"               
[25] "temperature, mean daily max coolest month (deg C)"
[26] "temperature, mean daily max warmest month (deg C)"
[27] "temperature, mean daily min coolest month (deg C)"
[28] "temperature, mean daily min warmest month (deg C)"
austraits::lookup_context_property(database = austraits, term = "season")
[1] "sampling season"  "flowering season" "sampling_season"  "fire season"     
austraits::lookup_context_property(database = austraits, term = "fire")
[1] "fire intensity"                           
[2] "fire history"                             
[3] "fire response type"                       
[4] "fire severity"                            
[5] "fire interval before 2019-20 fire (years)"
[6] "post_fire_recruitment notes"              
[7] "fire season"                              

For instance, to just look at number of records, datasets, and taxa with data for nitrogen-related traits:

N_traits <- austraits %>% 
  austraits::extract_trait(trait_name = "_N_") %>%
  austraits::summarise_database(var = "trait_name")

31.6 Wrangling AusTraits

Filtering data

There are four austraits functions that filter data: extract_trait, extract_taxon or extract_dataset_id, and extract_data.

Each of these functions simultaneously filters all database tables to only include trait measurements (and associated metadata) meeting the specified criteria, retaining the original database structure.

Note, although the extract_ functions were explicitly developed to return the original traits.build database structure, they will also work when the “database” is just a single table, such as if prior manipulations have separated the traits table from the rest of the database.

extract_trait, extract_dataset and extract_taxa

Three of the functions extract data based on pre-set columns: 1. extract_trait filters by trait_name 2. extract_dataset filters by dataset_id 3. extract_taxa filters by taxon_name, genus or family

Search terms can either be exact or partial matches.

leaf_mass_per_area_data <-
  austraits %>% 
     austraits::extract_trait(trait_names = c("leaf_mass_per_area"))

Westoby_2014_datasets <-
  austraits %>%
     austraits::extract_dataset("Westoby_2014")

all_Westoby_datasets <-
  austraits %>%
     austraits::extract_dataset("Westoby")

Eucalyptus_data <-
  austraits %>%
     austraits::extract_taxa(genus = "Eucalyptus")

Banksia_serrata_data <-
  austraits %>%
     austraits::extract_taxa(taxon_name = "Banksia serrata")

extract_data

extract_data offers the ability of filtering the database based on a value(s) in any column of any of the seven data tables (traits, locations, contexts, methods, taxa, taxonomic_updates, contributors).

See the database structure chapter for names and definitions of each column and, for those with controlled vocabulary, their allowed values.

Alternatively to see the list of column names to use:

names(austraits$traits)
 [1] "dataset_id"             "source_id"              "taxon_name"            
 [4] "observation_id"         "trait_name"             "value"                 
 [7] "unit"                   "entity_type"            "value_type"            
[10] "basis_of_value"         "replicates"             "basis_of_record"       
[13] "life_stage"             "population_id"          "individual_id"         
[16] "repeat_measurements_id" "temporal_context_id"    "location_id"           
[19] "entity_context_id"      "plot_context_id"        "treatment_context_id"  
[22] "collection_date"        "measurement_remarks"    "method_id"             
[25] "method_context_id"      "original_name"         
names(austraits$methods)
 [1] "dataset_id"          "trait_name"          "methods"            
 [4] "method_id"           "description"         "sampling_strategy"  
 [7] "dataset_id_type"     "dataset_id_citation" "secondary_id"       
[10] "secondary_citation"  "data_collectors"     "assistants"         
[13] "dataset_curators"   

And to see the list of possible values for a column:

unique(austraits$traits$life_stage)
 [1] "adult"                  "seedling"               "sapling"               
 [4] "adults"                 "adult, seedling"        "unknown"               
 [7] "seedling, adult"        "saplings"               "juvenile"              
[10] "seedling sapling adult" "adult juvenile"         NA                      
unique(austraits$traits$basis_of_record)
 [1] "preserved_specimen"                "field"                            
 [3] "lab"                               "captive_cultivated"               
 [5] "field_experiment"                  "field literature"                 
 [7] "field field_experiment"            "literature field"                 
 [9] "literature"                        "unknown"                          
[11] "literature field field_experiment" "field lab"                        
[13] "field captive_cultivated"          "field preserved_specimen"         
[15] NA                                 
unique(austraits$locations$location_property)[1:20]
 [1] "latitude (deg)"                     "longitude (deg)"                   
 [3] "locality"                           "recorded by"                       
 [5] "state"                              "aridity index (MAP/PET)"           
 [7] "precipitation, MAP (mm)"            "temperature, max (C)"              
 [9] "description"                        "community composition"             
[11] "topographic position"               "elevation (m)"                     
[13] "temperature, MAT (C)"               "georeference remarks"              
[15] "temperature, future summer max (C)" "temperature, mean annual max (C)"  
[17] "temperature, mean annual min (C)"   "notes"                             
[19] "soil type"                          "population"                        
unique(austraits$contexts$context_property)[1:20]
 [1] "trait scoring method"               "entity_measured"                   
 [3] "replicate observations"             "entity measured"                   
 [5] "seed purity (%)"                    "AVSB data version"                 
 [7] "storage temperature (C)"            "storage seed bank"                 
 [9] "seed collection fill rate"          "seed germination media/substrate"  
[11] "seed germination day temperature"   "seed germination night temperature"
[13] "seed germination light hours"       "seed germination dark hours"       
[15] "seed germination test length"       "flower visitor taxon name"         
[17] "DBH (cm)"                           "stand basal area (ft2/acre)"       
[19] "branch diameter (mm)"               "branch length (cm)"                

The function then allows you to filter down to the components of each table that are relevant to the search criteria specified:

field_data <- austraits %>% austraits::extract_data(table = "traits", col = "basis_of_record", col_value = "field")

field_data$traits %>% head()
# A tibble: 6 × 26
  dataset_id source_id taxon_name          observation_id trait_name value unit 
  <chr>      <chr>     <chr>               <chr>          <chr>      <chr> <chr>
1 ANBG_2026  ANBG_2026 Abelmoschus ficuln… 00001          seed_dry_… 24.3… mg   
2 ANBG_2026  ANBG_2026 Abrophyllum ornans  00011          seed_dry_… 0.058 mg   
3 ANBG_2026  ANBG_2026 Abrotanella nivige… 00021          seed_dry_… 0.612 mg   
4 ANBG_2026  ANBG_2026 Abutilon leucopeta… 00029          seed_dry_… 1.57… mg   
5 ANBG_2026  ANBG_2026 Abutilon otocarpum  00033          seed_dry_… 0.11… mg   
6 ANBG_2026  ANBG_2026 Acacia alleniana    00063          seed_dry_… 8.1   mg   
# ℹ 19 more variables: entity_type <chr>, value_type <chr>,
#   basis_of_value <chr>, replicates <chr>, basis_of_record <chr>,
#   life_stage <chr>, population_id <chr>, individual_id <chr>,
#   repeat_measurements_id <chr>, temporal_context_id <chr>, location_id <chr>,
#   entity_context_id <chr>, plot_context_id <chr>, treatment_context_id <chr>,
#   collection_date <chr>, measurement_remarks <chr>, method_id <chr>,
#   method_context_id <chr>, original_name <chr>
data_with_soils_data <- austraits %>% austraits::extract_data(table = "locations", col = "location_property", col_value = "soil")

data_with_soils_data$traits %>% head()
# A tibble: 6 × 26
  dataset_id  source_id   taxon_name       observation_id trait_name value unit 
  <chr>       <chr>       <chr>            <chr>          <chr>      <chr> <chr>
1 Apgaua_2017 Apgaua_2017 Aglaia meridion… 001            leaf_delt… -34.… {del…
2 Apgaua_2017 Apgaua_2017 Aglaia meridion… 001            leaf_wate… 0.02… umol…
3 Apgaua_2017 Apgaua_2017 Aglaia meridion… 001            sapwood_s… 14.6… kg/m…
4 Apgaua_2017 Apgaua_2017 Aglaia meridion… 001            stem_vess… 71.0… {cou…
5 Apgaua_2017 Apgaua_2017 Aglaia meridion… 001            stem_vess… 53.9… um   
6 Apgaua_2017 Apgaua_2017 Aglaia meridion… 001            stem_vess… 82.5… um   
# ℹ 19 more variables: entity_type <chr>, value_type <chr>,
#   basis_of_value <chr>, replicates <chr>, basis_of_record <chr>,
#   life_stage <chr>, population_id <chr>, individual_id <chr>,
#   repeat_measurements_id <chr>, temporal_context_id <chr>, location_id <chr>,
#   entity_context_id <chr>, plot_context_id <chr>, treatment_context_id <chr>,
#   collection_date <chr>, measurement_remarks <chr>, method_id <chr>,
#   method_context_id <chr>, original_name <chr>
data_with_soils_data$locations %>% head() # all location properties are retained for the measurements for measurements for which at least location property pertains to soil
# A tibble: 6 × 5
  dataset_id  location_id location_name                  location_property value
  <chr>       <chr>       <chr>                          <chr>             <chr>
1 Apgaua_2017 01          Daintree Rainforest Observato… description       lowl…
2 Apgaua_2017 01          Daintree Rainforest Observato… latitude (deg)    -16.…
3 Apgaua_2017 01          Daintree Rainforest Observato… longitude (deg)   145.…
4 Apgaua_2017 01          Daintree Rainforest Observato… precipitation, M… 4900 
5 Apgaua_2017 01          Daintree Rainforest Observato… soil type         high…
6 Apgaua_2017 01          Daintree Rainforest Observato… state             Qld  
data_contributed_by_Wright <- austraits %>% austraits::extract_data(table = "contributors", col = "last_name", col_value = "Wright")

data_contributed_by_Wright$traits %>% head()
# A tibble: 6 × 26
  dataset_id   source_id    taxon_name     observation_id trait_name value unit 
  <chr>        <chr>        <chr>          <chr>          <chr>      <chr> <chr>
1 Britton_2026 Britton_2026 Angophora cos… 001            huber_val… 0.00… mm2{…
2 Britton_2026 Britton_2026 Angophora cos… 001            leaf_area  876   mm2  
3 Britton_2026 Britton_2026 Angophora cos… 001            leaf_mass… 177.… g/m2 
4 Britton_2026 Britton_2026 Angophora cos… 001            leaf_thic… 0.731 mm   
5 Britton_2026 Britton_2026 Angophora cos… 001            wood_dens… 0.55… mg/m…
6 Britton_2026 Britton_2026 Angophora cos… 002            huber_val… 0.00… mm2{…
# ℹ 19 more variables: entity_type <chr>, value_type <chr>,
#   basis_of_value <chr>, replicates <chr>, basis_of_record <chr>,
#   life_stage <chr>, population_id <chr>, individual_id <chr>,
#   repeat_measurements_id <chr>, temporal_context_id <chr>, location_id <chr>,
#   entity_context_id <chr>, plot_context_id <chr>, treatment_context_id <chr>,
#   collection_date <chr>, measurement_remarks <chr>, method_id <chr>,
#   method_context_id <chr>, original_name <chr>
data_contributed_by_Wright$contributors %>% head() # all contributors are retained for datasets where at least one of the contributors on the dataset has the last name "Wright"
# A tibble: 6 × 6
  dataset_id   last_name given_name ORCID            affiliation additional_role
  <chr>        <chr>     <chr>      <chr>            <chr>       <chr>          
1 Britton_2026 Britton   Travis     0000-0003-1202-… Hawkesbury… contact        
2 Britton_2026 Halliwell Ben        0000-0003-2033-… University… <NA>           
3 Britton_2026 Blackman  Chris      0000-0002-7057-… University… <NA>           
4 Britton_2026 Hartill   Gabrielle  0000-0002-2903-… University… <NA>           
5 Britton_2026 Sumner    Emma       0000-0002-0918-… Hawkesbury… <NA>           
6 Britton_2026 Jacob     Vinod      0000-0002-6627-… Hawkesbury… <NA>           

Multiple extract_’s can be linked together to rapidly restrict data to the subset desired:

subset <- austraits %>%
  austraits::extract_data(table = "traits", col = "basis_of_record", col_value = "field") %>%
  austraits::extract_trait(trait_name = c("leaf_mass_per_area", "leaf_thickness", "leaf_length", "leaf_area")) %>%
  austraits::extract_taxa(genus = "Eucalyptus")

subset$traits[1:20]
# A tibble: 13,016 × 20
   dataset_id    source_id     taxon_name  observation_id trait_name value unit 
   <chr>         <chr>         <chr>       <chr>          <chr>      <chr> <chr>
 1 Anderegg_2020 Anderegg_2020 Eucalyptus… 0271           leaf_area  525.… mm2  
 2 Anderegg_2020 Anderegg_2020 Eucalyptus… 0271           leaf_mass… 167.… g/m2 
 3 Anderegg_2020 Anderegg_2020 Eucalyptus… 0273           leaf_area  766.… mm2  
 4 Anderegg_2020 Anderegg_2020 Eucalyptus… 0273           leaf_mass… 184.… g/m2 
 5 Anderegg_2020 Anderegg_2020 Eucalyptus… 0275           leaf_area  407.… mm2  
 6 Anderegg_2020 Anderegg_2020 Eucalyptus… 0275           leaf_mass… 186.… g/m2 
 7 Anderegg_2020 Anderegg_2020 Eucalyptus… 0277           leaf_area  655.… mm2  
 8 Anderegg_2020 Anderegg_2020 Eucalyptus… 0277           leaf_mass… 204.… g/m2 
 9 Anderegg_2020 Anderegg_2020 Eucalyptus… 0279           leaf_area  517.… mm2  
10 Anderegg_2020 Anderegg_2020 Eucalyptus… 0279           leaf_mass… 185.… g/m2 
# ℹ 13,006 more rows
# ℹ 13 more variables: entity_type <chr>, value_type <chr>,
#   basis_of_value <chr>, replicates <chr>, basis_of_record <chr>,
#   life_stage <chr>, population_id <chr>, individual_id <chr>,
#   repeat_measurements_id <chr>, temporal_context_id <chr>, location_id <chr>,
#   entity_context_id <chr>, plot_context_id <chr>

Joining relational tables

For many research purposes you will want to join metadata from one of the relational tables to the core traits table. There are eight {austraits} functions that facilitate this by adding the columns you select from the ancillary data tables to the database’s traits table, seven functions that merge information from a single table (join_...) and a function that joins columns from all seven ancillary data tables (flatten_database). All functions output the database with the original database structure allowing you to follow up joining with extracting and to continue joining additional columns.

Joining location metadata

The locations table includes information on all location properties measured, including the actual location (latitude/longitude), climatic data, soil properties, fire history, vegetation history, geologic history, etc.

The austraits function join_location_coordinates just adds location name, latitude, and longitude to the core traits table:

traits_with_lat_long <- austraits %>% 
  austraits::extract_dataset(dataset_id = "Westoby") %>%
  austraits::join_location_coordinates()

traits_with_lat_long$traits %>% names()
 [1] "dataset_id"             "source_id"              "taxon_name"            
 [4] "observation_id"         "trait_name"             "value"                 
 [7] "unit"                   "entity_type"            "value_type"            
[10] "basis_of_value"         "replicates"             "basis_of_record"       
[13] "life_stage"             "population_id"          "individual_id"         
[16] "repeat_measurements_id" "temporal_context_id"    "location_id"           
[19] "entity_context_id"      "plot_context_id"        "treatment_context_id"  
[22] "collection_date"        "measurement_remarks"    "method_id"             
[25] "method_context_id"      "original_name"          "location_name"         
[28] "latitude (deg)"         "longitude (deg)"       

The function join_location_properties joins other location properties to the traits table. It has two arguments:

  1. vars, specifies the location properties, via complete or partial string matches, that should be added to the traits table; defaults to “all”

  2. format offers three output formats:

*   `many_columns` (each location property is added as a separate column)  
*   `single_column_pretty` (all location properties compacted into a single column delimited in a way that is easy for humans to read; this is the default)
*   `single_column_json` (all location properties compacted into a single column, using json formatting)  

Examples of joining location properties to the traits table:

# method to add location properties that you know exist from previous database exploration; this example showcases `format = "many_columns"
locations1 <- austraits %>%
  austraits::join_location_properties(vars = c("description", "aridity index (MAP/PET)", 
                                         "soil type", "fire history"), format = "many_columns")

locations1$traits %>% names()
 [1] "dataset_id"                                
 [2] "source_id"                                 
 [3] "taxon_name"                                
 [4] "observation_id"                            
 [5] "trait_name"                                
 [6] "value"                                     
 [7] "unit"                                      
 [8] "entity_type"                               
 [9] "value_type"                                
[10] "basis_of_value"                            
[11] "replicates"                                
[12] "basis_of_record"                           
[13] "life_stage"                                
[14] "population_id"                             
[15] "individual_id"                             
[16] "repeat_measurements_id"                    
[17] "temporal_context_id"                       
[18] "location_id"                               
[19] "entity_context_id"                         
[20] "plot_context_id"                           
[21] "treatment_context_id"                      
[22] "collection_date"                           
[23] "measurement_remarks"                       
[24] "method_id"                                 
[25] "method_context_id"                         
[26] "original_name"                             
[27] "location_name"                             
[28] "location_property: aridity index (MAP/PET)"
[29] "location_property: description"            
[30] "location_property: soil type"              
[31] "location_property: fire history"           
locations1$traits[1:10]
# A tibble: 2,450,777 × 10
   dataset_id source_id taxon_name         observation_id trait_name value unit 
   <chr>      <chr>     <chr>              <chr>          <chr>      <chr> <chr>
 1 ABRS_1981  ABRS_1981 Acanthocarpus can… 0001           leaf_comp… simp… <NA> 
 2 ABRS_1981  ABRS_1981 Acanthocarpus can… 0001           seed_leng… 3     mm   
 3 ABRS_1981  ABRS_1981 Acanthocarpus hum… 0002           leaf_comp… simp… <NA> 
 4 ABRS_1981  ABRS_1981 Acanthocarpus par… 0003           leaf_comp… simp… <NA> 
 5 ABRS_1981  ABRS_1981 Acanthocarpus pre… 0004           leaf_comp… simp… <NA> 
 6 ABRS_1981  ABRS_1981 Acanthocarpus pre… 0004           seed_leng… 4     mm   
 7 ABRS_1981  ABRS_1981 Acanthocarpus pre… 0004           seed_leng… 5     mm   
 8 ABRS_1981  ABRS_1981 Acanthocarpus rob… 0005           leaf_comp… simp… <NA> 
 9 ABRS_1981  ABRS_1981 Acanthocarpus rup… 0006           leaf_comp… simp… <NA> 
10 ABRS_1981  ABRS_1981 Acanthocarpus rup… 0006           seed_leng… 2.5   mm   
# ℹ 2,450,767 more rows
# ℹ 3 more variables: entity_type <chr>, value_type <chr>, basis_of_value <chr>
# method where you first lookup location properties using the function `lookup_location_property`; this example showcases `format = "single_column_pretty"
precipitation_properties <- lookup_location_property(database = austraits, term = "precipitation")

locations2 <- austraits %>%
  austraits::join_location_properties(vars = precipitation_properties, format = "single_column_pretty")

locations2$traits %>% names()
 [1] "dataset_id"             "source_id"              "taxon_name"            
 [4] "observation_id"         "trait_name"             "value"                 
 [7] "unit"                   "entity_type"            "value_type"            
[10] "basis_of_value"         "replicates"             "basis_of_record"       
[13] "life_stage"             "population_id"          "individual_id"         
[16] "repeat_measurements_id" "temporal_context_id"    "location_id"           
[19] "entity_context_id"      "plot_context_id"        "treatment_context_id"  
[22] "collection_date"        "measurement_remarks"    "method_id"             
[25] "method_context_id"      "original_name"          "location_name"         
[28] "location_properties"   
locations2$traits[1:10]
# A tibble: 2,450,777 × 10
   dataset_id source_id taxon_name         observation_id trait_name value unit 
   <chr>      <chr>     <chr>              <chr>          <chr>      <chr> <chr>
 1 ABRS_1981  ABRS_1981 Acanthocarpus can… 0001           leaf_comp… simp… <NA> 
 2 ABRS_1981  ABRS_1981 Acanthocarpus can… 0001           seed_leng… 3     mm   
 3 ABRS_1981  ABRS_1981 Acanthocarpus hum… 0002           leaf_comp… simp… <NA> 
 4 ABRS_1981  ABRS_1981 Acanthocarpus par… 0003           leaf_comp… simp… <NA> 
 5 ABRS_1981  ABRS_1981 Acanthocarpus pre… 0004           leaf_comp… simp… <NA> 
 6 ABRS_1981  ABRS_1981 Acanthocarpus pre… 0004           seed_leng… 4     mm   
 7 ABRS_1981  ABRS_1981 Acanthocarpus pre… 0004           seed_leng… 5     mm   
 8 ABRS_1981  ABRS_1981 Acanthocarpus rob… 0005           leaf_comp… simp… <NA> 
 9 ABRS_1981  ABRS_1981 Acanthocarpus rup… 0006           leaf_comp… simp… <NA> 
10 ABRS_1981  ABRS_1981 Acanthocarpus rup… 0006           seed_leng… 2.5   mm   
# ℹ 2,450,767 more rows
# ℹ 3 more variables: entity_type <chr>, value_type <chr>, basis_of_value <chr>
# method where you add all location properties; this example showcases `format = "single_column_json"
locations3 <- austraits %>%
  austraits::join_location_properties(vars = "all", format = "single_column_json")

locations3$traits %>% names()
 [1] "dataset_id"             "source_id"              "taxon_name"            
 [4] "observation_id"         "trait_name"             "value"                 
 [7] "unit"                   "entity_type"            "value_type"            
[10] "basis_of_value"         "replicates"             "basis_of_record"       
[13] "life_stage"             "population_id"          "individual_id"         
[16] "repeat_measurements_id" "temporal_context_id"    "location_id"           
[19] "entity_context_id"      "plot_context_id"        "treatment_context_id"  
[22] "collection_date"        "measurement_remarks"    "method_id"             
[25] "method_context_id"      "original_name"          "location_name"         
[28] "location_properties"   
locations3$traits[1:10]
# A tibble: 2,450,777 × 10
   dataset_id source_id taxon_name         observation_id trait_name value unit 
   <chr>      <chr>     <chr>              <chr>          <chr>      <chr> <chr>
 1 ABRS_1981  ABRS_1981 Acanthocarpus can… 0001           leaf_comp… simp… <NA> 
 2 ABRS_1981  ABRS_1981 Acanthocarpus can… 0001           seed_leng… 3     mm   
 3 ABRS_1981  ABRS_1981 Acanthocarpus hum… 0002           leaf_comp… simp… <NA> 
 4 ABRS_1981  ABRS_1981 Acanthocarpus par… 0003           leaf_comp… simp… <NA> 
 5 ABRS_1981  ABRS_1981 Acanthocarpus pre… 0004           leaf_comp… simp… <NA> 
 6 ABRS_1981  ABRS_1981 Acanthocarpus pre… 0004           seed_leng… 4     mm   
 7 ABRS_1981  ABRS_1981 Acanthocarpus pre… 0004           seed_leng… 5     mm   
 8 ABRS_1981  ABRS_1981 Acanthocarpus rob… 0005           leaf_comp… simp… <NA> 
 9 ABRS_1981  ABRS_1981 Acanthocarpus rup… 0006           leaf_comp… simp… <NA> 
10 ABRS_1981  ABRS_1981 Acanthocarpus rup… 0006           seed_leng… 2.5   mm   
# ℹ 2,450,767 more rows
# ℹ 3 more variables: entity_type <chr>, value_type <chr>, basis_of_value <chr>

Joining contexts metadata

The context table documents additional context properties/ancillary data which may be useful for interpreting trait values. Context properties are divided into 5 categories: treatment context, plot context, entity context, temporal context, and method context.

context category description
treatment context Context property that is an experimental manipulation, that might affect the trait values measured on an individual, population or species-level entity.
plot context Context property that is a feature of a plot (subset of a location) that might affect the trait values measured on an individual, population or species-level entity.
entity context Context property that is information about an organismal entity (individual, population or taxon) that does not comprise a trait-centered observation but might affect the trait values measured on the entity.
temporal context Context property that is a feature of a “point in time” that might affect the trait values measured on an individual, population or species-level entity.
method context Context property that records specific information about a measurement method that is modified between measurements.

The austraits function join_context_properties joins context properties to the traits table. It has three arguments:

  1. vars, specifies the context properties, via complete or partial string matches, that should be added to the traits table; defaults to “all”

  2. format offers three output formats:

*   `many_columns` (each context property is added as a separate column)  
*   `single_column_pretty` (all context properties compacted into a single column delimited in a way that is easy for humans to read; this is the default)
*   `single_column_json` (all context properties compacted into a single column, using json formatting)
  1. include_description is a logical argument (TRUE/FALSE) that indicates where the context property value descriptions should be included or excluded when context data are joined; defaults to “TRUE”

Each category of context property is added to a separate column for the compacted columns, retaining this important information about the different groupings of context properties. When format = "many_columns" is selected the context category is indicated in the column name.

Examples of joining context properties to the traits table:

# method to add context properties that you know exist from previous database exploration; this example showcases `format = "many_columns"
contexts1 <- austraits %>%
  austraits::join_context_properties(
    vars = c("sampling season", "plant sex", "leaf surface", "leaf age", "fire intensity",
             "slope position", "fire season", "drought treatment", "temperature treatment"), 
    format = "many_columns",
    include_description = TRUE
    )

contexts1$traits %>% names()
 [1] "dataset_id"                              
 [2] "source_id"                               
 [3] "taxon_name"                              
 [4] "observation_id"                          
 [5] "trait_name"                              
 [6] "value"                                   
 [7] "unit"                                    
 [8] "entity_type"                             
 [9] "value_type"                              
[10] "basis_of_value"                          
[11] "replicates"                              
[12] "basis_of_record"                         
[13] "life_stage"                              
[14] "population_id"                           
[15] "individual_id"                           
[16] "repeat_measurements_id"                  
[17] "temporal_context_id"                     
[18] "location_id"                             
[19] "entity_context_id"                       
[20] "plot_context_id"                         
[21] "treatment_context_id"                    
[22] "collection_date"                         
[23] "measurement_remarks"                     
[24] "method_id"                               
[25] "method_context_id"                       
[26] "original_name"                           
[27] "treatment_context: sampling season"      
[28] "treatment_context: drought treatment"    
[29] "treatment_context: temperature treatment"
[30] "plot_context: fire intensity"            
[31] "plot_context: slope position"            
[32] "entity_context: plant sex"               
[33] "entity_context: leaf age"                
[34] "temporal_context: sampling season"       
[35] "temporal_context: fire season"           
[36] "method_context: leaf age"                
[37] "method_context: leaf surface"            
contexts1$traits[1:10]
# A tibble: 2,450,777 × 10
   dataset_id source_id taxon_name         observation_id trait_name value unit 
   <chr>      <chr>     <chr>              <chr>          <chr>      <chr> <chr>
 1 ABRS_1981  ABRS_1981 Acanthocarpus can… 0001           leaf_comp… simp… <NA> 
 2 ABRS_1981  ABRS_1981 Acanthocarpus can… 0001           seed_leng… 3     mm   
 3 ABRS_1981  ABRS_1981 Acanthocarpus hum… 0002           leaf_comp… simp… <NA> 
 4 ABRS_1981  ABRS_1981 Acanthocarpus par… 0003           leaf_comp… simp… <NA> 
 5 ABRS_1981  ABRS_1981 Acanthocarpus pre… 0004           leaf_comp… simp… <NA> 
 6 ABRS_1981  ABRS_1981 Acanthocarpus pre… 0004           seed_leng… 4     mm   
 7 ABRS_1981  ABRS_1981 Acanthocarpus pre… 0004           seed_leng… 5     mm   
 8 ABRS_1981  ABRS_1981 Acanthocarpus rob… 0005           leaf_comp… simp… <NA> 
 9 ABRS_1981  ABRS_1981 Acanthocarpus rup… 0006           leaf_comp… simp… <NA> 
10 ABRS_1981  ABRS_1981 Acanthocarpus rup… 0006           seed_leng… 2.5   mm   
# ℹ 2,450,767 more rows
# ℹ 3 more variables: entity_type <chr>, value_type <chr>, basis_of_value <chr>
# method where you first lookup context properties using the function `lookup_context_property`; this example showcases `format = "single_column_pretty"
leaf_properties <- lookup_context_property(database = austraits, term = "leaf")

contexts2 <- austraits %>%
  austraits::join_context_properties(
    vars = leaf_properties,
    format = "single_column_pretty",
    include_description = TRUE
    )

contexts2$traits %>% names()
 [1] "dataset_id"                   "source_id"                   
 [3] "taxon_name"                   "observation_id"              
 [5] "trait_name"                   "value"                       
 [7] "unit"                         "entity_type"                 
 [9] "value_type"                   "basis_of_value"              
[11] "replicates"                   "basis_of_record"             
[13] "life_stage"                   "population_id"               
[15] "individual_id"                "repeat_measurements_id"      
[17] "temporal_context_id"          "location_id"                 
[19] "entity_context_id"            "plot_context_id"             
[21] "treatment_context_id"         "collection_date"             
[23] "measurement_remarks"          "method_id"                   
[25] "method_context_id"            "original_name"               
[27] "treatment_context_properties" "plot_context_properties"     
[29] "entity_context_properties"    "temporal_context_properties" 
[31] "method_context_properties"   
contexts2$traits[1:10]
# A tibble: 2,450,777 × 10
   dataset_id source_id taxon_name         observation_id trait_name value unit 
   <chr>      <chr>     <chr>              <chr>          <chr>      <chr> <chr>
 1 ABRS_1981  ABRS_1981 Acanthocarpus can… 0001           leaf_comp… simp… <NA> 
 2 ABRS_1981  ABRS_1981 Acanthocarpus can… 0001           seed_leng… 3     mm   
 3 ABRS_1981  ABRS_1981 Acanthocarpus hum… 0002           leaf_comp… simp… <NA> 
 4 ABRS_1981  ABRS_1981 Acanthocarpus par… 0003           leaf_comp… simp… <NA> 
 5 ABRS_1981  ABRS_1981 Acanthocarpus pre… 0004           leaf_comp… simp… <NA> 
 6 ABRS_1981  ABRS_1981 Acanthocarpus pre… 0004           seed_leng… 4     mm   
 7 ABRS_1981  ABRS_1981 Acanthocarpus pre… 0004           seed_leng… 5     mm   
 8 ABRS_1981  ABRS_1981 Acanthocarpus rob… 0005           leaf_comp… simp… <NA> 
 9 ABRS_1981  ABRS_1981 Acanthocarpus rup… 0006           leaf_comp… simp… <NA> 
10 ABRS_1981  ABRS_1981 Acanthocarpus rup… 0006           seed_leng… 2.5   mm   
# ℹ 2,450,767 more rows
# ℹ 3 more variables: entity_type <chr>, value_type <chr>, basis_of_value <chr>
# method where you add all context properties; this example showcases `format = "single_column_json"
contexts3 <- austraits %>%
  austraits::join_context_properties(
    vars = "all",
    format = "single_column_json",
    include_description = FALSE
    )

contexts3$traits %>% names()
 [1] "dataset_id"                   "source_id"                   
 [3] "taxon_name"                   "observation_id"              
 [5] "trait_name"                   "value"                       
 [7] "unit"                         "entity_type"                 
 [9] "value_type"                   "basis_of_value"              
[11] "replicates"                   "basis_of_record"             
[13] "life_stage"                   "population_id"               
[15] "individual_id"                "repeat_measurements_id"      
[17] "temporal_context_id"          "location_id"                 
[19] "entity_context_id"            "plot_context_id"             
[21] "treatment_context_id"         "collection_date"             
[23] "measurement_remarks"          "method_id"                   
[25] "method_context_id"            "original_name"               
[27] "treatment_context_properties" "plot_context_properties"     
[29] "entity_context_properties"    "temporal_context_properties" 
[31] "method_context_properties"   
contexts3$traits[1:10]
# A tibble: 2,450,777 × 10
   dataset_id source_id taxon_name         observation_id trait_name value unit 
   <chr>      <chr>     <chr>              <chr>          <chr>      <chr> <chr>
 1 ABRS_1981  ABRS_1981 Acanthocarpus can… 0001           leaf_comp… simp… <NA> 
 2 ABRS_1981  ABRS_1981 Acanthocarpus can… 0001           seed_leng… 3     mm   
 3 ABRS_1981  ABRS_1981 Acanthocarpus hum… 0002           leaf_comp… simp… <NA> 
 4 ABRS_1981  ABRS_1981 Acanthocarpus par… 0003           leaf_comp… simp… <NA> 
 5 ABRS_1981  ABRS_1981 Acanthocarpus pre… 0004           leaf_comp… simp… <NA> 
 6 ABRS_1981  ABRS_1981 Acanthocarpus pre… 0004           seed_leng… 4     mm   
 7 ABRS_1981  ABRS_1981 Acanthocarpus pre… 0004           seed_leng… 5     mm   
 8 ABRS_1981  ABRS_1981 Acanthocarpus rob… 0005           leaf_comp… simp… <NA> 
 9 ABRS_1981  ABRS_1981 Acanthocarpus rup… 0006           leaf_comp… simp… <NA> 
10 ABRS_1981  ABRS_1981 Acanthocarpus rup… 0006           seed_leng… 2.5   mm   
# ℹ 2,450,767 more rows
# ℹ 3 more variables: entity_type <chr>, value_type <chr>, basis_of_value <chr>

Joining methods columns

The methods table documents a selection of metadata recorded about the entire dataset and methods used for individual trait measurements. There is a single row of data per dataset_id x trait_name x method_id combination. Method_id is used to distinguish between instances where a single trait is measured twice using two separate protocols and is separate to method_context_id, which documents specific components of a method that are modified between measurements.

The austraits function join_methods joins columns from the methods table to the traits table. It has one argument:

  1. vars which specifies which columns from the methods table are joined to the traits table; defaults to vars = c("all")

First, check the schema file embedded within AusTraits to see what information is documented in each column:

austraits$schema$database$elements$methods$elements %>% 
  austraits::convert_list_to_df1()
# A tibble: 13 × 2
   key                 value                                                    
   <chr>               <chr>                                                    
 1 dataset_id          Primary identifier for each study contributed to AusTrai…
 2 trait_name          Name of the trait sampled. Allowable values specified in…
 3 methods             A textual description of the methods used to collect the…
 4 method_id           A unique integer identifier to distinguish between multi…
 5 description         A 1-2 sentence description of the purpose of the study.  
 6 sampling_strategy   A written description of how study locations were select…
 7 dataset_id_type     Citation type for the dataset's own reference, `sources[…
 8 dataset_id_citation Citation for the dataset's own reference, `sources[[data…
 9 secondary_id        Citation keys, separated by `; `, for the dataset's `sec…
10 secondary_citation  Citations, separated by `; `, for the `secondary` refere…
11 data_collectors     The person (people) leading data collection for this stu…
12 assistants          Names of people who played a more minor role in data col…
13 dataset_curators    Names of database team member(s) who contacted the data …

Examples using join_methods:

# join methods column only, the default
traits_with_methods <- 
  austraits %>% austraits::join_methods()

traits_with_methods$traits %>% names()
 [1] "dataset_id"             "source_id"              "taxon_name"            
 [4] "observation_id"         "trait_name"             "value"                 
 [7] "unit"                   "entity_type"            "value_type"            
[10] "basis_of_value"         "replicates"             "basis_of_record"       
[13] "life_stage"             "population_id"          "individual_id"         
[16] "repeat_measurements_id" "temporal_context_id"    "location_id"           
[19] "entity_context_id"      "plot_context_id"        "treatment_context_id"  
[22] "collection_date"        "measurement_remarks"    "method_id"             
[25] "method_context_id"      "original_name"          "methods"               
# join all methods table columns
traits_with_methods <- 
  austraits %>% austraits::join_methods(vars = "all")

traits_with_methods$traits %>% names()
 [1] "dataset_id"             "source_id"              "taxon_name"            
 [4] "observation_id"         "trait_name"             "value"                 
 [7] "unit"                   "entity_type"            "value_type"            
[10] "basis_of_value"         "replicates"             "basis_of_record"       
[13] "life_stage"             "population_id"          "individual_id"         
[16] "repeat_measurements_id" "temporal_context_id"    "location_id"           
[19] "entity_context_id"      "plot_context_id"        "treatment_context_id"  
[22] "collection_date"        "measurement_remarks"    "method_id"             
[25] "method_context_id"      "original_name"          "methods"               
[28] "description"            "sampling_strategy"      "dataset_id_type"       
[31] "dataset_id_citation"    "secondary_id"           "secondary_citation"    
[34] "data_collectors"        "assistants"             "dataset_curators"      
# join all specifically selected methods table columns
traits_with_methods <- 
  austraits %>% austraits::join_methods(vars = c("methods", "description", "source_secondary_key"))

traits_with_methods$traits %>% names()
 [1] "dataset_id"             "source_id"              "taxon_name"            
 [4] "observation_id"         "trait_name"             "value"                 
 [7] "unit"                   "entity_type"            "value_type"            
[10] "basis_of_value"         "replicates"             "basis_of_record"       
[13] "life_stage"             "population_id"          "individual_id"         
[16] "repeat_measurements_id" "temporal_context_id"    "location_id"           
[19] "entity_context_id"      "plot_context_id"        "treatment_context_id"  
[22] "collection_date"        "measurement_remarks"    "method_id"             
[25] "method_context_id"      "original_name"          "methods"               
[28] "description"           

Joining taxa

The taxa table documents a collection of names and identifiers for each taxon. Within AusTraits, names submitted as identifiers within a dataset might be resolved to a species, an infraspecific taxon, or sometimes just to a genus- or family-level name; the name’s resolution is recorded as the taxon_rank. The taxon_rank determines which information is filled in in the taxa table.

The {austraits} function join_taxa joins columns from the taxa table to the traits table. It has one argument:

  1. vars which specifies which columns from the taxa table are joined to the traits table; defaults to vars = c("family", "genus", "taxon_rank", "establishment_means").

First, check the schema file embedded within AusTraits to see what information is documented in each column:

austraits$schema$database$elements$taxa$elements %>% 
  austraits::convert_list_to_df1()
# A tibble: 15 × 2
   key                 value                                                    
   <chr>               <chr>                                                    
 1 taxon_name          Scientific name of the taxon on which traits were sample…
 2 taxonomic_dataset   Name of the taxonomy (tree) that contains this concept. …
 3 taxon_rank          The taxonomic rank of the most specific name in the scie…
 4 trinomial           The infraspecific taxon name match for an original name.…
 5 binomial            The species-level taxon name match for an original name.…
 6 genus               Genus of the taxon without authorship.                   
 7 family              Family of the taxon.                                     
 8 taxon_distribution  Known distribution of the taxon, by Australian state.    
 9 establishment_means Statement about whether an organism or organisms have be…
10 taxonomic_status    The status of the use of the scientificName as a label f…
11 taxon_id            An identifier for the set of taxon information (data ass…
12 taxon_id_genus      An identifier for the set of taxon information (data ass…
13 taxon_id_family     An identifier for the set of taxon information (data ass…
14 scientific_name     The full scientific name, with authorship and date infor…
15 scientific_name_id  An identifier for the set of taxon information (data ass…

Examples using join_taxa:

# join the default columns
traits_with_taxa <- 
  austraits %>% austraits::join_taxa()

traits_with_taxa$traits %>% names()
 [1] "dataset_id"             "source_id"              "taxon_name"            
 [4] "observation_id"         "trait_name"             "value"                 
 [7] "unit"                   "entity_type"            "value_type"            
[10] "basis_of_value"         "replicates"             "basis_of_record"       
[13] "life_stage"             "population_id"          "individual_id"         
[16] "repeat_measurements_id" "temporal_context_id"    "location_id"           
[19] "entity_context_id"      "plot_context_id"        "treatment_context_id"  
[22] "collection_date"        "measurement_remarks"    "method_id"             
[25] "method_context_id"      "original_name"          "family"                
[28] "genus"                  "taxon_rank"             "establishment_means"   
# join all taxa table columns
traits_with_taxa <- 
  austraits %>% austraits::join_taxa(vars = "all")

traits_with_taxa$traits %>% names()
 [1] "dataset_id"              "source_id"              
 [3] "taxon_name"              "observation_id"         
 [5] "trait_name"              "value"                  
 [7] "unit"                    "entity_type"            
 [9] "value_type"              "basis_of_value"         
[11] "replicates"              "basis_of_record"        
[13] "life_stage"              "population_id"          
[15] "individual_id"           "repeat_measurements_id" 
[17] "temporal_context_id"     "location_id"            
[19] "entity_context_id"       "plot_context_id"        
[21] "treatment_context_id"    "collection_date"        
[23] "measurement_remarks"     "method_id"              
[25] "method_context_id"       "original_name"          
[27] "taxon_rank"              "taxonomic_status"       
[29] "taxonomic_dataset"       "taxon_name_alternatives"
[31] "genus"                   "family"                 
[33] "binomial"                "trinomial"              
[35] "taxon_distribution"      "establishment_means"    
[37] "scientific_name"         "taxon_id"               
[39] "taxon_id_genus"          "taxon_id_family"        
[41] "scientific_name_id"     

Joining taxonomic updates

The taxonomic updates table documents all taxonomic changes implemented in the construction of AusTraits, including both the correction of typos and the updating of outdated synonyms to the currently accepted name.

The {austraits} function join_taxonomic_updates joins columns from the taxonomic_updates table to the traits table. It has one argument:

  1. vars which specifies which columns from the taxonomic_updates table are joined to the traits table; defaults to vars = c("aligned_name").

First, check the schema file embedded within AusTraits to see what information is documented in each column:

austraits$schema$database$elements$taxonomic_updates$elements %>% 
  austraits::convert_list_to_df1()
# A tibble: 7 × 2
  key                           value                                           
  <chr>                         <chr>                                           
1 dataset_id                    Primary identifier for each study contributed t…
2 original_name                 Name given to taxon in the original data suppli…
3 aligned_name                  The taxon name without authorship after impleme…
4 taxonomic_resolution          The rank of the most specific taxon name (or sc…
5 taxon_name                    Scientific name of the taxon on which traits we…
6 aligned_name_taxon_id         An identifier for the aligned name before it is…
7 aligned_name_taxonomic_status The status of the use of the `aligned_name` as …

Examples using join_taxonomic_updates:

# join the default columns
traits_with_taxonomic_updates <- 
  austraits %>% austraits::join_taxonomic_updates()

traits_with_taxonomic_updates$traits %>% names()
 [1] "dataset_id"             "source_id"              "taxon_name"            
 [4] "observation_id"         "trait_name"             "value"                 
 [7] "unit"                   "entity_type"            "value_type"            
[10] "basis_of_value"         "replicates"             "basis_of_record"       
[13] "life_stage"             "population_id"          "individual_id"         
[16] "repeat_measurements_id" "temporal_context_id"    "location_id"           
[19] "entity_context_id"      "plot_context_id"        "treatment_context_id"  
[22] "collection_date"        "measurement_remarks"    "method_id"             
[25] "method_context_id"      "original_name"          "aligned_name"          
# join all methods columns
traits_with_taxonomic_updates <- 
  austraits %>% austraits::join_taxonomic_updates(vars = "all")

traits_with_taxonomic_updates$traits %>% names()
 [1] "dataset_id"                    "source_id"                    
 [3] "taxon_name"                    "observation_id"               
 [5] "trait_name"                    "value"                        
 [7] "unit"                          "entity_type"                  
 [9] "value_type"                    "basis_of_value"               
[11] "replicates"                    "basis_of_record"              
[13] "life_stage"                    "population_id"                
[15] "individual_id"                 "repeat_measurements_id"       
[17] "temporal_context_id"           "location_id"                  
[19] "entity_context_id"             "plot_context_id"              
[21] "treatment_context_id"          "collection_date"              
[23] "measurement_remarks"           "method_id"                    
[25] "method_context_id"             "original_name"                
[27] "aligned_name"                  "taxonomic_resolution"         
[29] "aligned_name_taxon_id"         "aligned_name_taxonomic_status"

Joining contributors

The contributors table documents all basic metadata about all dataset contributors, including their name, ORCID, and role for various datasets.

The {austraits} function join_contributors joins columns from the contributors table to the traits table. It has two arguments:

  1. vars which specifies which columns from the contributors table are joined to the traits table; defaults to `vars = c(“aligned_name”).

  2. format offers two output formats:

*   `single_column_pretty` (data in selected columns from `contributor` table compacted into a single column delimited in a way that is easy for humans to read; this is the default)
*   `single_column_json` (data in selected columns from `contributor` table compacted into a single column, using json formatting)  

First, check the schema file embedded within AusTraits to see what information is documented in each column:

austraits$schema$database$elements$contributors$elements %>% 
  austraits::convert_list_to_df1()
# A tibble: 6 × 2
  key             value                                                         
  <chr>           <chr>                                                         
1 dataset_id      Primary identifier for each study contributed to AusTraits; m…
2 last_name       Last name of the data collector.                              
3 given_name      Given names of the data collector.                            
4 ORCID           ORCID of the data collector.                                  
5 affiliation     Last known institution or affiliation.                        
6 additional_role Additional roles of data collector, mostly contact person.    

Examples using join_contributors:

# join all columns (the default)
traits_with_contributors <- 
  austraits %>% austraits::join_contributors(format = "single_column_json")

traits_with_contributors$traits %>% names()
 [1] "dataset_id"             "source_id"              "taxon_name"            
 [4] "observation_id"         "trait_name"             "value"                 
 [7] "unit"                   "entity_type"            "value_type"            
[10] "basis_of_value"         "replicates"             "basis_of_record"       
[13] "life_stage"             "population_id"          "individual_id"         
[16] "repeat_measurements_id" "temporal_context_id"    "location_id"           
[19] "entity_context_id"      "plot_context_id"        "treatment_context_id"  
[22] "collection_date"        "measurement_remarks"    "method_id"             
[25] "method_context_id"      "original_name"          "data_contributors"     
# join select contributors columns
traits_with_contributors <- 
  austraits %>% austraits::join_contributors(
                  vars = c("last_name", "first_name", "ORCID"),
                  format = "single_column_pretty")

traits_with_contributors$traits %>% names()
 [1] "dataset_id"             "source_id"              "taxon_name"            
 [4] "observation_id"         "trait_name"             "value"                 
 [7] "unit"                   "entity_type"            "value_type"            
[10] "basis_of_value"         "replicates"             "basis_of_record"       
[13] "life_stage"             "population_id"          "individual_id"         
[16] "repeat_measurements_id" "temporal_context_id"    "location_id"           
[19] "entity_context_id"      "plot_context_id"        "treatment_context_id"  
[22] "collection_date"        "measurement_remarks"    "method_id"             
[25] "method_context_id"      "original_name"          "data_contributors"     
traits_with_contributors$traits
# A tibble: 2,450,777 × 27
   dataset_id source_id taxon_name         observation_id trait_name value unit 
   <chr>      <chr>     <chr>              <chr>          <chr>      <chr> <chr>
 1 ABRS_1981  ABRS_1981 Acanthocarpus can… 0001           leaf_comp… simp… <NA> 
 2 ABRS_1981  ABRS_1981 Acanthocarpus can… 0001           seed_leng… 3     mm   
 3 ABRS_1981  ABRS_1981 Acanthocarpus hum… 0002           leaf_comp… simp… <NA> 
 4 ABRS_1981  ABRS_1981 Acanthocarpus par… 0003           leaf_comp… simp… <NA> 
 5 ABRS_1981  ABRS_1981 Acanthocarpus pre… 0004           leaf_comp… simp… <NA> 
 6 ABRS_1981  ABRS_1981 Acanthocarpus pre… 0004           seed_leng… 4     mm   
 7 ABRS_1981  ABRS_1981 Acanthocarpus pre… 0004           seed_leng… 5     mm   
 8 ABRS_1981  ABRS_1981 Acanthocarpus rob… 0005           leaf_comp… simp… <NA> 
 9 ABRS_1981  ABRS_1981 Acanthocarpus rup… 0006           leaf_comp… simp… <NA> 
10 ABRS_1981  ABRS_1981 Acanthocarpus rup… 0006           seed_leng… 2.5   mm   
# ℹ 2,450,767 more rows
# ℹ 20 more variables: entity_type <chr>, value_type <chr>,
#   basis_of_value <chr>, replicates <chr>, basis_of_record <chr>,
#   life_stage <chr>, population_id <chr>, individual_id <chr>,
#   repeat_measurements_id <chr>, temporal_context_id <chr>, location_id <chr>,
#   entity_context_id <chr>, plot_context_id <chr>, treatment_context_id <chr>,
#   collection_date <chr>, measurement_remarks <chr>, method_id <chr>, …

Joining all data

If you want to join data from all ancillary tables onto the traits table, effectively “flattening” the relational table into a flat table, it is simplest to use the {austraits} function flatten_database.

flatten_database calls each of the join functions, selecting vars = "all" as the default for each function.

It has three arguments:

  1. vars, specifies the context properties, via complete or partial string matches, that should be added to the traits table; defaults to “all”

  2. format offers three output formats that apply to the functions join_locations, join_contexts and join_contributors

*   `many_columns` (each location or context property is added as a separate column)
*   `single_column_pretty` (all location or context properties or all contributor columns compacted into a single column delimited in a way that is easy for humans to read; this is the default)
*   `single_column_json` (all location or context properties or all contributor columns compacted into a single column, using json formatting)
  1. include_description is a logical argument (TRUE/FALSE) that indicates where the context property value descriptions should be included or excluded when context data are joined; defaults to “TRUE”; this argument is only used to parameterise join_contexts

Examples using flatten_database:

# using the defaults
flat_database <- austraits %>% flatten_database()

names(flat_database)
 [1] "dataset_id"                    "source_id"                    
 [3] "taxon_name"                    "observation_id"               
 [5] "trait_name"                    "value"                        
 [7] "unit"                          "entity_type"                  
 [9] "value_type"                    "basis_of_value"               
[11] "replicates"                    "basis_of_record"              
[13] "life_stage"                    "population_id"                
[15] "individual_id"                 "repeat_measurements_id"       
[17] "temporal_context_id"           "location_id"                  
[19] "entity_context_id"             "plot_context_id"              
[21] "treatment_context_id"          "collection_date"              
[23] "measurement_remarks"           "method_id"                    
[25] "method_context_id"             "original_name"                
[27] "location_name"                 "latitude (deg)"               
[29] "longitude (deg)"               "location_properties"          
[31] "treatment_context_properties"  "plot_context_properties"      
[33] "entity_context_properties"     "temporal_context_properties"  
[35] "method_context_properties"     "methods"                      
[37] "description"                   "sampling_strategy"            
[39] "assistants"                    "dataset_curators"             
[41] "dataset_id_type"               "dataset_id_citation"          
[43] "secondary_id"                  "secondary_citation"           
[45] "source_id_citation"            "data_contributors"            
[47] "taxon_rank"                    "taxonomic_status"             
[49] "taxonomic_dataset"             "taxon_name_alternatives"      
[51] "genus"                         "family"                       
[53] "binomial"                      "trinomial"                    
[55] "taxon_distribution"            "establishment_means"          
[57] "scientific_name"               "taxon_id"                     
[59] "taxon_id_genus"                "taxon_id_family"              
[61] "scientific_name_id"            "aligned_name"                 
[63] "taxonomic_resolution"          "aligned_name_taxon_id"        
[65] "aligned_name_taxonomic_status" "identifier_types"             
# specifying vars for each column
flat_database <- austraits %>% flatten_database(
  vars = list(
    location = "all",
    context = "sampling_season",
    contributors = c("last_name", "first_name", "ORCID"),
    identifiers = "all",
    taxonomy = c("family", "establishment_means"),
    taxonomic_updates = "aligned_name",
    methods = "methods"
  )
)

names(flat_database)
 [1] "dataset_id"                   "source_id"                   
 [3] "taxon_name"                   "observation_id"              
 [5] "trait_name"                   "value"                       
 [7] "unit"                         "entity_type"                 
 [9] "value_type"                   "basis_of_value"              
[11] "replicates"                   "basis_of_record"             
[13] "life_stage"                   "population_id"               
[15] "individual_id"                "repeat_measurements_id"      
[17] "temporal_context_id"          "location_id"                 
[19] "entity_context_id"            "plot_context_id"             
[21] "treatment_context_id"         "collection_date"             
[23] "measurement_remarks"          "method_id"                   
[25] "method_context_id"            "original_name"               
[27] "location_name"                "latitude (deg)"              
[29] "longitude (deg)"              "location_properties"         
[31] "treatment_context_properties" "plot_context_properties"     
[33] "entity_context_properties"    "temporal_context_properties" 
[35] "method_context_properties"    "methods"                     
[37] "dataset_id_type"              "dataset_id_citation"         
[39] "secondary_id"                 "secondary_citation"          
[41] "source_id_citation"           "data_contributors"           
[43] "family"                       "establishment_means"         
[45] "aligned_name"                 "identifier_types"            

Combining extract_ and join_ functions

As both the extract and join functions output a database with the original database structure they can be used sequentially to extract, then join exactly the data desired.

For instance:

subset2 <- austraits %>%
  austraits::extract_data(table = "traits", col = "basis_of_record", col_value = "field") %>%
  austraits::extract_trait(trait_name = c("leaf_mass_per_area", "leaf_thickness", "leaf_length", "leaf_area")) %>%
  austraits::extract_taxa(genus = "Eucalyptus") %>%
  austraits::join_location_coordinates() %>%
  austraits::join_taxa(vars = c("family")) %>%
  austraits::join_context_properties(vars = "all", format = "many_columns")

names(subset2)
 [1] "traits"            "locations"         "contexts"         
 [4] "methods"           "excluded_data"     "taxonomic_updates"
 [7] "taxa"              "identifiers"       "contributors"     
[10] "sources"           "definitions"       "schema"           
[13] "metadata"          "build_info"       

Having joined all context properties are separate columns, you may now look at the expanded traits table and decide that you only want data that was sampled during wet seasons, documented in the column temporal_context: sampling season

unique(subset2$traits$`temporal_context: sampling season`)
 [1] NA                                                                                                            
 [2] "summer favourable <<Measurements made during summer in a location where this is the favourable season.>>"    
 [3] "winter unfavourable <<Measurements made during winter in a location where this is the unfavourable season.>>"
 [4] "dry <<Measurements made during the dry season.>>"                                                            
 [5] "summer unfavourable <<Measurements made during summer in a location where this is the unfavourable season.>>"
 [6] "winter favourable <<Measurements made during winter in a location where this is the favourable season.>>"    
 [7] "October"                                                                                                     
 [8] "wet <<Measurements made during the wet season.>>"                                                            
 [9] "dry season <<Measurements made during the dry season.>>"                                                     
[10] "wet season <<Measurements made during the wet season.>>"                                                     
[11] "dry season (Sep 2010) <<Measurements made during the dry season (Sep 2010).>>"                               
[12] "wet season (May 2011) <<Measurements made during the wet season (May 2011).>>"                               
[13] "summer <<Measurement made in summer.>>"                                                                      
[14] "winter <<Measurement made in winter.>>"                                                                      
subset2 <- subset2 %>%
  austraits::extract_data(table = "traits", col = "temporal_context: sampling season", col_value = "wet")

Binding datasets

For some applications, you may wish to extract two different subsets of data, based on the values of different columns, then merge those extracted database subsets together, but still retain the original database structure.

This is possible with the function bind_databases.

This function binds each of the relational tables, removing any duplicate entries.

For instance, you might want all measurements where either the location_property or the context_property references the word “fire”:

subset_a <- austraits %>%
  austraits::extract_data(table = "locations", col = "location_property", col_value = "fire")

subset_b <- austraits %>%
  austraits::extract_data(table = "contexts", col = "context_property", col_value = "fire")

subset_ab <- bind_databases(subset_a, subset_b)

31.7 Citing the data you use

When you extract a subset of a database for an analysis, you should cite the original sources the data came from, not just the database as a whole. Because traits.build databases retain their full structure through the extract_ functions, the provenance you need travels with your subset.

To see the citations for the sources in a subset, look at the methods table, which carries a primary citation for every dataset:

subset_data <- austraits %>% extract_dataset(c("Falster", "Wright", "Westoby", "White"))

subset_data$methods %>%
  dplyr::distinct(dataset_id, source_primary_citation)

To produce a BibTeX file you can import into a reference manager (Zotero, EndNote, Mendeley, …), run RefManageR::WriteBib() on the subset’s sources element:

# writes a .bib file of all sources in the subset to your working directory
RefManageR::WriteBib(subset_data$sources)

# or write to a named file
RefManageR::WriteBib(subset_data$sources, file = "austraits_sources.bib")

You can also inspect or export a single source:

subset_data$sources["Falster_2005_1"]

This is the most reliable way to acknowledge everyone whose data you have used — for example, to find the full citation behind the values for a particular trait, extract that trait and read off the citations from its methods table or exported .bib.

31.8 Summarising data: trait means, modes, etc.

The function summarise_trait_means() (from {traits.use}, and available through {austraits}) gives one row per taxon and trait, computed from the records. For a numeric trait it gives the observed mean (a geometric mean of the dataset × location means), with the range and the number of records behind it; for a categorical trait, the most frequent value and the count of each value; and for a trait recording months, such as flowering_time, the months at least half the records give.

means <- summarise_trait_means(austraits, traits = c("leaf_mass_per_area", "resprouting_capacity"))

means
# A tibble: 16,478 × 27
   taxon_name              trait_name unit  estimate_type method value log_value
   <chr>                   <chr>      <chr> <chr>         <chr>  <dbl>     <dbl>
 1 Abelmoschus ficulneus   resprouti… <NA>  observed_mean mode      NA        NA
 2 Abelmoschus manihot     resprouti… <NA>  observed_mean mode      NA        NA
 3 Abelmoschus moschatus   resprouti… <NA>  observed_mean mode      NA        NA
 4 Abildgaardia macrantha  resprouti… <NA>  observed_mean mode      NA        NA
 5 Abildgaardia pachyptera resprouti… <NA>  observed_mean mode      NA        NA
 6 Abrodictyum caudatum    resprouti… <NA>  observed_mean mode      NA        NA
 7 Abrodictyum obscurum    resprouti… <NA>  observed_mean mode      NA        NA
 8 Abrotanella forsteroid… resprouti… <NA>  observed_mean mode      NA        NA
 9 Abrotanella nivigena    resprouti… <NA>  observed_mean mode      NA        NA
10 Abrotanella sp. [White… resprouti… <NA>  observed_mean mode      NA        NA
# ℹ 16,468 more rows
# ℹ 20 more variables: arithmetic_mean <dbl>, value_min <dbl>, value_max <dbl>,
#   n_records <int>, n_locations <int>, n_datasets <int>, n_flora <int>,
#   n_field <int>, sd_log <dbl>, reliability <chr>, dataset_id <chr>,
#   source_id <chr>, type <chr>, value_mode <chr>, value_count <chr>,
#   taxon_rank <chr>, genus <chr>, family <chr>, establishment_means <chr>,
#   taxon_id <chr>

Each AusTraits release from 8.0.0 also publishes these observed means for every trait, which load_austraits(version = "8.0.0", means = TRUE) loads without downloading the whole database.

If you’ve sourced the file extra_functions.R, there are also a few simpler functions that summarise trait values.

Categorical traits

For instance, categorical_summary indicates how many times a specific trait value is reported for a given taxa (across all datasets):

cat_summary <- categorical_summary(austraits, "resprouting_capacity")

cat_summary
# A tibble: 14,029 × 3
   taxon_name                             trait_name           value_summary    
   <chr>                                  <chr>                <chr>            
 1 Abelmoschus ficulneus                  resprouting_capacity fire_killed (4)  
 2 Abelmoschus manihot                    resprouting_capacity fire_killed (3)  
 3 Abelmoschus moschatus                  resprouting_capacity resprouts (1)    
 4 Abelmoschus moschatus subsp. tuberosus resprouting_capacity resprouts (3)    
 5 Abildgaardia macrantha                 resprouting_capacity partial_resprout…
 6 Abildgaardia pachyptera                resprouting_capacity fire_killed (2)  
 7 Abrodictyum caudatum                   resprouting_capacity fire_killed (2)  
 8 Abrodictyum obscurum                   resprouting_capacity fire_killed (2)  
 9 Abrotanella forsteroides               resprouting_capacity resprouts (1)    
10 Abrotanella nivigena                   resprouting_capacity resprouts (1)    
# ℹ 14,019 more rows

Alternatively, create a wider matrix with possible trait values as columns:

categorical_summary_wider <- 
  categorical_summary_by_value(austraits, "resprouting_capacity") %>%
    tidyr::pivot_wider(names_from = value_tmp, values_from = replicates)

categorical_summary_wider
# A tibble: 14,029 × 5
   taxon_name               trait_name fire_killed resprouts partial_resprouting
   <chr>                    <chr>            <dbl>     <dbl>               <dbl>
 1 Abelmoschus ficulneus    resprouti…           4        NA                  NA
 2 Abelmoschus manihot      resprouti…           3        NA                  NA
 3 Abelmoschus moschatus    resprouti…          NA         1                  NA
 4 Abelmoschus moschatus s… resprouti…          NA         3                  NA
 5 Abildgaardia macrantha   resprouti…          NA         1                   1
 6 Abildgaardia pachyptera  resprouti…           2        NA                  NA
 7 Abrodictyum caudatum     resprouti…           2        NA                  NA
 8 Abrodictyum obscurum     resprouti…           2        NA                  NA
 9 Abrotanella forsteroides resprouti…          NA         1                  NA
10 Abrotanella nivigena     resprouti…          NA         1                  NA
# ℹ 14,019 more rows

Numeric traits

One of the problems with writing functions that summarise numeric traits is that they make statistical assumptions that are hidden within the function code and might not be appropriate for your data use case.

The datasets that comprise AusTraits were collected by different people, with a different number of replicates and different entity types reported. One dataset might include 20 measurements on individuals for a trait and another might have submitted a single population-level mean derived from 5 measurements.

How do you take the mean of these trait values?

Do you want to include both data from experiments and plants growing under natural conditions? This information is recorded in the basis_of_record column.

One function we’re developing calculates weighted group means for field and experiment-sourced data, by first grouping values at the site level, then at the taxon level. For trait data sourced from floras where trait values are documented as a minimum and maximum value, the function takes the mean of these. The two subsets of data are then merged together.

weighted <- austraits_weighted_means(austraits, c("leaf_mass_per_area", 
                                                  "leaf_length"))

weighted
# A tibble: 32,101 × 10
   taxon_name       trait_name  mean   min   max median geom_mean all_replicates
   <chr>            <chr>      <dbl> <dbl> <dbl>  <dbl>     <dbl>          <dbl>
 1 Abelia x grandi… leaf_leng…   35     20    50     NA      35                1
 2 Abelmoschus fic… leaf_leng…  105     50   160     NA     105                1
 3 Abelmoschus man… leaf_leng…  232.   150   380     NA     230.               2
 4 Abelmoschus man… leaf_leng…  200    200   200     NA     200                1
 5 Abelmoschus man… leaf_leng…  165     30   300     NA      94.9              2
 6 Abelmoschus mos… leaf_leng…  103.    27   150     NA      97.6              3
 7 Abelmoschus mos… leaf_leng…  145    100   190     NA     138.               2
 8 Abelmoschus mos… leaf_leng…  150    150   150     NA     150                1
 9 Abelmoschus mos… leaf_leng…   65     60    70     NA      64.8              2
10 Abildgaardia ov… leaf_leng…  230     60   400     NA     230                1
# ℹ 32,091 more rows
# ℹ 2 more variables: location_replicates <dbl>, flora_replicates <dbl>

This function may be sufficient for exploratory purposes. Alternatively, you can download the file with the function and edit the code to suit your purposes.

31.9 Plotting data

Plotting trait distributions

Another way to summarise AusTraits data by trait, and determine whether AusTraits offers sufficient data coverage for a trait of choice, is to plot the distribution of trait values in AusTraits.

As seen in A first look at data, the function austraits::plot_trait_distribution_jitter() plots the values of a numeric trait, one point per record, by dataset_id, genus, family or indeed any column in the traits table, such as life_stage or basis_of_record:

# How does leaf N vary by dataset?
austraits::plot_trait_distribution_jitter(austraits, "leaf_N_per_dry_mass", 
                                            y_axis_category = "dataset_id")

# How does leaf N vary across Banksia species?
Banksia_data <- austraits %>% extract_taxa(genus = "Banksia")

austraits::plot_trait_distribution_jitter(Banksia_data, "leaf_N_per_dry_mass",
                                            y_axis_category = "taxon_name")

# Does leaf mass per area shift in Eucalyptus seedlings versus adults, which is captured in `life_stage`? What about amongst Eucalypts where information about the age of the leaves was recorded, captured as the context property "leaf age"?

Euc_data <- austraits %>% extract_taxa(genus = "Eucalyptus") %>%
  austraits::join_context_properties(vars = "leaf age", format = "many_columns", include_description = FALSE)

austraits::plot_trait_distribution_jitter(Euc_data, "leaf_mass_per_area", 
                                            y_axis_category = "life_stage")

austraits::plot_trait_distribution_jitter(Euc_data, "leaf_mass_per_area", 
                                            y_axis_category = "method_context: leaf age")

Plotting data distribution by location

To plot locations, begin by merging on the latitude & longitude data from austraits$locations using austraits::join_location_coordinates.

The plot_locations function plots the selected data, separating data into a series of plots based on the variable name selected. You can separate data based on the values of any column within the traits table – including basis_of_record, life_stage and value_type – or higher taxon categories (genus, family).

For instance, austraits::plot_locations("trait_name") will output a separate plot for each trait_name within the selected data.

A warning: austraits::plot_locations() WILL BE VERY SLOW if you request more than ~20 plots. For instance, do not attempt to generate plots for all traits simultaneously. Always first use extract/filter to just select a narrow range of traits, datasets, or taxa.

Plot locations by trait, dataset, or other column

See where Eucalyptus data have been collected, divided by life_stage

Euc_data <- Euc_data %>%
  austraits::join_location_coordinates()

austraits::plot_locations(database = Euc_data, feature = "life_stage")

See where Banksia leaf area data have been collected, divided by taxon_name

Banksia_data <- Banksia_data %>%
  austraits::join_location_coordinates() %>%
  austraits::extract_trait(trait_name = "leaf_area")

austraits::plot_locations(database = Banksia_data, feature = "taxon_name")

Where were the various Westoby datasets collected?

Westoby <-
  austraits %>%
     austraits::extract_dataset(dataset_id = "Westoby") %>%
     austraits::join_location_coordinates()

austraits::plot_locations(database = Westoby, feature = "dataset_id")

# Note that while the `dataset` is intended to be a relational database, this function also works with just the traits table, should you have separated it out of the relational structure.

# Westoby_traits <- Westoby$traits
# austraits::plot_locations(dataset = Westoby_traits, feature = "dataset_id")

Where were data for Acacia aneura collected?

data <-
  austraits %>%
  austraits::extract_taxa(taxon_name = "Acacia aneura") %>%
  austraits::join_location_coordinates()

data$traits <- data$traits %>% 
  dplyr::filter(!is.na(`latitude (deg)`)) 

austraits::plot_locations(data, "taxon_name")     # actually 4 taxa, because of subspecies

austraits::plot_locations(data, "dataset_id")     # 1 plot for each dataset_id

More complex workflows – some examples

An example looking at trait-climate gradients

A simple workflow allows one to look at trait values across a climate gradient

An example incorporating ALA distribution data

A recent tutorial posted by ALA shows how one can combine AusTraits trait data and ALA spatial occurrence data:

Alternatives to box plots

We’ve adopted it here.

31.10 A complexity: pivoting datasets

The AusTraits tables are all in long format with an individual row for each trait measurement. This is the most compact way to store data and offers the flexibility of documenting diverse metadata for each trait measurement.

However, for many research uses, it may be more useful to view data in a wide format, with the multiple traits that comprise a single observation displayed as consecutive columns.

The {austraits} function trait_pivot_wider allows AusTraits datasets to be pivoted from long to wide format.

It is recommended to only use this function on individual datasets – or perhaps a small selection of datasets – as each dataset includes a different collection of traits and pivoting wider otherwise creates a very “holey” dataset.

Farrell_2017_values <-
  austraits %>%
    austraits::extract_dataset(dataset_id = "Farrell_2017")

Farrell_2017_pivoted <- 
  Farrell_2017_values$traits %>%
    austraits::trait_pivot_wider()

Farrell_2017_pivoted
# A tibble: 177 × 25
   dataset_id   source_id  taxon_name observation_id entity_type basis_of_record
   <chr>        <chr>      <chr>      <chr>          <chr>       <chr>          
 1 Farrell_2017 Farrell_2… Arthropod… 001            individual  lab            
 2 Farrell_2017 Farrell_2… Arthropod… 002            individual  lab            
 3 Farrell_2017 Farrell_2… Arthropod… 003            individual  lab            
 4 Farrell_2017 Farrell_2… Arthropod… 004            individual  lab            
 5 Farrell_2017 Farrell_2… Arthropod… 005            individual  lab            
 6 Farrell_2017 Farrell_2… Arthropod… 006            individual  lab            
 7 Farrell_2017 Farrell_2… Arthropod… 007            individual  lab            
 8 Farrell_2017 Farrell_2… Arthropod… 008            individual  lab            
 9 Farrell_2017 Farrell_2… Arthropod… 009            individual  lab            
10 Farrell_2017 Farrell_2… Chrysocep… 010            individual  lab            
# ℹ 167 more rows
# ℹ 19 more variables: life_stage <chr>, population_id <chr>,
#   individual_id <chr>, repeat_measurements_id <chr>,
#   temporal_context_id <chr>, location_id <chr>, entity_context_id <chr>,
#   plot_context_id <chr>, treatment_context_id <chr>, collection_date <chr>,
#   method_id <chr>, method_context_id <chr>, original_name <chr>,
#   bulk_modulus_of_elasticity <chr>, …

This example pivots “nicely” as all observations have entity_type = individual.

Compare this first example to the dataset Edwards_2000 which includes individual-, population-, and species-level observations:

Edwards_2000_values <-
  austraits %>%
    austraits::extract_dataset(dataset_id = "Edwards_2000")

Edwards_2000_pivoted <- 
  Edwards_2000_values$traits %>%
    austraits::trait_pivot_wider()

Edwards_2000_pivoted
# A tibble: 139 × 35
   dataset_id   source_id  taxon_name observation_id entity_type basis_of_record
   <chr>        <chr>      <chr>      <chr>          <chr>       <chr>          
 1 Edwards_2000 Edwards_2… Acacia me… 001            individual  field          
 2 Edwards_2000 Edwards_2… Acacia me… 002            individual  field          
 3 Edwards_2000 Edwards_2… Acacia me… 003            individual  field          
 4 Edwards_2000 Edwards_2… Acacia me… 004            individual  field          
 5 Edwards_2000 Edwards_2… Acacia me… 005            individual  field          
 6 Edwards_2000 Edwards_2… Acacia me… 006            population  field          
 7 Edwards_2000 Edwards_2… Acacia me… 007            species     field          
 8 Edwards_2000 Edwards_2… Acacia su… 008            individual  field          
 9 Edwards_2000 Edwards_2… Acacia su… 009            individual  field          
10 Edwards_2000 Edwards_2… Acacia su… 010            individual  field          
# ℹ 129 more rows
# ℹ 29 more variables: life_stage <chr>, population_id <chr>,
#   individual_id <chr>, repeat_measurements_id <chr>,
#   temporal_context_id <chr>, location_id <chr>, entity_context_id <chr>,
#   plot_context_id <chr>, treatment_context_id <chr>, collection_date <chr>,
#   method_id <chr>, method_context_id <chr>, original_name <chr>,
#   leaf_N_per_area <chr>, leaf_N_per_dry_mass <chr>, leaf_area <chr>, …

The values at the individual, population and species level do not collapse together, because traits measured on different entity_types have separate observation_id’s.

One of the core identifiers assigned to data points is the observation_id. An observation is a collection of measurements made on a specific entity at a single point in time.

Observation_id’s are, therefore, unique combinations of:

  • dataset_id
  • source_id
  • entity_type
  • taxon_name
  • population_id (location_id, plot_context_id, treatment_context_id)
  • individual_id
  • basis_of_record
  • entity_context_id
  • life_stage
  • temporal_context_id
  • collection_date
  • original_name

If a single dataset includes traits that are attributed to different entity types, they are assigned separate observation_id’s. For instance, many datasets are comprised of individual-level physiological trait data and a column growth_form, documenting the growth form (i.e. tree, shrub, herb, etc.) of each species.

We’re developing a function, merge_entity_types that collapses the pivoted data into a more condensed table, but this loses some of the metadata. This function is currently in the R file extra_functions.R

Edwards_2000_pivoted_merged <-
  merge_entity_types("Edwards_2000")
  • This function will duplicate any “higher-entity” trait values (e.g. A single species-level value is filled in for all individuals or populations)

  • Metadata fields, like entity_type or value_type, are only retained if their values are identical for all measurements

Westoby_2014_pivoted_merged <-
  merge_entity_types("Westoby_2014")

31.11 Intepreting trait names, taxon names

Trait dictionary

The {traits.build} pipeline requires a trait dictionary that documents 4 pieces of information about each trait:

  • trait name 
  • trait type (categorical vs numeric) 
  • allowable trait values (for categorical traits) 
  • allowable trait range and units (for numeric traits) 

The trait dictionary embedded within AusTraits also has:

  • trait labels 
  • trait definitions 
  • definitions for all categorical trait values 

Together these clarify each “trait concept”, which we define as: “a circumscribed set of trait measurements”. Much like a taxon concept delimits a collection of organisms, a trait concept delimits a collection of trait values pertaining to a distinct characteristic of a specific part of an organism (cell, tissue, organ, or whole organism).

The AusTraits Plant Dictionary (APD) offers detailed descriptions for all trait concepts included in AusTraits. With the APD, each trait is given a unique, resolvable identifier, allowing trait definitions to be reused and shared.

The trait dictionary also includes: 

  • keywords 
  • plant structure measured 
  • characteristic measured 
  • references 
  • links to the same (or similar) trait concepts in other databases and dictionaries 

Understanding taxon names

AusTraits uses the taxon names in the Australian Plant Census (APC) and the scientific names in the Australian Plant Names Index (APNI).

The R package {APCalign} is used to align and update taxon names submitted to AusTraits with those in the APC/APNI.

{APCalign} can be installed directly from CRAN

#install.packages("APCalign")

library(APCalign) # Australian plant taxon alignment function, available on CRAN 

Attaching package: 'APCalign'
The following object is masked from 'package:austraits':

    get_versions

There are two key components to the workflow: 

  1. aligning names 
  • syntax is standardised, including for phrase names 

  • most spelling mistakes are corrected 

  • names that indicate the plant can only be identified to genus are reformatted to genus sp. [available notes; dataset_id] 

    1. they are linked to an APC-accepted genus but not to an APC-accepted binomial. 

    2. they include the dataset_id so people don’t mistakenly group all Eucalyptus sp. as a single “species” 

  1. updating names 
  • all aligned names that are in the APC, but that have a taxonomic status other than accepted, are updated to their currently accepted name. 

Examples: 

Identical genus sp. inputs from disparate datasets are given unique “names”: 

austraits$traits %>%
  dplyr::filter(stringr::str_detect(original_name, "Eucalyptus sp\\.$")) %>%
  dplyr::distinct(dataset_id, taxon_name, original_name) %>%
  dplyr::filter(original_name != taxon_name) 
# A tibble: 7 × 3
  dataset_id         taxon_name                          original_name 
  <chr>              <chr>                               <chr>         
1 Britton_2026       Eucalyptus sp. [Britton_2026]       Eucalyptus sp.
2 Brown_1997         Eucalyptus sp. [Brown_1997]         Eucalyptus sp.
3 Clarke_2015        Eucalyptus sp. [Clarke_2015]        Eucalyptus sp.
4 Nolan_2022         Eucalyptus sp. [Nolan_2022]         Eucalyptus sp.
5 Prendergast_2026_2 Eucalyptus sp. [Prendergast_2026_2] Eucalyptus sp.
6 Soper_2014         Eucalyptus sp. [Soper_2014]         Eucalyptus sp.
7 Zieminska_2015     Eucalyptus sp. [Zieminska_2015]     Eucalyptus sp.

Outdated names are updated: 

austraits$traits %>%
  dplyr::filter(stringr::str_detect(original_name, "Dryandra")) %>%
  dplyr::distinct(taxon_name, original_name) %>%
  dplyr::filter(original_name != taxon_name) %>% dplyr::slice(1:15)
# A tibble: 15 × 2
   taxon_name                                 original_name                     
   <chr>                                      <chr>                             
 1 Banksia acanthopoda                        Dryandra acanthopoda              
 2 Banksia anatona                            Dryandra anatona                  
 3 Banksia arborea                            Dryandra arborea                  
 4 Banksia arctotidis                         Dryandra arctotidis               
 5 Banksia armata var. armata                 Dryandra armata var. armata       
 6 Banksia armata var. ignicida               Dryandra armata var. ignicida     
 7 Banksia armata                             Dryandra armata                   
 8 Banksia aurantia                           Dryandra aurantia                 
 9 Banksia biterax                            Dryandra baxteri                  
10 Banksia bipinnatifida subsp. bipinnatifida Dryandra bipinnatifida subsp. bip…
11 Banksia bipinnatifida subsp. multifida     Dryandra bipinnatifida subsp. mul…
12 Banksia bipinnatifida                      Dryandra bipinnatifida            
13 Banksia pellaeifolia                       Dryandra blechnifolia             
14 Banksia borealis subsp. borealis           Dryandra borealis subsp. borealis 
15 Banksia borealis subsp. elatior            Dryandra borealis subsp. elatior  

Phrase name syntax across datasets is aligned:

austraits$traits %>%
  dplyr::filter(stringr::str_detect(taxon_name, "Argyrodendron sp. Whyanbeel")) %>%
  dplyr::distinct(taxon_name, original_name)
# A tibble: 6 × 2
  taxon_name                                       original_name                
  <chr>                                            <chr>                        
1 Argyrodendron sp. Whyanbeel (B.P.Hyland RFK1106) Argyrodendron sp. Whyanbeel …
2 Argyrodendron sp. Whyanbeel (B.P.Hyland RFK1106) Argyrodendron (Whyanbeel)    
3 Argyrodendron sp. Whyanbeel (B.P.Hyland RFK1106) Argyrodendron ssp. (Whyanbee…
4 Argyrodendron sp. Whyanbeel (B.P.Hyland RFK1106) Argyrodendron Whyanbeel      
5 Argyrodendron sp. Whyanbeel (B.P.Hyland RFK1106) Argyrodendron sp. (Whyanbeel…
6 Argyrodendron sp. Whyanbeel (B.P.Hyland RFK1106) Argyrodendron sp. Whyanbeel …