Title: | Phenotypic Index Measures for Oak Decline Severity |
---|---|
Description: | Oak declines are complex disease syndromes and consist of many visual indicators that include aspects of tree size, crown condition and trunk condition. This can cause difficulty in the manual classification of symptomatic and non-symptomatic trees from what is in reality a broad spectrum of oak tree health condition. Two phenotypic oak decline indexes have been developed to quantitatively describe and differentiate oak decline syndromes in Quercus robur. This package provides a toolkit to generate these decline indexes from phenotypic descriptors using the machine learning algorithm random forest. The methodology for generating these indexes is outlined in Finch et al. (2121) <doi:10.1016/j.foreco.2021.118948>. |
Authors: | Jasen Finch [aut, cre] |
Maintainer: | Jasen Finch <[email protected]> |
License: | GPL-3 |
Version: | 0.4.2 |
Built: | 2024-11-07 03:27:01 UTC |
Source: | https://github.com/jasenfinch/pdi |
Calculate Agrilus biguttatus exit hole density.
agrilusExitHoleDensity(n, d, s = 2)
agrilusExitHoleDensity(n, d, s = 2)
n |
number of Agrilus exit holes |
d |
diameter at breast height (m) |
s |
height to which stem surveyed from the tree base (m) |
agrilusExitHoleDensity(2,1.02,1.3)
agrilusExitHoleDensity(2,1.02,1.3)
Calculate estimated bleed prevalence.
bleedPrevalence(a, A, b, B, d, s = 3)
bleedPrevalence(a, A, b, B, d, s = 3)
a |
average active bleed size (mm) |
A |
number of active bleeds |
b |
average black stain size (mm) |
B |
number of black stains |
d |
diameter at breast height (m) |
s |
height to which stem surveyed from the tree base (m) |
bleedPrevalence(30,10,40,5,1,1.3)
bleedPrevalence(30,10,40,5,1,1.3)
Calculate Phenotypic Decline Index (PDI) and Decline Acuteness Index (DAI).
calcDIs(rfModels, PDI = TRUE, DAI = TRUE, invertPDI = TRUE, invertDAI = TRUE)
calcDIs(rfModels, PDI = TRUE, DAI = TRUE, invertPDI = TRUE, invertDAI = TRUE)
rfModels |
list containing random forest models as returned by |
PDI |
TRUE/FALSE, calculate PDI? |
DAI |
TRUE/FALSE, calculate DAI? |
invertPDI |
invert the PDI scale? TRUE/FALSE. Ignored if argument PDI is FALSE |
invertDAI |
invert the DAI scale? TRUE/FALSE. Ignored if argument DAI is FALSE |
library(dplyr) ## Retrieve file paths for example data files <- list.files(system.file('phenotypeDataCollectionSheets', package = 'pdi'),full.names = TRUE) ## Prepare data d <- map(files,readPhenotypeSheet) %>% map(preparePhenotypeData) %>% bind_rows() %>% siteAdjustment() %>% mutate(`Live crown ratio (%)` = liveCrownRatio(`Total height (m)`, `Lower crown height (m)`), `Crown condition (%)` = crownCondition(`Missing crown (%)`, `Crown transparency (%)`), `Crown volume (m^3)` = crownVolume(`Crown radius (m)`, `Total height (m)`, `Lower crown height (m)`, `Crown condition (%)`), `Bleed prevalence (%)` = bleedPrevalence(`Active bleed length (mm)`, `Active bleeds`, `Black staining length (mm)`, `Black staining`, `Diameter at breast height (m)`), `Agrilus exit hole density (m^-2)` = agrilusExitHoleDensity(`Agrilus exit holes`, `Diameter at breast height (m)`) ) t <- makeAnalysisTable(d) ## Generate random forest models m <- rf(t,cls = NULL,nreps = 10) ## Calculate decline indexese DIs <- calcDIs(m,DAI = FALSE,invertPDI = FALSE) %>% bind_cols(d %>% select(Location,ID,Status))
library(dplyr) ## Retrieve file paths for example data files <- list.files(system.file('phenotypeDataCollectionSheets', package = 'pdi'),full.names = TRUE) ## Prepare data d <- map(files,readPhenotypeSheet) %>% map(preparePhenotypeData) %>% bind_rows() %>% siteAdjustment() %>% mutate(`Live crown ratio (%)` = liveCrownRatio(`Total height (m)`, `Lower crown height (m)`), `Crown condition (%)` = crownCondition(`Missing crown (%)`, `Crown transparency (%)`), `Crown volume (m^3)` = crownVolume(`Crown radius (m)`, `Total height (m)`, `Lower crown height (m)`, `Crown condition (%)`), `Bleed prevalence (%)` = bleedPrevalence(`Active bleed length (mm)`, `Active bleeds`, `Black staining length (mm)`, `Black staining`, `Diameter at breast height (m)`), `Agrilus exit hole density (m^-2)` = agrilusExitHoleDensity(`Agrilus exit holes`, `Diameter at breast height (m)`) ) t <- makeAnalysisTable(d) ## Generate random forest models m <- rf(t,cls = NULL,nreps = 10) ## Calculate decline indexese DIs <- calcDIs(m,DAI = FALSE,invertPDI = FALSE) %>% bind_cols(d %>% select(Location,ID,Status))
Calculate crown condition (%).
crownCondition(m, t)
crownCondition(m, t)
m |
missing crown (%) |
t |
crown transparency (%) |
crownCondition(50,60)
crownCondition(50,60)
Calculate the crown production efficiency
crownProductionEfficiency(crown_surface_area, crown_volume)
crownProductionEfficiency(crown_surface_area, crown_volume)
crown_surface_area |
crown surface area (m^2) |
crown_volume |
crown volume (m^3) |
crownProductionEfficiency(34,35)
crownProductionEfficiency(34,35)
Calculate the crown surface area
crownSurfaceArea(r, h, l, c)
crownSurfaceArea(r, h, l, c)
r |
crown radius (m) |
h |
total height (m) |
l |
lower crown height (m) |
c |
crown condition (%) |
crownSurfaceArea(3,15,10,50)
crownSurfaceArea(3,15,10,50)
Calculate estimated crown volume.
crownVolume(r, h, l, c)
crownVolume(r, h, l, c)
r |
crown radius (m) |
h |
total height (m) |
l |
lower crown height (m) |
c |
crown condition (%) |
crownVolume(3,15,10,50)
crownVolume(3,15,10,50)
Calculate average descriptor contributions to random forest models.
descriptorContributions(rfModels)
descriptorContributions(rfModels)
rfModels |
list containing random forest models as returned by |
See see ?randomForest::importance
for details on random forest importance metrics.
library(dplyr) ## Retrieve file paths for example data files <- list.files(system.file('phenotypeDataCollectionSheets', package = 'pdi'),full.names = TRUE) ## Prepare data d <- map(files,readPhenotypeSheet) %>% map(preparePhenotypeData) %>% bind_rows() %>% siteAdjustment() %>% mutate(`Live crown ratio (%)` = liveCrownRatio(`Total height (m)`, `Lower crown height (m)`), `Crown condition (%)` = crownCondition(`Missing crown (%)`, `Crown transparency (%)`), `Crown volume (m^3)` = crownVolume(`Crown radius (m)`, `Total height (m)`, `Lower crown height (m)`, `Crown condition (%)`), `Bleed prevalence (%)` = bleedPrevalence(`Active bleed length (mm)`, `Active bleeds`, `Black staining length (mm)`, `Black staining`, `Diameter at breast height (m)`), `Agrilus exit hole density (m^-2)` = agrilusExitHoleDensity(`Agrilus exit holes`, `Diameter at breast height (m)`) ) t <- makeAnalysisTable(d) ## Generate random forest models m <- rf(t,cls = NULL,nreps = 10) descriptor_contributions <- m %>% descriptorContributions()
library(dplyr) ## Retrieve file paths for example data files <- list.files(system.file('phenotypeDataCollectionSheets', package = 'pdi'),full.names = TRUE) ## Prepare data d <- map(files,readPhenotypeSheet) %>% map(preparePhenotypeData) %>% bind_rows() %>% siteAdjustment() %>% mutate(`Live crown ratio (%)` = liveCrownRatio(`Total height (m)`, `Lower crown height (m)`), `Crown condition (%)` = crownCondition(`Missing crown (%)`, `Crown transparency (%)`), `Crown volume (m^3)` = crownVolume(`Crown radius (m)`, `Total height (m)`, `Lower crown height (m)`, `Crown condition (%)`), `Bleed prevalence (%)` = bleedPrevalence(`Active bleed length (mm)`, `Active bleeds`, `Black staining length (mm)`, `Black staining`, `Diameter at breast height (m)`), `Agrilus exit hole density (m^-2)` = agrilusExitHoleDensity(`Agrilus exit holes`, `Diameter at breast height (m)`) ) t <- makeAnalysisTable(d) ## Generate random forest models m <- rf(t,cls = NULL,nreps = 10) descriptor_contributions <- m %>% descriptorContributions()
Calculate the live crown ratio
liveCrownRatio(h, l)
liveCrownRatio(h, l)
h |
total height (m) |
l |
lower crown height (m) |
liveCrownRatio(15,10)
liveCrownRatio(15,10)
prepare data table ready for random forest analysis
makeAnalysisTable(phenoData)
makeAnalysisTable(phenoData)
phenoData |
tibble containing phenotype data |
library(dplyr) ## Retrieve file paths for example data files <- list.files(system.file('phenotypeDataCollectionSheets', package = 'pdi'),full.names = TRUE) ## Prepare data d <- map(files,readPhenotypeSheet) %>% map(preparePhenotypeData) %>% bind_rows() %>% siteAdjustment() %>% mutate(`Live crown ratio (%)` = liveCrownRatio(`Total height (m)`, `Lower crown height (m)`), `Crown condition (%)` = crownCondition(`Missing crown (%)`, `Crown transparency (%)`), `Crown volume (m^3)` = crownVolume(`Crown radius (m)`, `Total height (m)`, `Lower crown height (m)`, `Crown condition (%)`), `Bleed prevalence (%)` = bleedPrevalence(`Active bleed length (mm)`, `Active bleeds`, `Black staining length (mm)`, `Black staining`, `Diameter at breast height (m)`), `Agrilus exit hole density (m^-2)` = agrilusExitHoleDensity(`Agrilus exit holes`, `Diameter at breast height (m)`) ) t <- makeAnalysisTable(d)
library(dplyr) ## Retrieve file paths for example data files <- list.files(system.file('phenotypeDataCollectionSheets', package = 'pdi'),full.names = TRUE) ## Prepare data d <- map(files,readPhenotypeSheet) %>% map(preparePhenotypeData) %>% bind_rows() %>% siteAdjustment() %>% mutate(`Live crown ratio (%)` = liveCrownRatio(`Total height (m)`, `Lower crown height (m)`), `Crown condition (%)` = crownCondition(`Missing crown (%)`, `Crown transparency (%)`), `Crown volume (m^3)` = crownVolume(`Crown radius (m)`, `Total height (m)`, `Lower crown height (m)`, `Crown condition (%)`), `Bleed prevalence (%)` = bleedPrevalence(`Active bleed length (mm)`, `Active bleeds`, `Black staining length (mm)`, `Black staining`, `Diameter at breast height (m)`), `Agrilus exit hole density (m^-2)` = agrilusExitHoleDensity(`Agrilus exit holes`, `Diameter at breast height (m)`) ) t <- makeAnalysisTable(d)
perform multidimensional scaling of random forest proximities
mds(rfModels, dimensions = 2)
mds(rfModels, dimensions = 2)
rfModels |
list containing random forest models as returned by |
dimensions |
number of dimensions to scale to |
library(dplyr) ## Retrieve file paths for example data files <- list.files(system.file('phenotypeDataCollectionSheets', package = 'pdi'),full.names = TRUE) ## Prepare data d <- map(files,readPhenotypeSheet) %>% map(preparePhenotypeData) %>% bind_rows() %>% siteAdjustment() %>% mutate(`Live crown ratio (%)` = liveCrownRatio(`Total height (m)`, `Lower crown height (m)`), `Crown condition (%)` = crownCondition(`Missing crown (%)`, `Crown transparency (%)`), `Crown volume (m^3)` = crownVolume(`Crown radius (m)`, `Total height (m)`, `Lower crown height (m)`, `Crown condition (%)`), `Bleed prevalence (%)` = bleedPrevalence(`Active bleed length (mm)`, `Active bleeds`, `Black staining length (mm)`, `Black staining`, `Diameter at breast height (m)`), `Agrilus exit hole density (m^-2)` = agrilusExitHoleDensity(`Agrilus exit holes`, `Diameter at breast height (m)`) ) t <- makeAnalysisTable(d) ## Generate random forest models m <- rf(t,cls = NULL,nreps = 10) mds_data <- mds(m,2)
library(dplyr) ## Retrieve file paths for example data files <- list.files(system.file('phenotypeDataCollectionSheets', package = 'pdi'),full.names = TRUE) ## Prepare data d <- map(files,readPhenotypeSheet) %>% map(preparePhenotypeData) %>% bind_rows() %>% siteAdjustment() %>% mutate(`Live crown ratio (%)` = liveCrownRatio(`Total height (m)`, `Lower crown height (m)`), `Crown condition (%)` = crownCondition(`Missing crown (%)`, `Crown transparency (%)`), `Crown volume (m^3)` = crownVolume(`Crown radius (m)`, `Total height (m)`, `Lower crown height (m)`, `Crown condition (%)`), `Bleed prevalence (%)` = bleedPrevalence(`Active bleed length (mm)`, `Active bleeds`, `Black staining length (mm)`, `Black staining`, `Diameter at breast height (m)`), `Agrilus exit hole density (m^-2)` = agrilusExitHoleDensity(`Agrilus exit holes`, `Diameter at breast height (m)`) ) t <- makeAnalysisTable(d) ## Generate random forest models m <- rf(t,cls = NULL,nreps = 10) mds_data <- mds(m,2)
Variable min-max scaling.
minMaxScale(vec)
minMaxScale(vec)
vec |
vector of numbers to scale |
set.seed(1234) d <- runif(20,1,10) minMaxScale(d)
set.seed(1234) d <- runif(20,1,10) minMaxScale(d)
Export a copy of the oak phenotyping data collection spreadsheet.
phenotypingTemplate(path = ".")
phenotypingTemplate(path = ".")
path |
directory path for export output |
## Not run: phenotypingTemplate() ## End(Not run)
## Not run: phenotypingTemplate() ## End(Not run)
Process parsed phenotype data sheets into a tibble suitable for random forest analysis.
preparePhenotypeData(phenotypeData)
preparePhenotypeData(phenotypeData)
phenotypeData |
parsed phenotype data collection sheet returned from |
library(dplyr) ## Retrieve file paths for example data files <- list.files(system.file('phenotypeDataCollectionSheets', package = 'pdi'),full.names = TRUE) ## Prepare data d <- map(files,readPhenotypeSheet) %>% map(preparePhenotypeData)
library(dplyr) ## Retrieve file paths for example data files <- list.files(system.file('phenotypeDataCollectionSheets', package = 'pdi'),full.names = TRUE) ## Prepare data d <- map(files,readPhenotypeSheet) %>% map(preparePhenotypeData)
Parse .xlsx phenotype data collection sheets.
readPhenotypeSheet(file)
readPhenotypeSheet(file)
file |
file path to excel file to parse |
library(dplyr) ## Retrieve file paths for example data files <- list.files(system.file('phenotypeDataCollectionSheets', package = 'pdi'),full.names = TRUE) ## Prepare data d <- readPhenotypeSheet(files[1])
library(dplyr) ## Retrieve file paths for example data files <- list.files(system.file('phenotypeDataCollectionSheets', package = 'pdi'),full.names = TRUE) ## Prepare data d <- readPhenotypeSheet(files[1])
Perform random forest repetitions.
rf(analysisTable, cls, params = list(), nreps = 100, seed = 1234)
rf(analysisTable, cls, params = list(), nreps = 100, seed = 1234)
analysisTable |
tibble of phenotype data suitable for random forest analysis as returned by |
cls |
analysisTable column to use as response vector. NULL for unsupervised analyses. |
params |
additional arguments to pass to randomForest::randomForest |
nreps |
number of repetitions |
seed |
random number seed |
library(dplyr) ## Retrieve file paths for example data files <- list.files(system.file('phenotypeDataCollectionSheets', package = 'pdi'),full.names = TRUE) ## Prepare data d <- map(files,readPhenotypeSheet) %>% map(preparePhenotypeData) %>% bind_rows() %>% siteAdjustment() %>% mutate(`Live crown ratio (%)` = liveCrownRatio(`Total height (m)`, `Lower crown height (m)`), `Crown condition (%)` = crownCondition(`Missing crown (%)`, `Crown transparency (%)`), `Crown volume (m^3)` = crownVolume(`Crown radius (m)`, `Total height (m)`, `Lower crown height (m)`, `Crown condition (%)`), `Bleed prevalence (%)` = bleedPrevalence(`Active bleed length (mm)`, `Active bleeds`, `Black staining length (mm)`, `Black staining`, `Diameter at breast height (m)`), `Agrilus exit hole density (m^-2)` = agrilusExitHoleDensity(`Agrilus exit holes`, `Diameter at breast height (m)`) ) t <- makeAnalysisTable(d) ## Generate random forest models m <- rf(t,cls = NULL,nreps = 10)
library(dplyr) ## Retrieve file paths for example data files <- list.files(system.file('phenotypeDataCollectionSheets', package = 'pdi'),full.names = TRUE) ## Prepare data d <- map(files,readPhenotypeSheet) %>% map(preparePhenotypeData) %>% bind_rows() %>% siteAdjustment() %>% mutate(`Live crown ratio (%)` = liveCrownRatio(`Total height (m)`, `Lower crown height (m)`), `Crown condition (%)` = crownCondition(`Missing crown (%)`, `Crown transparency (%)`), `Crown volume (m^3)` = crownVolume(`Crown radius (m)`, `Total height (m)`, `Lower crown height (m)`, `Crown condition (%)`), `Bleed prevalence (%)` = bleedPrevalence(`Active bleed length (mm)`, `Active bleeds`, `Black staining length (mm)`, `Black staining`, `Diameter at breast height (m)`), `Agrilus exit hole density (m^-2)` = agrilusExitHoleDensity(`Agrilus exit holes`, `Diameter at breast height (m)`) ) t <- makeAnalysisTable(d) ## Generate random forest models m <- rf(t,cls = NULL,nreps = 10)
Perform a site adjustment of selected descriptors.
siteAdjustment( phenoData, descriptors = c("Diameter at breast height (m)", "Lower crown height (m)", "Timber height (m)", "Total height (m)", "Crown radius (m)") )
siteAdjustment( phenoData, descriptors = c("Diameter at breast height (m)", "Lower crown height (m)", "Timber height (m)", "Total height (m)", "Crown radius (m)") )
phenoData |
phenoData tibble containing phenotype data |
descriptors |
columns of phenoData on which to perform site correction |
library(dplyr) ## Retrieve file paths for example data files <- list.files(system.file('phenotypeDataCollectionSheets', package = 'pdi'),full.names = TRUE) ## Prepare data d <- map(files,readPhenotypeSheet) %>% map(preparePhenotypeData) %>% bind_rows() %>% siteAdjustment()
library(dplyr) ## Retrieve file paths for example data files <- list.files(system.file('phenotypeDataCollectionSheets', package = 'pdi'),full.names = TRUE) ## Prepare data d <- map(files,readPhenotypeSheet) %>% map(preparePhenotypeData) %>% bind_rows() %>% siteAdjustment()
Return site adjustment factors of selected phenotypic descriptors.
siteAdjustmentFactors( phenoData, descriptors = c("Diameter at breast height (m)", "Lower crown height (m)", "Timber height (m)", "Total height (m)", "Crown radius (m)") )
siteAdjustmentFactors( phenoData, descriptors = c("Diameter at breast height (m)", "Lower crown height (m)", "Timber height (m)", "Total height (m)", "Crown radius (m)") )
phenoData |
phenoData tibble containing phenotype data |
descriptors |
columns of phenoData on which calculate site correction factors |
library(dplyr) ## Retrieve file paths for example data files <- list.files(system.file('phenotypeDataCollectionSheets', package = 'pdi'),full.names = TRUE) ## Prepare data d <- map(files,readPhenotypeSheet) %>% map(preparePhenotypeData) %>% bind_rows() %>% siteAdjustment() sa_factors <- siteAdjustmentFactors(d)
library(dplyr) ## Retrieve file paths for example data files <- list.files(system.file('phenotypeDataCollectionSheets', package = 'pdi'),full.names = TRUE) ## Prepare data d <- map(files,readPhenotypeSheet) %>% map(preparePhenotypeData) %>% bind_rows() %>% siteAdjustment() sa_factors <- siteAdjustmentFactors(d)