A_06_Predictors_phylogenetic_metrics.R

A - 06: Calculate phylogenetic distinctiveness

Source 00_Configuration.R

Code
source(here::here("Code/00_Configuration.R"))
x <- lapply(package_list, require, character = TRUE)
rm(x)

tax_path <-
  here("Data/input/Tax_lookup.csv")

Read tree and taxonomic data

Code
Tax <-
  read_csv(tax_path)

tree <-
  ape::read.tree(
  here::here("Data/input/MRC_consensus_BirdTree.tre"))

Calculate phylogenetic distinctiveness

Code
pd <-
  phyloregion::evol_distinct(
  tree,
  type = "fair.proportion",
  scale = FALSE,
  use.branch.lengths = TRUE) %>%
  as.data.frame() %>%
  tibble::rownames_to_column(var = "tip.label") %>%
  rename(pd = ".") %>%
  right_join(Tax) %>%
  select(verbatimIdentification, scientificName, pd)

Checks:

Code
pd %>% skimr::skim()
Data summary
Name Piped data
Number of rows 890
Number of columns 3
_______________________
Column type frequency:
character 2
numeric 1
________________________
Group variables None

Variable type: character

skim_variable n_missing complete_rate min max empty n_unique whitespace
verbatimIdentification 0 1 9 32 0 762 0
scientificName 0 1 9 39 0 726 0

Variable type: numeric

skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
pd 9 0.99 8.18 6.17 1.11 4.38 6.24 9.55 56.96 ▇▁▁▁▁

Save results to .rds

Code
# eval: false
saveRDS(pd,
        here::here("Data/output/A_predictors/Phylo_distinct.rds"))