# to install the package 'plotsdatabase'
# make sure you are running recent R version

devtools::install_github("gdauby/bdd_plots_central_africa")
## if the installation above failed, it may be because your timeout is too low
## you can increase the timeout by using the following code
options(timeout = 1000)


library(tidyverse)
library(plotsdatabase) ## R package for exploring the database
packageVersion("plotsdatabase")
## [1] '0.1.4.31'

Extract data from the database

Concerning observatories, taxonomic and traits data are stored and managed in this database. Phenological characterization and spatial vectors linked to each tree (crown polygons) are managed trough the Shiny apps.

Data are stored in a postrgresql relational database and are available with several ‘query’ functions using an R package and a proper password and login name (ask Gilles).

Data is subject to evolve regularly : new data can be added and taxonomic identification can be updated.

Extract datasets for mbalmayo and bouamir observatories.

tree_data <-
  query_plots(
    locality_name = c("Bouamir", "Mbalmayo"),
    method = c("1ha-IRD", "phenological_observatory"),
    extract_individuals = TRUE,
    remove_ids = F
  )

meta_data <- 
    query_plots(
    locality_name = c("Bouamir", "Mbalmayo"), 
    method = c("1ha-IRD", "phenological_observatory"),
    remove_ids = F,
  )

Query all features (including traits) linked to an individual of the observatory. A feature can be anything (including traits but not only).

### export all features linked to an individual

all_traits_features <-
  query_individual_features(
    id = tree_data$id_n,
    pivot_table = FALSE,
    extract_trait_measures_features = TRUE
  )
## ! Individual features queried by chunks because of large number of values

Explore and rearrange the dataset

Number of trees, plots and observatories

tree_data %>% 
  left_join(meta_data %>% select(plot_name, method)) %>% 
  group_by(plot_name, method, locality_name) %>% 
  count() %>% 
  ungroup() %>% 
  group_by(method) %>% 
  summarise(nbe_plot = n(),
            nbe_individual = sum(n),
            nbe_min_individual = min(n),
            nbe_max_individual = max(n)) %>% 
  gt::gt() %>% 
   gt::cols_label(
     nbe_individual = "Total number of tree",
    nbe_min_individual = "Minimum number of tree per inventory"
  )
## Joining with `by = join_by(plot_name)`
method nbe_plot Total number of tree Minimum number of tree per inventory nbe_max_individual
1ha-IRD 25 11921 373 623
phenological_observatory 2 6621 2053 4568

The outputs of query_individual_features is a list that splits features into character values and numeric values. Character values concern observations done in the field. Numerical values include traits, among others.

# print(all_traits_features)

### count number of values for all numerical features
all_features_num <- all_traits_features$traits_num[[1]]

list_features_num <-
  all_features_num %>%
  group_by(trait, id_trait) %>%
  count()


### all character features
all_features_char <- all_traits_features$traits_char[[1]]
list_features_num %>% 
  ungroup() %>% 
  arrange(desc(n)) %>% 
  rename('number of values' = n) %>% 
  gt::gt()
trait id_trait number of values
stem_diameter 1 20731
height_of_stem_diameter 2 20369
centroid_ddlat 66 3402
centroid_ddlon 67 3402
crown_area 68 3400
mesophyl_thickness 36 2367
SPAD_chlorophyll_measurement 35 2355
lma_lamina 55 1899
lma_mesophyll 53 1894
leaf_area 5 1870
lma_whole_leaf 57 1753
whole_leaf_area 59 1752
position_x 39 1641
position_y 40 1641
leaf_structure_mass_area 62 1599
tree_height 3 1154
lamina_length 60 556
lamina_width 61 556
leaf_C_percentage 86 550
leaf_N_percentage 85 550
leaf_delta_carbon_13 87 550
twig_specific_gravity 9 422
height_of_first_branch 11 176
total_chlorophyll_content 76 152

Checklist of traits and features and their definition

all_feat_database <- traits_list()


all_feat_database <- 
  all_feat_database %>% 
  filter(grepl("lma_", trait) |
         trait == "twig_specific_gravity"|
         trait == "leaf_area"|
         trait == "SPAD_chlorophyll_measurement"|
         trait == "mesophyl_thickness"|
         trait == "whole_leaf_area"|
         trait == "leaf_structure_mass_area"|
         trait == "total_chlorophyll_content"|
         trait == "leaf_delta_carbon_13"|
         trait == "leaf_N_percentage"|
         trait == "leaf_C_percentage"|
         trait == "leaf_C_percentage")

list_features_num <- 
  list_features_num %>% 
  filter(id_trait %in% all_feat_database$id_trait)

features_meta_data <- 
  all_feat_database %>% 
  filter(id_trait %in% list_features_num$id_trait)

all_features_num <- 
  all_features_num %>% 
  filter(id_trait %in% list_features_num$id_trait)
trait id_trait traitdescription maxallowedvalue minallowedvalue expectedunit valuetype
leaf_area 5 Leaf area (in case of compound leaves: leaflet, petiole excluded) 750 0.0 cm2 numeric
twig_specific_gravity 9 Ratio of twig dry mass to twig fresh volume 100 0.0 g/cm3 numeric
SPAD_chlorophyll_measurement 35 SPAD raw measurment 200 0.1 none numeric
mesophyl_thickness 36 Mesophyl thickness 5 0.0 mm numeric
lma_mesophyll 53 Leaf mass per area based on punches collected from the mesophyll avoiding when possible first and second order venation 1000 0.0 g/m² numeric
whole_leaf_area 59 Whole leaf area, including petiole and rachis 1000 0.0 cm² numeric
leaf_structure_mass_area 62 Leaf mass per area only including structural organs (petiole and rachis) 50000 0.0 g/m² numeric
total_chlorophyll_content 76 Total chlorophyll content per leaf mass 300 0.0 ug/g numeric
lma_whole_leaf 57 Leaf mass per area based on whole leaf (include petiole and rachis) 1000 0.0 g/m² numeric
lma_lamina 55 Leaf mass per area based lamina photoynthetic unit (leaflet for compound leaves) 1000 0.0 g/m² numeric
leaf_delta_carbon_13 87 Stable carbon isotope ratio in leaf material 0 -40.0 per_mill numeric
leaf_N_percentage 85 Nitrogen percentage in leaf material 100 0.0 percentage numeric
leaf_C_percentage 86 Carbon percentage in leaf material 100 0.0 percentage numeric

How traits are collected in the field and metada are associated

Each set of traits measured on a tree in an observatory is associated with a unique number pheno_tree_nbr which is incremental.

Thus, each pheno_tree_nbr is linked to a tree, to trait measurements, to any observations/remarks on these measurements (for example the id of the leaf, because leaf traits are measured for at least 3 leaves), to any axillary measures used for the measurements (for example the area of the leaf for leaf mass per area measurements), to people involved in the measurements and to the date of measurement.

See one measurement

all_traits %>%
  slice(2000) %>% 
  select(
    id_trait_measures,
    id_trait,
    trait,
    traitvalue,
    colnbr,
    leaf_id,
    leaf_maturity,
    cohort_id,
    colnam,
    whole_leaf_area,
    tag,
    plot_name,
    day, 
    month,
    year
  ) %>% 
  gt::gt()
id_trait_measures id_trait trait traitvalue colnbr leaf_id leaf_maturity cohort_id colnam whole_leaf_area tag plot_name day month year
1015699 57 lma_whole_leaf 187.52 290 4 mature 2 Vincent Pearlstein|Bidima Emmanuel 11.41239 870 mbalmayo_pheno_observatory 25 3 2024

A glimpse into the raw dataset

colnbr voucher_type tag tax_sp_level leaf_id day month year measurementremarks measurementmethod trait traitvalue colnam cohort_id leaf_maturity
142 phenotree 128 Ongokea gore 4 8 12 2023 leaf_id_4, weight_dry_0.01 g, area_2.9e-05 m², cohort 2, organs_ petiole Include petiole and rachis leaf_structure_mass_area 345.21 Gilles Dauby|Bidima Emmanuel|Yvan Ndjock NaN NA
142 phenotree 128 Ongokea gore 4 NA 12 2023 leaf_id 4, Cohort 2 Average of three measurements across lamina SPAD_chlorophyll_measurement 82.30 Gilles Dauby|Bidima Emmanuel|Yvan Ndjock 2 NA
142 phenotree 128 Ongokea gore 5 NA 12 2023 leaf_id 5, Cohort 2 Average of three measurements across lamina mesophyl_thickness 0.34 Gilles Dauby|Bidima Emmanuel|Yvan Ndjock 2 NA
142 phenotree 128 Ongokea gore 5 8 12 2023 leaf_id_5, weight_dry_0.281 g, area_0.002408 m², cohort 2 Based on one leaf or leaflet (the smallest lamina unit) lma_lamina 116.69 Gilles Dauby|Bidima Emmanuel|Yvan Ndjock NaN NA
142 phenotree 128 Ongokea gore 5 8 12 2023 leaf_id_5, punch_diameter_12 m, Number_punches_2, weight_dry_0.026 g, area0.000226 m², cohort 2 Punches in mesophyll avoiding first and second order nervation when possible lma_mesophyll 114.95 Gilles Dauby|Bidima Emmanuel|Yvan Ndjock NaN NA
142 phenotree 128 Ongokea gore 5 8 12 2023 leaf_id_5, weight_dry_0.321 g, area_0.002677 m², cohort 2 Include petiole and rachis lma_whole_leaf 119.92 Gilles Dauby|Bidima Emmanuel|Yvan Ndjock NaN NA
142 phenotree 128 Ongokea gore 5 8 12 2023 leaf_id_5, weight_dry_0.321 g, area_0.002677 m², cohort 2 Include petiole and rachis whole_leaf_area 26.77 Gilles Dauby|Bidima Emmanuel|Yvan Ndjock NaN NA
142 phenotree 128 Ongokea gore 5 8 12 2023 leaf_id_5, cohort 2 Area of leaves of leaflet without petiole or rachis leaf_area 24.08 Gilles Dauby|Bidima Emmanuel|Yvan Ndjock NaN NA
142 phenotree 128 Ongokea gore 5 8 12 2023 leaf_id_5, cohort 2 Area of leaves of leaflet without petiole or rachis leaf_area 24.08 Gilles Dauby|Bidima Emmanuel|Yvan Ndjock NaN NA
142 phenotree 128 Ongokea gore 5 8 12 2023 leaf_id_5, weight_dry_0.014 g, area_4.2e-05 m², cohort 2, organs_ petiole Include petiole and rachis leaf_structure_mass_area 329.57 Gilles Dauby|Bidima Emmanuel|Yvan Ndjock NaN NA
142 phenotree 128 Ongokea gore 5 NA 12 2023 leaf_id 5, Cohort 2 Average of three measurements across lamina SPAD_chlorophyll_measurement 75.20 Gilles Dauby|Bidima Emmanuel|Yvan Ndjock 2 NA

Arranging the data into columns

## retrieving information associated to each leaf : maturity and cohort when available
leaves_data <- 
  all_traits %>% 
  group_by(colnbr, voucher_type, leaf_id) %>% 
  summarise(leaf_maturity = first(leaf_maturity, na_rm = T),
            cohort_id = first(cohort_id, na_rm = T)) %>% 
  filter(!is.na(leaf_id)) %>% 
  ungroup()

## re arrangin the data in columns
# each trait columns will start with a prefix 't_' that help selection
all_traits_wide <-
  all_traits %>%
  select(
    id_data_individuals,
    id_trait_measures,
    colnbr,
    voucher_type,
    leaf_id,
    tag,
    plot_name,
    tax_sp_level,
    tax_gen,
    trait,
    traitvalue,
    day,
    month,
    year
  ) %>%
  pivot_wider(names_from = trait, 
              values_from = traitvalue,
              names_prefix = "t_")


traits_leaf_level <-
  all_traits_wide %>%
  group_by(voucher_type ,
           colnbr,
           leaf_id,
           tag,
           tax_sp_level,
           id_data_individuals,
           plot_name) %>%
  summarise(across(starts_with("t_"), ~ mean(., na.rm = T)), plot_name = first(plot_name)) %>%
  left_join(leaves_data) %>%
  ungroup()


traits_leaf_level_averaged <-
  traits_leaf_level %>%
  group_by(voucher_type,
           colnbr,
           tag,
           tax_sp_level,
           cohort_id,
           leaf_maturity) %>%
  summarise(across(starts_with("t_"), ~ mean(., na.rm = T)), plot_name = first(plot_name))

Quantile-quantile plots

ggqq_plots <- ggplot(data = all_traits, 
       mapping = aes(sample = traitvalue, 
                     colour = trait)) +
  stat_qq() +
  stat_qq_line() +
  facet_wrap(~ trait, scales = "free") +
  guides(colour = "none")

ggqq_plots

Leaf level

Leaf Mass Per Area

All leaves.

gg_lma1 <- 
  ggplot() +
  geom_point(data = traits_leaf_level, 
             mapping = aes(x = t_lma_mesophyll, 
                           y = t_lma_whole_leaf,
                           color = tax_sp_level,
                           shape = leaf_maturity)) +
  geom_abline(slope = 1, intercept = 0) + 
  scale_x_continuous(trans='log10') + 
  scale_y_continuous(trans='log10') +
  xlab(label = "log10(lma mesophyll scale)") +
  ylab(label = "log10(lma whole leaf scale)") +
  guides(color = "none")

plotly::ggplotly(gg_lma1)

Averaging across leaves per cohort.

gg_lma1 <- 
  ggplot() +
  geom_point(data = traits_leaf_level_averaged, 
             mapping = aes(x = t_lma_mesophyll, 
                           y = t_lma_whole_leaf,
                           color = tax_sp_level,
                           shape = leaf_maturity)) +
  geom_abline(slope = 1, intercept = 0) + 
  scale_x_continuous(trans='log10') + 
  scale_y_continuous(trans='log10') +
  xlab(label = "log10(lma mesophyll scale)") +
  ylab(label = "log10(lma whole leaf scale)") +
  guides(color = "none")

plotly::ggplotly(gg_lma1)
gg_lma2 <- 
  ggplot() +
  geom_point(data = traits_leaf_level, 
             mapping = aes(x = t_lma_lamina, 
                           y = t_lma_whole_leaf,
                           color = tax_sp_level,
                           shape = leaf_maturity)) +
  geom_abline(slope = 1, intercept = 0) + 
  scale_x_continuous(trans='log10') + 
  scale_y_continuous(trans='log10') +
  xlab(label = "log10(lma lamina scale)") +
  ylab(label = "log10(lma whole leaf scale)") +
  guides(color = "none")


plotly::ggplotly(gg_lma2)

Averaging across leaves per cohort.

gg_lma2 <- 
  ggplot() +
  geom_point(data = traits_leaf_level_averaged, 
             mapping = aes(x = t_lma_lamina, 
                           y = t_lma_whole_leaf,
                           color = tax_sp_level,
                           shape = leaf_maturity)) +
  geom_abline(slope = 1, intercept = 0) + 
  scale_x_continuous(trans='log10') + 
  scale_y_continuous(trans='log10') +
  xlab(label = "log10(lma lamina scale)") +
  ylab(label = "log10(lma whole leaf scale)") +
  guides(color = "none")


plotly::ggplotly(gg_lma2)
gg_lma3 <- 
  ggplot() +
  geom_point(data = traits_leaf_level, 
             mapping = aes(x = t_lma_lamina, 
                           y = t_mesophyl_thickness,
                           color = tax_sp_level,
                           shape = leaf_maturity)) +
  scale_x_continuous(trans='log10') + 
  scale_y_continuous(trans='log10') +
  xlab(label = "log10(lma lamina scale)") +
  ylab(label = "log10(mesophyl_thickness)") +
  guides(color = "none")


plotly::ggplotly(gg_lma3)
gg_lma4 <- 
  ggplot() +
  geom_point(data = traits_leaf_level, 
             mapping = aes(x = t_lma_lamina, 
                           y = t_leaf_structure_mass_area,
                           color = tax_sp_level,
                           shape = leaf_maturity)) +
  scale_x_continuous(trans='log10') + 
  scale_y_continuous(trans='log10') +
  xlab(label = "log10(lma lamina scale)") +
  ylab(label = "log10(leaf_structure_mass_area)") +
  guides(color = "none")


plotly::ggplotly(gg_lma4)

Ratio of LMA at mesophyl scale and LMA at the whole leaf scale

Can we express this ratio as a proxy of construction costs to non photosynthetic tissues ?

LMA_ratios <- 
  traits_leaf_level %>%
  select(
    starts_with("t_lma"),
    leaf_id,
    colnbr,
    voucher_type,
    tax_sp_level,
    cohort_id,
    leaf_maturity,
    t_leaf_area,
    t_whole_leaf_area, 
    t_leaf_C_percentage
  ) %>%
  mutate(
    ratio_lma_lamina_meso =
      round((t_lma_lamina - t_lma_mesophyll) / t_lma_lamina * 100, 1),
    ratio_lma_whole_lamina =
      round((t_lma_whole_leaf - t_lma_lamina) / t_lma_whole_leaf * 100, 1),
    ratio_lma_whole_meso =
      round((t_lma_whole_leaf - t_lma_mesophyll) / t_lma_whole_leaf * 100, 1)
  ) %>%
  group_by(cohort_id, colnbr) %>% ### averaged across leaves per cohort
  summarise(
    across(starts_with("ratio_lma"), ~ round(mean(., na.rm = T), 1)),
    across(starts_with("t_lma"), ~ round(mean(., na.rm = T), 1)),
    tax_sp_level = first(tax_sp_level),
    leaf_maturity = first(leaf_maturity),
    t_leaf_area = mean(t_leaf_area, na.rm = T),
    t_whole_leaf_area = mean(t_whole_leaf_area, na.rm = T),
    t_leaf_C_percentage = mean(t_leaf_C_percentage, na.rm = T)
  ) %>%
  filter(!is.na(ratio_lma_whole_meso)) %>% 
  ungroup()
## `summarise()` has grouped output by 'cohort_id'. You can override using the
## `.groups` argument.

How this ratio correlates with leaf area.

gg_lma4 <- 
  ggplot() +
  geom_point(data = LMA_ratios, 
             mapping = aes(x = t_whole_leaf_area , 
                           y = ratio_lma_whole_meso,
                           color = tax_sp_level,
                           shape = leaf_maturity)) +
  scale_x_continuous(trans='log10') + 
  xlab(label = "log10(whole leaf area)") +
  ylab(label = "Ratio LMA mesophyl/LMA whole leaf") +
  guides(color = "none")


plotly::ggplotly(gg_lma4)

How this ratio correlates with leaf C carbon.

gg_lma4 <- 
  ggplot() +
  geom_point(data = LMA_ratios, 
             mapping = aes(x = t_leaf_C_percentage , 
                           y = ratio_lma_whole_meso,
                           color = tax_sp_level,
                           shape = leaf_maturity)) +
  scale_x_continuous(trans='log10') + 
  xlab(label = "log10(leaf C content)") +
  ylab(label = "Ratio LMA mesophyl/LMA whole leaf") +
  guides(color = "none")


plotly::ggplotly(gg_lma4)

Nitrogen content and LMA

The whole dataset

gg_lma2 <- 
  ggplot() +
  geom_point(data = traits_leaf_level, 
             mapping = aes(x = t_lma_mesophyll, 
                           y = t_leaf_N_percentage,
                           color = tax_sp_level,
                           shape = leaf_maturity)) +
  geom_abline(slope = 1, intercept = 0) + 
  scale_x_continuous(trans='log10') + 
  scale_y_continuous(trans='log10') +
  xlab(label = "log10(lma mesophyl scale)") +
  ylab(label = "log10(Nitrogen content)") +
  guides(color = "none")


plotly::ggplotly(gg_lma2)

Within species

## select the four most sampled species
selected_sp <- 
  traits_leaf_level %>% 
  filter(!is.na(tax_sp_level)) %>% 
  group_by(tax_sp_level) %>% 
  count() %>% 
  arrange(desc(n))%>% 
  ungroup() %>% 
  slice(1:4)

dataset_filtered <- 
  traits_leaf_level %>% 
  filter(tax_sp_level %in% selected_sp$tax_sp_level) %>% 
  mutate(leaf_maturity = replace_na(leaf_maturity, "unkown")) %>% 
  group_by(leaf_id, colnbr, tax_sp_level, voucher_type) %>% 
  summarise(t_lma_mesophyll = mean(t_lma_mesophyll, na.rm = T),
            t_leaf_N_percentage = mean(t_leaf_N_percentage, na.rm = T),
            leaf_maturity = first(leaf_maturity, na_rm = T)) %>% 
  filter(!is.na(t_lma_mesophyll),
         !is.na(t_leaf_N_percentage))

gg_w <- 
  ggplot(data = dataset_filtered,
         aes(x = t_lma_mesophyll, 
             y = t_leaf_N_percentage, 
             color = tax_sp_level,
             shape = leaf_maturity)) +
    geom_point() + 
  scale_x_continuous(trans='log10') + 
  scale_y_continuous(trans='log10') +                      
  geom_smooth(method = "lm", 
                se = FALSE, 
                mapping = aes(group = tax_sp_level)) + 
    labs(title = "Within-species", 
         x = "log(LMA mesophyll scale)", 
         y = "log(N content per dry mass (%))") +
    theme_minimal()
  

plotly::ggplotly(gg_w)

Carbon content and LMA

gg_lma2 <- 
  ggplot() +
  geom_point(data = traits_leaf_level, 
             mapping = aes(x = t_lma_mesophyll, 
                           y = t_leaf_C_percentage,
                           color = tax_sp_level,
                           shape = leaf_maturity)) +
  scale_x_continuous(trans='log10') + 
  scale_y_continuous(trans='log10') +
  xlab(label = "log10(lma mesophyl scale)") +
  ylab(label = "log10(Carbon content)") +
  guides(color = "none")


plotly::ggplotly(gg_lma2)

Total chlorophyll content and SPAD measurement

measurementmethod measurementremarks
maceration 50mg of leaf sample in 80% Acetone, centrifuging and spectrophotometric reading of absorbances at the various wavelengths to determine chlorophyll a and b Measures were done on silica-dried samples in the field. Lab work was done at IITA under the supervision of Rose Ndango
gg1 <- ggplot() +
  geom_point(data = traits_leaf_level, 
             mapping = aes(x = t_total_chlorophyll_content, 
                           y = t_SPAD_chlorophyll_measurement, 
                           color = tax_sp_level,
                           fill = tax_sp_level,
                           shape = leaf_maturity)) +
  guides(color = "none",
         fill = "none",
         shape = "none")

plotly::ggplotly(gg1)

Total chlorophyll content and Nitrogen content

gg1 <- ggplot() +
  geom_point(data = traits_leaf_level, 
             mapping = aes(x = t_total_chlorophyll_content, 
                           y = t_leaf_N_percentage, 
                           color = tax_sp_level,
                           fill = tax_sp_level,
                           shape = leaf_maturity)) +
  guides(color = "none",
         fill = "none",
         shape = "none")

plotly::ggplotly(gg1)

Total chlorophyll content and stable delta 13C isotope

gg1 <- ggplot() +
  geom_point(data = traits_leaf_level, 
             mapping = aes(x = t_total_chlorophyll_content, 
                           y = t_leaf_delta_carbon_13, 
                           color = tax_sp_level,
                           fill = tax_sp_level,
                           shape = leaf_maturity)) +
  guides(color = "none",
         fill = "none",
         shape = "none")

plotly::ggplotly(gg1)

Species level

Grouping by species

colnbr_per_sp <-
  traits_leaf_level %>%
  filter(leaf_maturity != "immature" |
           is.na(leaf_maturity)) %>%  ## excluding immature leaf for species level
  group_by(voucher_type, colnbr, tag, id_data_individuals, plot_name) %>%
  summarise(
    tax_sp_level = first(tax_sp_level),
    across(starts_with("t_"), ~ mean(., na.rm = TRUE)),
    plot_name = first(plot_name)
  )
## `summarise()` has grouped output by 'voucher_type', 'colnbr', 'tag',
## 'id_data_individuals'. You can override using the `.groups` argument.
traits_taxa <-
  colnbr_per_sp %>%
  group_by(tax_sp_level) %>%
  summarise(nbe_voucher = n(), across(starts_with("t_"), ~ mean(., na.rm = TRUE))) %>%
  left_join(LMA_ratios %>% 
  group_by(tax_sp_level) %>% 
  summarise(t_ratio_lma_whole_meso = mean(ratio_lma_whole_meso, na.rm = T))) %>% 
  filter(!grepl("indet", tax_sp_level))
## Joining with `by = join_by(tax_sp_level)`
traits_taxa_sel <-
  traits_taxa %>%
  select(
    tax_sp_level,
    t_lma_lamina,
    t_lma_mesophyll,
    t_lma_whole_leaf,
    t_mesophyl_thickness,
    t_SPAD_chlorophyll_measurement,
    t_leaf_area,
    t_leaf_structure_mass_area,
    t_twig_specific_gravity,
    t_leaf_N_percentage,
    t_leaf_C_percentage,
    t_ratio_lma_whole_meso
  ) %>%
  mutate(lma = ifelse(is.na(t_lma_lamina), t_lma_mesophyll, t_lma_lamina)) %>% ## taking lma mesophyll if no lma lamina available
  mutate(lma = ifelse(is.na(lma), t_lma_whole_leaf, lma)) %>% ## taking lma whole leaf if no lma mesophyll available
  select(-starts_with("t_lma")) %>% 
  rename(t_lma = lma)

Get maximum diameter values for all species

all_diameters <-
  query_individual_features(id_traits = 1,  ## id of the stem_diameter
                            pivot_table = FALSE,
                            extract_linked_individuals = TRUE)

## extract all values
all_values <-
  all_diameters$traits_num[[1]]

linked_individuals <-
  all_diameters$ind_data %>% select(id_n, idtax_individual_f, tax_sp_level, tax_fam)

## Get the maximum and the percentile 95 of stem_diameter for all species
taxa_level_stem_diameters <-
  all_values %>%
  select(traitvalue, id_data_individuals) %>%
  left_join(
    linked_individuals,
    by = c("id_data_individuals" = "id_n")
  ) %>%
  filter(!is.na(idtax_individual_f)) %>%
  group_by(id_data_individuals) %>% ### if more than one diameter value linked to an individual, take the maximal value. This happens if the individual has been censused more than once.
  summarise(
    tax_sp_level = first(tax_sp_level),
    tax_fam = first(tax_fam),
    traitvalue = max(traitvalue)
  ) %>%
  group_by(tax_sp_level, tax_fam) %>% ### summary by species
  summarise(
    max_stem_diameter = max(traitvalue), ## take the highest recorded value
    t_dbh_095 = quantile(traitvalue, 0.95), ## take the percentile 0.95
    nbe_values = n() ## number of values
  ) %>% 
  filter(!is.na(tax_sp_level))
## `summarise()` has grouped output by 'tax_sp_level'. You can override using the
## `.groups` argument.
traits_taxa_sel <- 
  traits_taxa_sel %>% 
  left_join(taxa_level_stem_diameters %>% 
              select(t_dbh_095, tax_sp_level),
            by = c("tax_sp_level" = "tax_sp_level"))

Quantile-quantile plots

traits_taxa_sel_pivot <- 
  traits_taxa_sel %>% 
  pivot_longer(cols = starts_with("t_"), names_to = "trait") %>% 
  filter(!is.na(value))

ggqq_plots <- ggplot(data = traits_taxa_sel_pivot, 
       mapping = aes(sample = value, 
                     colour = trait)) +
  stat_qq() +
  stat_qq_line() +
  facet_wrap(~ trait, scales = "free") +
  guides(colour = "none")


ggqq_plots

PCA leaves economic spectra

traits_taxa_sel_filtered <- 
  traits_taxa_sel %>%
  select(-t_twig_specific_gravity, 
         -t_dbh_095, 
         -t_leaf_structure_mass_area) %>% 
  rename(ratio_lma_whole_meso = t_ratio_lma_whole_meso) %>% 
  rowwise() %>%
  filter(!any(is.na(c_across(where( ### keeping onlue species where all traits are available
    is.numeric
  ))))) %>%
  mutate(across(starts_with("t_"), ~ log10(.x))) %>% ## log transformation
  ungroup() %>% 
  rename(t_ratio_lma_whole_meso = ratio_lma_whole_meso)

pca_res <- dudi.pca(
  df = traits_taxa_sel_filtered %>% select(where(is.numeric)),
  scannf = FALSE,
  nf = 2,
  center = TRUE
)

pca_res_tax <- tibble(tax_sp_level = traits_taxa_sel_filtered$tax_sp_level,
                      rs1 = pca_res$li$Axis1,
                      rs2 = pca_res$li$Axis2)

env_scores <- tibble(var = rownames(pca_res$c1), 
                     rs1 = pca_res$c1$CS1, rs2 = pca_res$c1$CS2)

pca_1 <- ggplot() +
  geom_point(
    data = pca_res_tax,
    mapping = aes(x = rs1, y = rs2,
                  colour = tax_sp_level)
  ) +
  ggrepel::geom_text_repel(
    data = pca_res_tax,
    aes(x = rs1, y = rs2, label = tax_sp_level),
    size = 3,
    color = "black"
  ) +
  geom_segment(
    data = env_scores,
    aes(
      x = 0,
      y = 0,
      xend = rs1,
      yend = rs2
    ),
    arrow = arrow(length = unit(0.2, "cm"))
  ) +
  ggrepel::geom_text_repel(
    data = env_scores,
    aes(x = rs1, y = rs2, label = var),
    size = 4,
    color = "red"
  ) +
  geom_hline(yintercept = 0, linetype = "dashed") +
  geom_vline(xintercept = 0, linetype = "dashed") +
  guides(colour = "none")

pca_1

traits_taxa_sel_filtered <- 
  traits_taxa_sel %>%
  select(-t_twig_specific_gravity, 
         -t_dbh_095, 
         -t_leaf_structure_mass_area,
         -t_leaf_C_percentage,
         -t_leaf_N_percentage) %>% 
  rename(ratio_lma_whole_meso = t_ratio_lma_whole_meso) %>% 
  rowwise() %>%
  filter(!any(is.na(c_across(where( ### keeping onlue species where all traits are available
    is.numeric
  ))))) %>%
  mutate(across(starts_with("t_"), ~ log10(.x))) %>% ## log transformation
  ungroup() %>% 
  rename(t_ratio_lma_whole_meso = ratio_lma_whole_meso)

pca_res <- dudi.pca(
  df = traits_taxa_sel_filtered %>% select(where(is.numeric)),
  scannf = FALSE,
  nf = 2,
  center = TRUE
)

pca_res_tax <- tibble(tax_sp_level = traits_taxa_sel_filtered$tax_sp_level,
                      rs1 = pca_res$li$Axis1,
                      rs2 = pca_res$li$Axis2)

env_scores <- tibble(var = rownames(pca_res$c1), 
                     rs1 = pca_res$c1$CS1, rs2 = pca_res$c1$CS2)

pca_1 <- ggplot() +
  geom_point(
    data = pca_res_tax,
    mapping = aes(x = rs1, y = rs2,
                  colour = tax_sp_level)
  ) +
  ggrepel::geom_text_repel(
    data = pca_res_tax,
    aes(x = rs1, y = rs2, label = tax_sp_level),
    size = 3,
    color = "black"
  ) +
  geom_segment(
    data = env_scores,
    aes(
      x = 0,
      y = 0,
      xend = rs1,
      yend = rs2
    ),
    arrow = arrow(length = unit(0.2, "cm"))
  ) +
  ggrepel::geom_text_repel(
    data = env_scores,
    aes(x = rs1, y = rs2, label = var),
    size = 4,
    color = "red"
  ) +
  geom_hline(yintercept = 0, linetype = "dashed") +
  geom_vline(xintercept = 0, linetype = "dashed") +
  guides(colour = "none")

pca_1

PCA including twig wood density

traits_taxa_sel_filtered <- 
  traits_taxa_sel %>%
  rowwise() %>%
  filter(!any(is.na(c_across(where( ### keeping onlue species where all traits are available
    is.numeric
  ))))) %>%
  mutate(across(where(is.numeric), ~ log10(.x))) %>% ## log transformation
  ungroup()

pca_res <- dudi.pca(df = traits_taxa_sel_filtered %>% select(where(is.numeric)), scannf = FALSE, nf = 2, center = TRUE)

pca_res_tax <- tibble(tax_sp_level = traits_taxa_sel_filtered$tax_sp_level,
                      rs1 = pca_res$li$Axis1,
                      rs2 = pca_res$li$Axis2)

env_scores <- tibble(var = rownames(pca_res$c1), 
                     rs1 = pca_res$c1$CS1, rs2 = pca_res$c1$CS2)

pca_1 <- ggplot() +
  geom_point(
    data = pca_res_tax,
    mapping = aes(x = rs1, y = rs2,
                  colour = tax_sp_level)
  ) +
  ggrepel::geom_text_repel(
    data = pca_res_tax,
    aes(x = rs1, y = rs2, label = tax_sp_level),
    size = 3,
    color = "black"
  ) +
  geom_segment(
    data = env_scores,
    aes(
      x = 0,
      y = 0,
      xend = rs1,
      yend = rs2
    ),
    arrow = arrow(length = unit(0.2, "cm"))
  ) +
  ggrepel::geom_text_repel(
    data = env_scores,
    aes(x = rs1, y = rs2, label = var),
    size = 4,
    color = "red"
  ) +
  geom_hline(yintercept = 0, linetype = "dashed") +
  geom_vline(xintercept = 0, linetype = "dashed") +
  guides(colour = "none")

pca_1

State of sampling per observatory

all_traits %>% 
  group_by(plot_name, trait) %>% 
  filter(grepl("_observatory", plot_name)) %>% 
  count() %>%
  pivot_wider(names_from = plot_name, 
              values_from = n) %>% 
  gt::gt()
bouamir_pheno_observatory mbalmayo_pheno_observatory
SPAD_chlorophyll_measurement
483 1019
leaf_C_percentage
74 476
leaf_N_percentage
74 476
leaf_area
297 655
leaf_delta_carbon_13
74 476
leaf_structure_mass_area
357 617
lma_lamina
366 824
lma_mesophyll
457 699
lma_whole_leaf
363 730
mesophyl_thickness
486 1011
twig_specific_gravity
90 134
whole_leaf_area
363 729
total_chlorophyll_content
NA 152
nbe_tree_sampled <- 
  traits_leaf_level %>% 
  filter(grepl("_observatory", plot_name)) %>% 
  group_by(plot_name, tag) %>% 
  count() %>% 
  ungroup() %>% 
  group_by(plot_name) %>% 
  summarise(nbe_tree_sampled = n())

colnbr_per_sp %>%
  filter(grepl("observatory", plot_name)) %>% 
  group_by(plot_name) %>%
  summarise(nbe_pheno_tree = n()) %>% 
  left_join(nbe_tree_sampled) %>% 
  gt::gt(caption = "Number of pheno_tree and tree sampled per observatory")
## Joining with `by = join_by(plot_name)`
Number of pheno_tree and tree sampled per observatory
plot_name nbe_pheno_tree nbe_tree_sampled
bouamir_pheno_observatory 114 114
mbalmayo_pheno_observatory 258 181
sampled_per_observatory <- 
  colnbr_per_sp %>% 
  filter(grepl("_observatory", plot_name)) %>% 
  group_by(plot_name, tax_sp_level) %>% 
  summarise(nbe_tree_sampled = n()) %>% 
  pivot_wider(names_from = plot_name, 
              values_from =  c(nbe_tree_sampled), 
              names_prefix = "sampled_")
## `summarise()` has grouped output by 'plot_name'. You can override using the
## `.groups` argument.
nbe_tree_obs <- 
  tree_data %>% 
  filter(grepl("observatory", plot_name)) %>% 
  filter(!is.na(tax_sp_level)) %>% 
  group_by(tax_sp_level, tax_fam) %>% 
  summarise(nbe_tree = n()) %>% 
  ungroup() %>% 
  mutate(plot_name = "total")
## `summarise()` has grouped output by 'tax_sp_level'. You can override using the
## `.groups` argument.
tree_data %>% 
  filter(grepl("_observatory", plot_name)) %>% 
  filter(!is.na(tax_sp_level)) %>% 
  group_by(tax_sp_level, tax_fam, plot_name) %>% 
  summarise(nbe_tree = n()) %>% 
  ungroup() %>% 
  bind_rows(nbe_tree_obs) %>% 
  pivot_wider(names_from = plot_name, 
              values_from =  c(nbe_tree)) %>% 
  left_join(sampled_per_observatory) %>% 
  relocate(contains("bouamir"), .after = where(is.character)) %>% 
  relocate(contains("mbalmayo"), .before = total) %>% 
  arrange(desc(total)) %>% 
  gt::gt() %>% 
   gt::tab_spanner(
    label = "Bouamir",
    columns = contains("bouamir")
  ) %>% 
   gt::tab_spanner(
    label = "Mbalmayo",
    columns = contains("mbalmayo")
  ) %>% 
   gt::cols_label(
     bouamir_pheno_observatory = "Number of \ntree",
    sampled_bouamir_pheno_observatory = "Number of sampled tree",
    mbalmayo_pheno_observatory = "Number of \ntree",
    sampled_mbalmayo_pheno_observatory = "Number of sampled tree",
    tax_sp_level = "Species",
    tax_fam = "Family"
  )  %>%
  gt::tab_style_body(
    fn = function(x) is.na(x),
    style = gt::cell_fill(color = "grey")
  )
## `summarise()` has grouped output by 'tax_sp_level', 'tax_fam'. You can override
## using the `.groups` argument.
## Joining with `by = join_by(tax_sp_level)`
Species Family
Bouamir
Mbalmayo
total
Number of tree Number of sampled tree Number of tree Number of sampled tree
Desbordesia glaucescens Irvingiaceae 734 4 41 18 775
Terminalia superba Combretaceae 288 2 31 4 319
Petersianthus macrocarpus Lecythidaceae 209 2 4 2 213
Alstonia boonei Apocynaceae 170 1 31 2 201
Pterocarpus soyauxii Fabaceae 91 1 88 28 179
Lophira alata Ochnaceae NA NA 178 31 178
Erythrophleum suaveolens Fabaceae 100 1 62 5 162
Klainedoxa gabonensis Irvingiaceae 84 2 77 3 161
Tessmannia africana Fabaceae 99 2 37 2 136
Piptadeniastrum africanum Fabaceae 55 1 75 4 130
Distemonanthus benthamianus Fabaceae 110 1 19 1 129
Uapaca mole Phyllanthaceae 92 2 24 2 116
Dialium angolense Fabaceae NA NA 114 5 114
Pteleopsis hylodendron Combretaceae 90 3 21 1 111
Musanga cecropioides Urticaceae 43 1 56 15 99
Celtis tessmannii Cannabaceae 71 1 27 2 98
Xylopia hypolampra Annonaceae 77 1 14 1 91
Uapaca heudelotii Phyllanthaceae 38 NA 52 2 90
Hexalobus crispiflorus Annonaceae 52 2 35 4 87
Pentaclethra macrophylla Fabaceae 78 1 9 NA 87
Quassia gabonensis Simaroubaceae 2 NA 81 2 83
Irvingia grandifolia Irvingiaceae 46 2 34 5 80
Homalium letestui Salicaceae 72 1 7 1 79
Strombosia pustulata Olacaceae 77 2 1 NA 78
Hylodendron gabunense Fabaceae 33 NA 43 2 76
Milicia excelsa Moraceae 59 1 12 NA 71
Pycnanthus angolensis Myristicaceae 35 1 36 7 71
Celtis mildbraedii Cannabaceae 65 1 NA NA 65
Maranthes glabra Chrysobalanaceae 6 NA 59 1 65
Greenwayodendron suaveolens Annonaceae 52 1 2 NA 54
Albizia adianthifolia Fabaceae 34 NA 19 1 53
Annickia affinis Annonaceae 52 NA NA NA 52
Duboscia macrocarpa Malvaceae 50 2 1 NA 51
Eribroma oblongum Malvaceae 31 2 20 2 51
Discoglypremna caloneura Euphorbiaceae 39 1 6 1 45
Duguetia staudtii Annonaceae 24 1 19 NA 43
Xylopia aethiopica Annonaceae 32 NA 10 2 42
Macaranga barteri Euphorbiaceae 32 NA 8 1 40
Eriocoelum macrocarpum Sapindaceae 29 NA 9 2 38
Ongokea gore Olacaceae 27 1 9 1 36
Canarium schweinfurthii Burseraceae 21 2 14 5 35
Parkia bicolor Fabaceae 7 1 28 3 35
Erismadelphus exsul Vochysiaceae 31 2 1 NA 32
Pterygota bequaertii Malvaceae 11 1 21 1 32
Blighia welwitschii Sapindaceae 30 1 1 NA 31
Nesogordonia kabingaensis Malvaceae 28 2 3 NA 31
Ceiba pentandra Malvaceae 4 NA 25 1 29
Lannea welwitschii Anacardiaceae 14 1 15 2 29
Syzygium rowlandii Myrtaceae 29 1 NA NA 29
Tessmannia anomala Fabaceae 13 1 16 3 29
Funtumia africana Apocynaceae 28 1 NA NA 28
Gilbertiodendron dewevrei Fabaceae 1 NA 27 3 28
Phyllocosmus africanus Ixonanthaceae 27 2 1 NA 28
Staudtia kamerunensis Myristicaceae 27 NA 1 NA 28
Irvingia gabonensis Irvingiaceae 8 NA 18 2 26
Amphimas pterocarpoides Fabaceae 21 1 4 1 25
Anopyxis klaineana Rhizophoraceae 15 1 10 2 25
Cylicodiscus gabunensis Fabaceae 24 1 1 1 25
Entandrophragma cylindricum Meliaceae 25 2 NA NA 25
Funtumia elastica Apocynaceae 23 NA 2 NA 25
Maesopsis eminii Rhamnaceae 22 NA 3 NA 25
Ricinodendron heudelotii Euphorbiaceae 25 1 NA NA 25
Bombax brevicuspe Malvaceae 21 1 3 NA 24
Detarium macrocarpum Fabaceae 10 1 14 20 24
Leplaea cedrata Meliaceae 23 1 1 NA 24
Albizia ferruginea Fabaceae 20 1 3 NA 23
Chrysophyllum lacourtianum Sapotaceae 19 1 4 1 23
Dacryodes edulis Burseraceae 21 1 2 NA 23
Parinari excelsa Chrysobalanaceae 15 NA 8 3 23
Corynanthe macroceras Rubiaceae 11 NA 11 2 22
Irvingia robur Irvingiaceae 13 2 8 2 21
Lovoa trichilioides Meliaceae 9 NA 12 2 21
Xylopia rubescens Annonaceae 21 NA NA NA 21
Entandrophragma candollei Meliaceae 18 NA 2 NA 20
Tapura africana Dichapetalaceae 20 1 NA NA 20
Xylopia quintasii Annonaceae 9 NA 10 NA 19
Afzelia bipindensis Fabaceae 16 1 2 NA 18
Licania elaeosperma Chrysobalanaceae NA NA 18 2 18
Manilkara letouzeyi Sapotaceae 18 2 NA NA 18
Nauclea diderrichii Rubiaceae 10 NA 8 2 18
Pterocarpus mildbraedii Fabaceae 18 NA NA NA 18
Margaritaria discoidea Phyllanthaceae 4 1 13 NA 17
Sterculia tragacantha Malvaceae 13 2 4 NA 17
Bombax buonopozense Malvaceae 13 NA 3 1 16
Zanthoxylum gilletii Rutaceae 13 NA 3 NA 16
Maprounea membranacea Euphorbiaceae 9 NA 6 NA 15
Anthonotha sp1 Bouamir Fabaceae 14 NA NA NA 14
Khaya grandifoliola Meliaceae 14 1 NA NA 14
Scottellia klaineana Achariaceae 10 NA 4 1 14
Cleistopholis patens Annonaceae 11 NA 2 NA 13
Pachyelasma tessmannii Fabaceae 8 1 5 1 13
Xylopia staudtii Annonaceae 11 NA 2 NA 13
Dracaena arborea Asparagaceae 12 1 NA NA 12
Beilschmiedia obscura Lauraceae 10 1 1 NA 11
Coelocaryon preussii Myristicaceae 9 NA 2 NA 11
Rauvolfia caffra Apocynaceae 6 NA 5 NA 11
Carapa procera Meliaceae 10 1 NA NA 10
Terminalia ivorensis Combretaceae NA NA 10 NA 10
Tetrapleura tetraptera Fabaceae 6 NA 4 NA 10
Cola lateritia Malvaceae 8 NA 1 NA 9
Dialium pachyphyllum Fabaceae 9 NA NA NA 9
Ficus mucuso Moraceae NA NA 9 1 9
Khaya ivorensis Meliaceae NA NA 9 1 9
Mammea africana Calophyllaceae 3 1 6 1 9
Markhamia tomentosa Bignoniaceae 8 NA 1 NA 9
Angylocalyx pynaertii Fabaceae 6 NA 2 1 8
Dialium dinklagei Fabaceae 1 1 7 2 8
Drypetes gossweileri Putranjivaceae 8 1 NA NA 8
Trichilia dregeana Meliaceae 7 NA 1 NA 8
Baillonella toxisperma Sapotaceae 6 1 1 NA 7
Bridelia grandis Phyllanthaceae 5 1 2 NA 7
Pouteria altissima Sapotaceae 7 NA NA NA 7
Talbotiella breteleri Fabaceae NA NA 7 NA 7
Cordia africana Boraginaceae NA NA 6 NA 6
Heisteria trillesiana Olacaceae 6 1 NA NA 6
Irvingia excelsa Irvingiaceae 4 1 2 NA 6
Macaranga monandra Euphorbiaceae 6 1 NA NA 6
Macaranga spinosa Euphorbiaceae 1 NA 5 NA 6
Nauclea pobeguinii Rubiaceae NA NA 6 1 6
Omphalocarpum elatum Sapotaceae 6 1 NA NA 6
Panda oleosa Pandaceae NA NA 6 3 6
Trichoscypha engong Anacardiaceae 2 1 4 1 6
Allanblackia floribunda Clusiaceae 5 NA NA NA 5
Antrocaryon klaineanum Anacardiaceae 3 NA 2 NA 5
Chrysophyllum boukokoense Sapotaceae 5 1 NA NA 5
Erythroxylum mannii Erythroxylaceae NA NA 5 1 5
Leplaea thompsonii Meliaceae 4 NA 1 NA 5
Symphonia globulifera Clusiaceae 5 1 NA NA 5
Syzygium staudtii Myrtaceae 5 NA NA NA 5
Treculia africana Moraceae 4 NA 1 NA 5
Uapaca acuminata Phyllanthaceae NA NA 5 1 5
Uapaca guineensis Phyllanthaceae 4 NA 1 NA 5
Uapaca staudtii Phyllanthaceae 3 NA 2 1 5
Vitex rivularis Lamiaceae 5 1 NA NA 5
Amphimas ferrugineus Fabaceae NA NA 4 3 4
Anthocleista vogelii Gentianaceae 2 NA 2 NA 4
Carapa parviflora Meliaceae 3 NA 1 NA 4
Cathormion altissimum Fabaceae NA NA 4 NA 4
Dialium bipindense Fabaceae 4 1 NA NA 4
Entandrophragma angolense Meliaceae 4 NA NA NA 4
Erythrina excelsa Fabaceae 3 NA 1 NA 4
Fillaeopsis discophora Fabaceae NA NA 4 NA 4
Keayodendron bridelioides Phyllanthaceae 4 NA NA NA 4
Newtonia leucocarpa Fabaceae 2 NA 2 NA 4
Parkia filicoidea Fabaceae NA NA 4 1 4
Phyllocosmus calothyrsus Ixonanthaceae 1 NA 3 1 4
Pterygota macrocarpa Malvaceae 1 NA 3 NA 4
Sterculia rhinopetala Malvaceae NA NA 4 NA 4
Tessmannia lescrauwaetii Fabaceae 4 NA NA NA 4
Uapaca vanhouttei Phyllanthaceae 4 NA NA NA 4
Vitex grandifolia Lamiaceae NA NA 4 1 4
Zanthoxylum heitzii Rutaceae 4 NA NA NA 4
Blighia sapida Sapindaceae 3 1 NA NA 3
Cleistopholis glauca Annonaceae 3 NA NA NA 3
Entandrophragma utile Meliaceae 3 NA NA NA 3
Fernandoa adolfi-friderici Bignoniaceae 2 NA 1 NA 3
Manilkara obovata Sapotaceae 1 NA 2 2 3
Newtonia grandifolia Fabaceae NA NA 3 NA 3
Oldfieldia africana Picrodendraceae NA NA 3 1 3
Pentadesma butyracea Clusiaceae 3 NA NA NA 3
Shirakiopsis elliptica Euphorbiaceae 1 NA 2 NA 3
Strombosiopsis tetrandra Olacaceae NA NA 3 NA 3
Autranella congolensis Sapotaceae 2 1 NA NA 2
Beilschmiedia congolana Lauraceae 2 1 NA NA 2
Chrysophyllum perpulchrum Sapotaceae 2 1 NA NA 2
Copaifera mildbraedii Fabaceae 2 1 NA NA 2
Diospyros crassiflora Ebenaceae NA NA 2 1 2
Guibourtia tessmannii Fabaceae NA NA 2 NA 2
Hymenocardia lyrata Phyllanthaceae 2 NA NA NA 2
Keyaodendron bridelioides Euphorbiaceae 2 NA NA NA 2
Lebruniodendron leptanthum Fabaceae NA NA 2 NA 2
Maranthes chrysophylla Chrysobalanaceae 2 1 NA NA 2
Oubanguia africana Lecythidaceae NA NA 2 NA 2
Parinari hypochrysea Chrysobalanaceae 2 1 NA NA 2
Poga oleosa Anisophylleaceae 1 NA 1 NA 2
Pseudospondias microcarpa Anacardiaceae 1 NA 1 NA 2
Santiria trimera Burseraceae 1 NA 1 NA 2
Trichilia tessmannii Meliaceae 1 NA 1 NA 2
Trilepisium madagascariense Moraceae 2 1 NA NA 2
Albizia glaberrima Fabaceae 1 NA NA NA 1
Annea afzelii Fabaceae NA NA 1 NA 1
Anonidium mannii Annonaceae 1 NA NA NA 1
Antrocaryon micraster Anacardiaceae 1 NA NA NA 1
Celtis adolfi-friderici Cannabaceae NA NA 1 NA 1
Chrysophyllum africanum Sapotaceae 1 NA NA NA 1
Coula edulis Olacaceae NA NA 1 NA 1
Diospyros canaliculata Ebenaceae NA NA 1 NA 1
Diospyros gilletii Ebenaceae NA NA 1 NA 1
Diospyros suaveolens Ebenaceae NA NA 1 NA 1
Endodesmia calophylloides Calophyllaceae NA NA 1 NA 1
Entada gigas Fabaceae 1 NA NA NA 1
Entandrophragma congoense Meliaceae 1 NA NA NA 1
Euphorbia letestui Euphorbiaceae 1 NA NA NA 1
Gardenia imperialis Rubiaceae 1 NA NA NA 1
Holoptelea grandis Ulmaceae 1 NA NA NA 1
Morinda lucida Rubiaceae 1 NA NA NA 1
Newtonia glandulifera Fabaceae NA NA 1 NA 1
Strombosia scheffleri Olacaceae 1 NA NA NA 1
Tetrorchidium didymostemon Euphorbiaceae 1 NA NA NA 1
Triplochiton scleroxylon Malvaceae NA NA 1 NA 1

State of sampling in permanent plots

all_traits %>% 
  left_join(meta_data %>% select(plot_name, locality_name),
            by = c("plot_name" = "plot_name")) %>% 
  group_by(locality_name, trait) %>% 
  filter(!grepl("_observatory", plot_name)) %>% 
  count() %>%
  pivot_wider(names_from = locality_name, 
              values_from = n) %>% 
  gt::gt()
Bouamir Mbalmayo
SPAD_chlorophyll_measurement
563 290
leaf_area
434 484
leaf_structure_mass_area
415 210
lma_lamina
431 278
lma_mesophyll
504 234
lma_whole_leaf
431 229
mesophyl_thickness
580 290
twig_specific_gravity
29 NA
whole_leaf_area
431 229
nbe_tree_sampled <- 
  traits_leaf_level %>% 
  left_join(meta_data %>% select(plot_name, locality_name),
            by = c("plot_name" = "plot_name")) %>% 
  filter(!grepl("observatory", plot_name)) %>% 
  group_by(locality_name, tag) %>% 
  count() %>% 
  ungroup() %>% 
  group_by(locality_name) %>% 
  summarise(nbe_tree_sampled = n())

nbe_tree_sampled %>% 
  gt::gt(caption = "Number of tree sampled in permanent plots per locality")
Number of tree sampled in permanent plots per locality
locality_name nbe_tree_sampled
Bouamir 156
Mbalmayo 94
sampled_per_locality <- 
  colnbr_per_sp  %>% 
  left_join(meta_data %>% select(plot_name, locality_name),
            by = c("plot_name" = "plot_name")) %>% 
  filter(!grepl("_observatory", plot_name)) %>% 
  group_by(locality_name, tax_sp_level) %>% 
  summarise(nbe_tree_sampled = n()) %>% 
  pivot_wider(names_from = locality_name, 
              values_from =  c(nbe_tree_sampled), 
              names_prefix = "sampled_")
## `summarise()` has grouped output by 'locality_name'. You can override using the
## `.groups` argument.
nbe_tree_obs <- 
  tree_data %>% 
  filter(!grepl("observatory", plot_name)) %>% 
  filter(!is.na(tax_sp_level)) %>% 
  group_by(tax_sp_level, tax_fam) %>% 
  summarise(nbe_tree = n()) %>% 
  ungroup() %>% 
  mutate(locality_name = "total")
## `summarise()` has grouped output by 'tax_sp_level'. You can override using the
## `.groups` argument.
tree_data %>% 
  filter(!grepl("_observatory", plot_name)) %>% 
  filter(!is.na(tax_sp_level)) %>% 
  group_by(tax_sp_level, tax_fam, locality_name) %>% 
  summarise(nbe_tree = n()) %>% 
  ungroup() %>% 
  bind_rows(nbe_tree_obs) %>% 
  pivot_wider(names_from = locality_name, 
              values_from =  c(nbe_tree)) %>% 
  left_join(sampled_per_locality) %>% 
  relocate(contains("bouamir"), .after = where(is.character)) %>% 
  relocate(contains("mbalmayo"), .before = total) %>% 
  arrange(desc(total)) %>% 
  gt::gt() %>% 
   gt::tab_spanner(
    label = "bouamir",
    columns = contains("Bouamir")
  ) %>% 
   gt::tab_spanner(
    label = "Mmbalmayo",
    columns = contains("Mbalmayo")
  ) %>% 
   gt::cols_label(
    Bouamir = "Number of \ntree",
    sampled_Bouamir = "Number of sampled tree",
    Mbalmayo = "Number of \ntree",
    sampled_Mbalmayo = "Number of sampled tree",
    tax_sp_level = "Species",
    tax_fam = "Family"
  )  %>%
  gt::tab_style_body(
    fn = function(x) is.na(x),
    style = gt::cell_fill(color = "grey")
  )
## `summarise()` has grouped output by 'tax_sp_level', 'tax_fam'. You can override
## using the `.groups` argument.
## Joining with `by = join_by(tax_sp_level)`
Species Family
bouamir
Mmbalmayo
total
Number of tree Number of sampled tree Number of tree Number of sampled tree
Gilbertiodendron dewevrei Fabaceae NA NA 1051 NA 1051
Desbordesia glaucescens Irvingiaceae 412 1 30 NA 442
Tabernaemontana crassa Apocynaceae 305 2 53 NA 358
Angylocalyx pynaertii Fabaceae 32 1 253 NA 285
Oubanguia africana Lecythidaceae NA NA 281 4 281
Diospyros iturensis Ebenaceae NA NA 277 NA 277
Strombosiopsis tetrandra Olacaceae 145 1 86 2 231
Greenwayodendron suaveolens Annonaceae 199 1 18 NA 217
Englerophytum congolense Sapotaceae NA NA 193 1 193
Staudtia kamerunensis Myristicaceae 5 NA 175 NA 180
Quassia gabonensis Simaroubaceae 1 NA 169 1 170
Sorindeia grandifolia Anacardiaceae 139 2 21 NA 160
Mitragyna stipulosa Rubiaceae 1 1 157 1 158
Martretia quadricornis Euphorbiaceae NA NA 139 1 139
Duguetia barteri Annonaceae NA NA 136 1 136
Memecylon germainii Melastomataceae NA NA 133 1 133
Strombosia pustulata Olacaceae 119 1 2 NA 121
Diospyros gilletii Ebenaceae NA NA 120 1 120
Corynanthe pachyceras Rubiaceae 41 1 77 NA 118
Strombosia grandifolia Olacaceae 115 1 3 NA 118
Dialium pachyphyllum Fabaceae 45 1 63 NA 108
Santiria trimera Burseraceae 81 1 18 NA 99
Musanga cecropioides Urticaceae 11 NA 82 1 93
Maranthes glabra Chrysobalanaceae 2 NA 85 2 87
Corynanthe macroceras Rubiaceae 63 NA 22 NA 85
Uapaca guineensis Phyllanthaceae 55 2 29 NA 84
Dialium angolense Fabaceae 1 NA 81 1 82
Annickia affinis Annonaceae 74 2 7 NA 81
Macaranga spinosa Euphorbiaceae NA NA 78 1 78
Duboscia macrocarpa Malvaceae 60 2 16 NA 76
Antidesma laciniatum Phyllanthaceae 74 NA NA NA 74
Plagiostyles africana Euphorbiaceae 74 2 NA NA 74
Uapaca heudelotii Phyllanthaceae 58 NA 12 NA 70
Irvingia gabonensis Irvingiaceae 12 3 57 1 69
Mareyopsis longifolia Euphorbiaceae 69 3 NA NA 69
Talbotiella breteleri Fabaceae NA NA 69 1 69
Klaineanthus gabonii Euphorbiaceae 59 3 9 NA 68
Tessmannia africana Fabaceae 23 1 40 NA 63
Morelia senegalensis Rubiaceae NA NA 62 2 62
Petersianthus macrocarpus Lecythidaceae 42 NA 20 1 62
Klainedoxa gabonensis Irvingiaceae 34 1 27 1 61
Uapaca staudtii Phyllanthaceae 59 NA NA NA 59
Pterocarpus soyauxii Fabaceae 18 NA 40 NA 58
Maesobotrya klaineana Phyllanthaceae 22 1 35 NA 57
Lecaniodiscus cupanioides Sapindaceae 54 3 2 1 56
Panda oleosa Pandaceae 13 2 43 NA 56
Trichoscypha acuminata Anacardiaceae 31 NA 25 NA 56
Leptaulus daphnoides Cardiopteridaceae NA NA 55 1 55
Diospyros suaveolens Ebenaceae NA NA 54 NA 54
Eriocoelum macrocarpum Sapindaceae 40 1 13 NA 53
Manilkara obovata Sapotaceae 1 1 52 NA 53
Hylodendron gabunense Fabaceae 25 1 25 NA 50
Desplatsia dewevrei Malvaceae 38 NA 11 NA 49
Englerophytum laurentii Sapotaceae NA NA 49 1 49
Uapaca mole Phyllanthaceae 34 NA 15 NA 49
Octolobus heteromerus Malvaceae 28 1 19 1 47
Pentaclethra macrophylla Fabaceae 40 NA 5 NA 45
Aubrevillea platycarpa Fabaceae NA NA 44 1 44
Celtis tessmannii Cannabaceae 16 NA 28 NA 44
Plagiosiphon emarginatus Fabaceae NA NA 44 NA 44
Hexalobus crispiflorus Annonaceae 17 2 26 NA 43
Octolobus spectabilis Malvaceae 33 1 10 NA 43
Pycnanthus angolensis Myristicaceae 6 NA 37 NA 43
Anthonotha macrophylla Fabaceae 24 2 15 NA 39
Dacryodes edulis Burseraceae 28 1 10 NA 38
Xylopia quintasii Annonaceae 10 1 28 NA 38
Garcinia mannii Clusiaceae 16 1 20 1 36
Alstonia boonei Apocynaceae 29 NA 6 NA 35
Anthonotha sp1 Bouamir Fabaceae 35 2 NA NA 35
Coula edulis Olacaceae NA NA 35 NA 35
Blighia welwitschii Sapindaceae 30 NA 3 NA 33
Carapa procera Meliaceae 26 NA 7 NA 33
Drypetes spinosodentata Putranjivaceae 33 1 NA NA 33
Funtumia africana Apocynaceae 22 NA 11 NA 33
Trichilia rubescens Meliaceae 27 1 6 NA 33
Lophira alata Ochnaceae NA NA 31 NA 31
Erythrophleum suaveolens Fabaceae 19 NA 11 1 30
Phyllocosmus africanus Ixonanthaceae 29 NA 1 NA 30
Rothmannia lujae Rubiaceae 15 1 15 NA 30
Myrianthus arboreus Urticaceae 23 NA 6 NA 29
Pterygota bequaertii Malvaceae 6 NA 23 NA 29
Markhamia tomentosa Bignoniaceae 24 NA 4 NA 28
Aidia micrantha Rubiaceae 20 1 7 NA 27
Duguetia staudtii Annonaceae 9 1 18 NA 27
Homalium abdessammadii Salicaceae NA NA 27 1 27
Cola lateritia Malvaceae 22 1 4 1 26
Licania elaeosperma Chrysobalanaceae NA NA 26 1 26
Macaranga barteri Euphorbiaceae 11 NA 15 1 26
Macaranga monandra Euphorbiaceae 18 1 8 NA 26
Xylopia aethiopica Annonaceae 9 NA 17 NA 26
Celtis mildbraedii Cannabaceae 24 NA 1 NA 25
Rinorea oblongifolia Violaceae 22 NA 3 NA 25
Uvariastrum pierreanum Annonaceae 8 1 17 1 25
Carapa parviflora Meliaceae 14 NA 9 1 23
Cola acuminata Malvaceae 10 NA 13 1 23
Terminalia superba Combretaceae 23 NA NA NA 23
Tessmannia anomala Fabaceae 3 NA 20 1 23
Treculia africana Moraceae 3 1 20 1 23
Coelocaryon preussii Myristicaceae 4 1 18 1 22
Funtumia elastica Apocynaceae 19 NA 3 NA 22
Globulostylis cuvieroides Rubiaceae 22 NA NA NA 22
Pseudospondias microcarpa Anacardiaceae 12 NA 10 1 22
Garcinia epunctata Clusiaceae 15 1 6 NA 21
Mammea africana Calophyllaceae 15 NA 6 NA 21
Cola pachycarpa Malvaceae NA NA 20 NA 20
Distemonanthus benthamianus Fabaceae 10 NA 10 1 20
Anonidium mannii Annonaceae 11 2 8 NA 19
Chytranthus macrophyllus Sapindaceae 3 1 16 1 19
Cleistopholis glauca Annonaceae 2 NA 17 1 19
Milicia excelsa Moraceae 12 NA 7 NA 19
Oncoba glauca Salicaceae 14 3 5 NA 19
Allanblackia floribunda Clusiaceae 4 1 14 2 18
Irvingia grandifolia Irvingiaceae 7 NA 11 NA 18
Piptadeniastrum africanum Fabaceae 4 NA 14 NA 18
Vitex rivularis Lamiaceae 16 NA 2 NA 18
Calpocalyx dinklagei Fabaceae 14 1 3 NA 17
Lovoa trichilioides Meliaceae 5 NA 12 NA 17
Beilschmiedia obscura Lauraceae 13 2 3 2 16
Bridelia grandis Phyllanthaceae 3 NA 13 NA 16
Discoglypremna caloneura Euphorbiaceae 13 1 3 NA 16
Maprounea membranacea Euphorbiaceae 4 1 12 1 16
Nesogordonia kabingaensis Malvaceae 8 NA 8 NA 16
Centroplacus glaucinus Centroplacaceae 15 2 NA NA 15
Cleistopholis patens Annonaceae 5 NA 10 NA 15
Diospyros crassiflora Ebenaceae NA NA 15 NA 15
Scottellia klaineana Achariaceae 4 NA 11 1 15
Terminalia ivorensis Combretaceae NA NA 15 1 15
Barteria fistulosa Passifloraceae 9 1 5 NA 14
Endodesmia calophylloides Calophyllaceae NA NA 14 NA 14
Homalium letestui Salicaceae 13 NA 1 1 14
Hymenocardia lyrata Phyllanthaceae 14 NA NA NA 14
Lasiodiscus mannii Rhamnaceae 7 1 7 NA 14
Leonardoxa africana Fabaceae NA NA 14 1 14
Ongokea gore Olacaceae 6 NA 8 NA 14
Tetrapleura tetraptera Fabaceae 7 NA 6 NA 13
Bombax brevicuspe Malvaceae 3 NA 9 NA 12
Cleistanthus polystachyus Phyllanthaceae NA NA 12 NA 12
Cordia africana Boraginaceae NA NA 12 NA 12
Garcinia ovalifolia Clusiaceae 4 1 8 NA 12
Pauridiantha floribunda Rubiaceae 12 1 NA NA 12
Shirakiopsis elliptica Euphorbiaceae 11 NA 1 NA 12
Sterculia tragacantha Malvaceae 5 NA 7 1 12
Trichilia prieuriana Meliaceae NA NA 12 NA 12
Xylopia hypolampra Annonaceae 12 NA NA NA 12
Albizia adianthifolia Fabaceae 1 NA 10 1 11
Amphimas pterocarpoides Fabaceae 4 2 7 NA 11
Anthonotha fragrans Fabaceae 11 1 NA NA 11
Blighia sapida Sapindaceae 3 NA 8 2 11
Chrysophyllum africanum Sapotaceae 5 NA 6 NA 11
Gardenia imperialis Rubiaceae 5 NA 6 1 11
Heisteria parvifolia Olacaceae 11 4 NA NA 11
Hemandradenia mannii Connaraceae NA NA 11 NA 11
Lepidobotrys staudtii Lepidobotryaceae 11 2 NA NA 11
Mallotus oppositifolius Euphorbiaceae 11 1 NA NA 11
Nauclea diderrichii Rubiaceae 9 NA 2 NA 11
Persea americana Lauraceae NA NA 11 NA 11
Trichoscypha oddonii Anacardiaceae 7 NA 4 NA 11
Baphia nitida Fabaceae NA NA 10 NA 10
Bridelia micrantha Phyllanthaceae 4 NA 6 NA 10
Eribroma oblongum Malvaceae 10 NA NA NA 10
Heinsia crinita Rubiaceae 9 NA 1 NA 10
Isolona hexaloba Annonaceae 9 1 1 NA 10
Monodora tenuifolia Annonaceae 10 NA NA NA 10
Sclerocroton cornutus Euphorbiaceae 4 1 6 NA 10
Strombosia zenkeri Olacaceae 10 2 NA NA 10
Trichilia tessmannii Meliaceae 3 NA 7 NA 10
Baikiaea insignis Fabaceae NA NA 9 1 9
Christiana africana Malvaceae NA NA 9 NA 9
Chrysophyllum lacourtianum Sapotaceae 8 NA 1 NA 9
Coffea canephora Rubiaceae 9 NA NA NA 9
Desplatsia chrysochlamys Malvaceae 9 NA NA NA 9
Detarium macrocarpum Fabaceae 6 NA 3 NA 9
Diospyros hoyleana Ebenaceae 2 1 7 NA 9
Drypetes chevalieri Putranjivaceae 9 1 NA NA 9
Oncoba dentata Salicaceae 8 1 1 NA 9
Pteleopsis hylodendron Combretaceae 6 NA 3 NA 9
Strombosia scheffleri Olacaceae 9 1 NA NA 9
Dialium guineense Fabaceae 7 NA 1 1 8
Oncoba welwitschii Salicaceae NA NA 8 NA 8
Parinari excelsa Chrysobalanaceae 3 NA 5 NA 8
Symphonia globulifera Clusiaceae 5 1 3 NA 8
Trichilia welwitschii Meliaceae 8 1 NA NA 8
Uapaca vanhouttei Phyllanthaceae 8 NA NA NA 8
Alchornea laxiflora Euphorbiaceae 7 NA NA NA 7
Allophylus africanus Sapindaceae 3 1 4 NA 7
Antidesma membranaceum Phyllanthaceae 7 1 NA NA 7
Dialium bipindense Fabaceae NA NA 7 NA 7
Erismadelphus exsul Vochysiaceae 6 NA 1 NA 7
Fernandoa adolfi-friderici Bignoniaceae 3 NA 4 NA 7
Guibourtia ehie Fabaceae NA NA 7 NA 7
Leplaea cedrata Meliaceae 3 NA 4 NA 7
Margaritaria discoidea Phyllanthaceae 3 NA 4 NA 7
Parkia bicolor Fabaceae 1 NA 6 NA 7
Psydrax splendens Rubiaceae 7 NA NA NA 7
Rhabdophyllum arnoldianum Ochnaceae NA NA 7 NA 7
Tetrorchidium didymostemon Euphorbiaceae NA NA 7 NA 7
Zanthoxylum gilletii Rutaceae 7 NA NA NA 7
Aulacocalyx jasminiflora Rubiaceae 1 NA 5 NA 6
Canarium schweinfurthii Burseraceae 3 NA 3 NA 6
Ceiba pentandra Malvaceae 1 NA 5 NA 6
Cola rostrata Malvaceae NA NA 6 NA 6
Diospyros conocarpa Ebenaceae 4 NA 2 NA 6
Entandrophragma candollei Meliaceae 2 NA 4 NA 6
Entandrophragma cylindricum Meliaceae 4 NA 2 NA 6
Ficus exasperata Moraceae NA NA 6 NA 6
Xylopia staudtii Annonaceae 6 NA NA NA 6
Zanthoxylum heitzii Rutaceae 6 1 NA NA 6
Anthocleista liebrechtsiana Gentianaceae NA NA 5 1 5
Aoranthe cladantha Rubiaceae 1 NA 4 NA 5
Keayodendron bridelioides Phyllanthaceae 4 1 1 NA 5
Lannea welwitschii Anacardiaceae 3 NA 2 NA 5
Maesopsis eminii Rhamnaceae 3 NA 2 NA 5
Millettia sanagana Fabaceae 3 NA 2 NA 5
Picralima nitida Apocynaceae 5 NA NA NA 5
Spathandra blakeoides Melastomataceae NA NA 5 1 5
Streblus usambarensis Moraceae NA NA 5 NA 5
Tricalysia pangolina Rubiaceae 5 NA NA NA 5
Trichilia dregeana Meliaceae 5 NA NA NA 5
Vitex grandifolia Lamiaceae NA NA 5 NA 5
Xylopia rubescens Annonaceae 5 NA NA NA 5
Zanthoxylum macrophyllum Rutaceae 5 NA NA NA 5
Casearia stipitata Salicaceae NA NA 4 1 4
Chlamydocola chlamydantha Malvaceae 4 NA NA NA 4
Desplatsia mildbraedii Malvaceae 4 1 NA NA 4
Englerodendron isopetalum Fabaceae NA NA 4 1 4
Ficus mucuso Moraceae NA NA 4 NA 4
Nauclea pobeguinii Rubiaceae 2 NA 2 1 4
Omphalocarpum elatum Sapotaceae 4 1 NA NA 4
Paropsia guineensis Passifloraceae 4 NA NA NA 4
Pterocarpus mildbraedii Fabaceae 4 NA NA NA 4
Ricinodendron heudelotii Euphorbiaceae 4 NA NA NA 4
Synsepalum brevipes Sapotaceae NA NA 4 1 4
Tapura africana Dichapetalaceae 4 NA NA NA 4
Trichoscypha engong Anacardiaceae 1 1 3 NA 4
Vepris glaberrima Rutaceae 4 1 NA NA 4
Afzelia bipindensis Fabaceae 1 NA 2 NA 3
Anopyxis klaineana Rhizophoraceae 3 NA NA NA 3
Anthocleista vogelii Gentianaceae 3 NA NA NA 3
Aptandra zenkeri Olacaceae 3 1 NA NA 3
Clausena anisata Rutaceae 3 NA NA NA 3
Cleistanthus gabonensis Phyllanthaceae NA NA 3 NA 3
Cylicodiscus gabunensis Fabaceae 2 NA 1 NA 3
Drypetes gossweileri Putranjivaceae 1 NA 2 NA 3
Drypetes laciniata Putranjivaceae 3 NA NA NA 3
Leplaea thompsonii Meliaceae 3 NA NA NA 3
Maytenus undatus Celastraceae 3 1 NA NA 3
Morinda lucida Rubiaceae 1 1 2 1 3
Newtonia glandulifera Fabaceae NA NA 3 NA 3
Pouteria altissima Sapotaceae 3 1 NA NA 3
Rauvolfia vomitoria Apocynaceae 1 NA 2 NA 3
Santiria ebo Burseraceae 3 NA NA NA 3
Strombosia tetandra Olacaceae 3 NA NA NA 3
Synsepalum seretii Sapotaceae NA NA 3 NA 3
Syzygium rowlandii Myrtaceae 2 NA 1 NA 3
Syzygium staudtii Myrtaceae 3 1 NA NA 3
Treculia obovoidea Moraceae NA NA 3 NA 3
Tricalysia bifida Rubiaceae 3 NA NA NA 3
Trilepisium madagascariense Moraceae 1 NA 2 NA 3
Uapaca acuminata Phyllanthaceae 2 NA 1 NA 3
Aulacocalyx caudata Rubiaceae 1 1 1 NA 2
Berlinia bracteosa Fabaceae 2 1 NA NA 2
Bombax buonopozense Malvaceae 1 NA 1 NA 2
Campylospermum mannii Ochnaceae 2 NA NA NA 2
Cathormion altissimum Fabaceae NA NA 2 NA 2
Celtis adolfi-friderici Cannabaceae NA NA 2 NA 2
Chrysophyllum giganteum Sapotaceae 2 1 NA NA 2
Cola cauliflora Malvaceae 2 NA NA NA 2
Cola digitata Malvaceae NA NA 2 NA 2
Croton sylvaticus Euphorbiaceae NA NA 2 NA 2
Diospyros ferrea Ebenaceae NA NA 2 1 2
Dracaena arborea Asparagaceae 2 NA NA NA 2
Entandrophragma congoense Meliaceae 1 NA 1 NA 2
Erythroxylum mannii Erythroxylaceae NA NA 2 1 2
Ficus vogeliana Moraceae 1 1 1 NA 2
Grewia coriacea Tiliaceae 2 NA NA NA 2
Guibourtia tessmannii Fabaceae NA NA 2 NA 2
Hymenocardia ulmoides Phyllanthaceae 2 1 NA NA 2
Irvingia robur Irvingiaceae NA NA 2 NA 2
Khaya grandifoliola Meliaceae 1 NA 1 NA 2
Khaya ivorensis Meliaceae 1 NA 1 NA 2
Leptactina arborescens Rubiaceae 1 NA 1 1 2
Mangifera indica Anacardiaceae NA NA 2 NA 2
Massularia acuminata Rubiaceae 1 1 1 NA 2
Oldfieldia africana Picrodendraceae NA NA 2 NA 2
Psychotria venosa Rubiaceae NA NA 2 NA 2
Ptychopetalum petiolatum Olacaceae NA NA 2 1 2
Quassia silvestris Simaroubaceae 1 NA 1 NA 2
Rhabdophyllum calophyllum Ochnaceae 2 1 NA NA 2
Rinorea grandifolia Violaceae NA NA 2 NA 2
Synsepalum cerasiferum Sapotaceae 2 1 NA NA 2
Talbotiella batesii Fabaceae NA NA 2 NA 2
Turraeanthus africanus Meliaceae 2 NA NA NA 2
Afzelia pachyloba Fabaceae 1 NA NA NA 1
Albizia glaberrima Fabaceae 1 NA NA NA 1
Albizia zygia Fabaceae NA NA 1 NA 1
Amphimas ferrugineus Fabaceae 1 NA NA NA 1
Annickia chlorantha Annonaceae NA NA 1 NA 1
Antrocaryon klaineanum Anacardiaceae NA NA 1 NA 1
Baillonella toxisperma Sapotaceae 1 NA NA NA 1
Beilschmiedia fulva Lauraceae NA NA 1 NA 1
Bridelia atroviridis Phyllanthaceae 1 NA NA NA 1
Calpocalyx heitzii Fabaceae 1 NA NA NA 1
Cassipourea congoensis Rhizophoraceae NA NA 1 NA 1
Celtis zenkeri Cannabaceae 1 NA NA NA 1
Chrysophyllum beguei Sapotaceae 1 NA NA NA 1
Chrysophyllum perpulchrum Sapotaceae 1 1 NA NA 1
Cola lepidota Malvaceae NA NA 1 NA 1
Cuviera longiflora Rubiaceae 1 NA NA NA 1
Dacryodes ledermannii Burseraceae 1 NA NA NA 1
Dacryodes macrophylla Burseraceae NA NA 1 NA 1
Diospyros pseudomespilus Ebenaceae 1 1 NA NA 1
Entandrophragma utile Meliaceae NA NA 1 NA 1
Erythrina excelsa Fabaceae 1 NA NA NA 1
Erythroxylum emarginatum Erythroxylaceae 1 1 NA NA 1
Garcinia kola Clusiaceae NA NA 1 NA 1
Garcinia smeathmannii Clusiaceae 1 1 NA NA 1
Glyphaea brevis Malvaceae 1 NA NA NA 1
Grewia oligoneura Tiliaceae 1 NA NA NA 1
Heinsia parviflora Rubiaceae 1 NA NA NA 1
Holoptelea grandis Ulmaceae 1 NA NA NA 1
Irvingia excelsa Irvingiaceae 1 NA NA NA 1
Leptaulus zenkeri Cardiopteridaceae NA NA 1 NA 1
Majidea fosteri Sapindaceae NA NA 1 NA 1
Manilkara pellegriniana Sapotaceae 1 1 NA NA 1
Meiocarpidium oliverianum Annonaceae NA NA 1 NA 1
Newbouldia laevis Bignoniaceae 1 1 NA NA 1
Ochna calodendron Ochnaceae NA NA 1 NA 1
Parkia filicoidea Fabaceae NA NA 1 NA 1
Paropsia grewioides Passifloraceae 1 NA NA NA 1
Pauridiantha afzelii Rubiaceae 1 NA NA NA 1
Rauvolfia caffra Apocynaceae NA NA 1 NA 1
Rinorea dentata Violaceae 1 NA NA NA 1
Rothmannia talbotii Rubiaceae NA NA 1 NA 1
Sterculia rhinopetala Malvaceae NA NA 1 NA 1
Strephonema sericeum Combretaceae 1 1 NA NA 1
Synsepalum letouzeyi Sapotaceae NA NA 1 NA 1
Synsepalum longicuneatum Sapotaceae 1 1 NA NA 1
Synsepalum sp.nov. Bouamir Sapotaceae 1 1 NA NA 1
Syzygium guineense Myrtaceae 1 NA NA NA 1
Tricalysia anomala Rubiaceae 1 NA NA NA 1
Tricalysia fangana Rubiaceae 1 NA NA NA 1
Tridesmostemon omphalocarpoides Sapotaceae 1 NA NA NA 1
Vitex doniana Lamiaceae 1 NA NA NA 1
Xylopia phloiodora Annonaceae 1 1 NA NA 1

Variance decomposition

Following the method in Boisseaux et al 2024.

Results below are not comparable across traits because datasets varies. For example chlorophyll content and delta carbon measurements were measured on samples that favours within-species variation.

MyData_Sp <- 
  colnbr_per_sp %>%
  left_join(
    tree_data %>% select(
      id_n,
      locality_name,
      taxa_level_bioclimatic_group,
      taxa_level_phenology,
      taxa_level_succession_guild
    ),
    by = c("id_data_individuals" = "id_n")
  ) %>% 
  mutate(site = case_when(
   grepl("Mbalmayo", locality_name) ~ "Mbalmayo",
   grepl("Bouamir", locality_name) ~ "Bouamir"
  )) %>% 
  ungroup()


### function for variance decomposition for each trait


func_var_components <- function(my_data,
                                col_tax = "tax_sp_level",
                                col_trait,
                                col_fixed_group) {
  my_data <-
    my_data %>%
    rename(
      taxa = all_of(col_tax),
      col_trait = all_of(col_trait),
      col_fixed_group = all_of(col_fixed_group)
    ) %>%
    select(taxa, col_trait, col_fixed_group) %>%
    filter(!is.na(taxa), !is.na(col_trait), !is.na(col_fixed_group))
  
  
  # Fit the linear mixed-effects model
  model <- nlme::lme(
    col_trait ~ col_fixed_group,
    random =  ~ 1 |
      taxa,
    data = my_data,
    na.action = na.omit,
    method = "ML"
  )
  
  Var_components <- lme4::VarCorr(model)
  var_sp <- as.numeric(Var_components[1, 1]) #for the random effects - species
  var_indv <- as.numeric(Var_components[2, 1]) #model residual, also known as the intraspecific residual
  
  
  #Fit the associated null model with random intercept on species
  null_model <- nlme::lme(
    col_trait ~ 1,
    random =  ~ 1 |
      taxa,
    data = my_data,
    na.action = na.omit,
    method = "ML"
  )
  
  # Obtain the variance of the random effect in the null model.
  random_variance_null <- as.numeric(lme4::VarCorr(null_model)[1, 1])
  
  # Obtain the residual variance
  residual_variance_null <- as.numeric(lme4::VarCorr(null_model)[2, 1])
  
  # Obtain the total variance of the null model
  v_0 <- random_variance_null + residual_variance_null
  
  # Calculate the variance component linked to the env't by substracting the residual variance of the model (var_indv) and the variance explained by the random factor, the species (var_sp), from the variance of the null model
  
  # Variance partitioning
  comp_sp <- round(100 * var_sp / v_0, 1)
  comp_indv <- round(100 * var_indv / v_0, 1)
  
  comp_envt <- 100 - (comp_indv +  comp_sp)
  
  res <- tibble(
    trait = col_trait,
    fixed_group = col_fixed_group,
    comp_var = c("species", "within_species", "group"),
    value = c(comp_sp, comp_indv, comp_envt)
  )
  
  return(res)
}

all_traits_names <- 
  names(MyData_Sp %>% select(starts_with("t_")))

MyData_Sp <- 
  MyData_Sp %>%
  mutate(t_leaf_delta_carbon_13 = abs(t_leaf_delta_carbon_13)) %>% 
  mutate(across(starts_with("t_"), ~ log10(.x))) ## log transformation

Using phenology as a fixed group.

res_list <- vector('list', length(all_traits_names))
for (i in 1:length(all_traits_names)) {
  res_list[[i]] <-
  func_var_components(my_data = MyData_Sp,
                 col_trait = all_traits_names[i],
                 col_fixed_group = "taxa_level_phenology")
}


res <- bind_rows(res_list)
res %>% 
  filter(comp_var == "group")
## # A tibble: 13 × 4
##    trait                          fixed_group          comp_var  value
##    <chr>                          <chr>                <chr>     <dbl>
##  1 t_SPAD_chlorophyll_measurement taxa_level_phenology group     4.70 
##  2 t_whole_leaf_area              taxa_level_phenology group     1.60 
##  3 t_mesophyl_thickness           taxa_level_phenology group    -0.100
##  4 t_lma_mesophyll                taxa_level_phenology group     1.10 
##  5 t_lma_lamina                   taxa_level_phenology group     1.30 
##  6 t_lma_whole_leaf               taxa_level_phenology group     2.80 
##  7 t_leaf_area                    taxa_level_phenology group     3.80 
##  8 t_leaf_structure_mass_area     taxa_level_phenology group     0.5  
##  9 t_twig_specific_gravity        taxa_level_phenology group     0.600
## 10 t_total_chlorophyll_content    taxa_level_phenology group     0.100
## 11 t_leaf_delta_carbon_13         taxa_level_phenology group     8.10 
## 12 t_leaf_N_percentage            taxa_level_phenology group     6.40 
## 13 t_leaf_C_percentage            taxa_level_phenology group     0.5
ggplot(res, aes(x = trait, y = value, fill = comp_var)) +
  geom_bar(stat = "identity", position = "stack") +
  labs(title = "taxa_level_phenology", y = "Percentage") +
  theme_minimal() +
  coord_flip()

Using guild as a fixed group.

res_list <- vector('list', length(all_traits_names))
for (i in 1:length(all_traits_names)) {
  res_list[[i]] <-
  func_var_components(my_data = MyData_Sp,
                 col_trait = all_traits_names[i],
                 col_fixed_group = "taxa_level_succession_guild")
}


res <- bind_rows(res_list)
res %>% 
  filter(comp_var == "group")
## # A tibble: 13 × 4
##    trait                          fixed_group                 comp_var  value
##    <chr>                          <chr>                       <chr>     <dbl>
##  1 t_SPAD_chlorophyll_measurement taxa_level_succession_guild group     4.30 
##  2 t_whole_leaf_area              taxa_level_succession_guild group     1    
##  3 t_mesophyl_thickness           taxa_level_succession_guild group    -0.100
##  4 t_lma_mesophyll                taxa_level_succession_guild group     1.20 
##  5 t_lma_lamina                   taxa_level_succession_guild group     0.100
##  6 t_lma_whole_leaf               taxa_level_succession_guild group     0.700
##  7 t_leaf_area                    taxa_level_succession_guild group     1.30 
##  8 t_leaf_structure_mass_area     taxa_level_succession_guild group     2.5  
##  9 t_twig_specific_gravity        taxa_level_succession_guild group     3.60 
## 10 t_total_chlorophyll_content    taxa_level_succession_guild group     0.200
## 11 t_leaf_delta_carbon_13         taxa_level_succession_guild group     5.60 
## 12 t_leaf_N_percentage            taxa_level_succession_guild group     1.40 
## 13 t_leaf_C_percentage            taxa_level_succession_guild group     0.400
ggplot(res, aes(x = trait, y = value, fill = comp_var)) +
  geom_bar(stat = "identity", position = "stack") +
  labs(title = "taxa_level_succession_guild", y = "Percentage") +
  theme_minimal() +
  coord_flip()