Code
#pkg
library(tidyverse)
library(here)
library(readxl)
library(ggnewscale) # to have two scale_fill
library(ggh4x)
library(ggstats)
library(patchwork)

# src
source(here::here("src/function/stat_function/stat_analysis_main.R")) # for make plot 
source(here::here("src/function/fig_export.R")) # This function saves a given plot (plot_x) as both a PDF and a high-resolution PNG file at specified dimensions.

# cosmetics
sulfate_pallet=read_excel(here::here("data/color_palette.xlsm")) %>%
      filter(set == "sulfure_condition") %>%
      dplyr::select(color, treatment) %>%
      pull(color) %>%
      setNames(read_excel(here::here("data/color_palette.xlsm")) %>%
                 filter(set == "sulfure_condition") %>%
                 pull(treatment)
               )

mutant_palette=read_excel(here::here("data/color_palette.xlsm")) %>%
      filter(set == "mutant") %>%
      dplyr::select(color, treatment) %>%
      pull(color) %>%
      setNames(read_excel(here::here("data/color_palette.xlsm")) %>%
                 filter(set == "mutant") %>%
                 pull(treatment)
               )

4.1 Data importation

There are 40 plants and two measurements are taken per plant. The first measurement is taken on the first leaflet of the fully developed leaf of the uppermost node, and the second on the first leaflet of the node below. The third measurement is taken on the first leaflet of the most developed leaf at the bottom of the plant.

For unit of the licor see licor.com

Code
name_files <- list.files(
  path = here("data/physio/LI-COR_LI-600"),
  pattern = "\\.csv$", 
  full.names = TRUE
)

df_licor <- map_dfr(name_files, ~ read_csv(.x, skip = 1, col_names = TRUE, show_col_types = FALSE) %>%
                      mutate(
                        source_file = basename(.x),  # Nom du fichier sans le chemin
                        leaf_num = str_extract(source_file, "(?<=leaf_)\\d+") %>% as.integer()  # extrait le numéro après "leaf_"
                      )) %>% 
  drop_na(configName) %>% 
  select(-any_of(c("configAuthor", "configName", "remark", "...8", "...9"))) %>% 
  rename(obs = "Obs#") %>% 
  mutate(
    Time = hms(Time) + hours(7),
    Time = format(Time, "%H:%M:%S"),
    record = as.numeric(Record)
  ) %>%
  select(-Record) %>% 
  mutate(across(where(~ is.character(.) && all(!is.na(suppressWarnings(as.numeric(.))))),
                ~ as.numeric(.)))

# Add the number of the leaf where a measure has been carried out and the plant_information
plant_info <- read_excel(here::here("data/plant_info.xlsx"), col_names = T) %>% 
  dplyr::rename("position"= "tablar position")

n_files <- length(name_files)

df_licor <- df_licor %>% 
  mutate(plant_num = rep(1:40, times = n_files)) %>% 
  #mutate(plant_num = record) %>% 
  left_join(plant_info, by = "plant_num") %>% 
  mutate(genotype=fct_relevel(genotype, "WT1", "W78*", "WT2", "E568K")) %>% 
  filter(plant_num!= 6) %>% 
  mutate(DAP = as.numeric(as.Date(Date)-as.Date("2025-04-10")), 
    leaf_stage = case_when(
      leaf_num == 1 ~ "Last fully expanded leaf",  # première feuille complètement ouverte
      leaf_num == 2 ~ "First reproductive node",    # premier nœud reproducteur
      leaf_num == 3 ~ "Fourth vegetative node"      # quatrième nœud végétatif
    ),
    leaf_stage = factor(leaf_stage,
                        levels = c("Last fully expanded leaf",
                                   "First reproductive node",
                                   "Fourth vegetative node"))
  ) %>% 
  mutate(depodding = ifelse(depodding %in% c("D", "FD"), "Pod removal", "Control"))

# export results

write_csv(x = df_licor, file = here::here("data/physio/LI-COR_LI-600/output/raw_licor.csv"))

4.2 Quick observation of results

For stomatal conductance to water vapour, we look to see if there is an environmental effect.

Code
df_licor <- read_csv(here::here("data/physio/LI-COR_LI-600/output/raw_licor.csv"), show_col_types = FALSE) %>% 
  mutate(depodding = as.factor(depodding),
  depodding = factor(depodding,levels = c("Control",
                                   "Pod removal")))%>% 
  mutate(plant_num = as.factor(plant_num),
         leaf_stage = as.factor(leaf_stage),
         leaf_stage = factor(leaf_stage,
                        levels = c("Last fully expanded leaf",
                                   "First reproductive node",
                                   "Fourth vegetative node")),
         line = as.factor(line),
         genotype = as.factor(genotype),
         genotype=fct_relevel(genotype, "WT1", "W78*", "WT2", "E568K"), 
         DAP = as.factor(DAP)) # %>% 
         #  mutate(DAP = relevel(DAP, ref = "0"))

##### Linea mixed model ######
contrasts(df_licor$genotype) <- contr.sum # to say look at the big average only for genotype (juste an other representation)

mod1=lm(formula = gsw ~ genotype+leaf_stage+row+line+DAP+ depodding, data = df_licor)
p_x<-ggcoef_model(mod1)

fig_export(here::here("report/physio/plot/licor/ggcoef_model_gsw"), p_x, height_i = 7, width_i = 8, res_i = 600)

There is a strong effect of the genotype (whether it’s a mutant or not), a strong effect of the leaf being analyzed and a strong effect of the position in the greenhouse, particularly the row. There is no line effect. So i need to correction for spatial trends.

4.4 Analysis of corrected results

Code
df_licor_leaf_1 = df_licor %>% 
  filter(leaf_num == 1)

df_licor_leaf_2 = df_licor %>% 
  filter(leaf_num == 2)

df_licor_leaf_3 = df_licor %>% 
  filter(leaf_num == 3)

df_licor_leaf_mean = df_licor %>% 
  dplyr::group_by(plant_num, genotype) %>% 
  dplyr::summarise(gsw=mean(gsw), PhiPS2=mean(PhiPS2), Tleaf=mean(Tleaf))

# gsw
p <- stat_analyse(
    data=df_licor_leaf_2 %>% 
      as.data.frame() %>% 
      mutate(genotype=fct_relevel(genotype, "WT1", "W78*", "WT2", "E568K")),
      #mutate(climat_condition=paste0(water_condition,"_",heat_condition)) %>% 
      #mutate(condition=factor(condition,levels=c("Sto_WW_OT","Stoc_WS_OT","Sto_WW_HS","Sto_WS_HS","Wen_WW_OT","Wen_WS_OT","Wen_WW_HS","Wen_WS_HS"))) %>% 
      
    column_value = "gsw",
    category_variables = c("genotype"),
    grp_var = "",
    show_plot = T,
    outlier_show = F, 
    label_outlier = "plant_num",
    biologist_stats = T,
    Ylab_i =  expression(atop("Stomatal conductance to water vapor", 
                         "(mol m"^{-2}~"s"^{-1}*")")),
    control_conditions = "",
    strip_normale = F,
    hex_pallet = c("#003049", "#780000", "#7FACC7", "#EC323E")
)

p <-p[["plot"]]+labs(color="Genotype",fill="Genotype",x="Genotype")
fig_export(here::here("report/physio/plot/licor/gsw_leaf_3"), p, height_i = 3.5, width_i = 4, res_i = 600)

##### Linea mixed model ######
contrasts(df_licor$genotype) <- contr.sum # to say look at the big average only for genotype (juste an other representation)

mod1=lm(formula = gsw ~ genotype+leaf_num+row+line, data = df_licor)
p_x<-ggcoef_model(mod1)

fig_export(here::here("report/physio/plot/licor/ggcoef_model_gsw.svg"), p_x, height_i = 4, width_i = 6, res_i = 600)

# Modèle avec uniquement la position
mod_position <- lm(gsw ~ row + line, data = df_licor)

# Résidus = gsw "corrigé" de l'effet de la position
df_licor <- df_licor %>%
  mutate(gsw_corrected = resid(mod_position))


contrasts(df_licor$genotype) <- contr.sum # to say look at the big average only for genotype (juste an other representation)
mod1_corr <- lm(gsw_corrected ~ genotype + leaf_num, data = df_licor)
p_x <- ggcoef_model(mod1_corr)

df_licor_leaf_2 = df_licor %>% 
  filter(leaf_num == 3)

p <- stat_analyse(
    data=df_licor_leaf_2 %>% 
      as.data.frame() %>% 
      mutate(genotype=fct_relevel(genotype, "WT1", "W78*", "WT2", "E568K")),
      #mutate(climat_condition=paste0(water_condition,"_",heat_condition)) %>% 
      #mutate(condition=factor(condition,levels=c("Sto_WW_OT","Stoc_WS_OT","Sto_WW_HS","Sto_WS_HS","Wen_WW_OT","Wen_WS_OT","Wen_WW_HS","Wen_WS_HS"))) %>% 
      
    column_value = "gsw_corrected",
    category_variables = c("genotype"),
    grp_var = "",
    show_plot = T,
    outlier_show = F, 
    label_outlier = "plant_num",
    biologist_stats = T,
    Ylab_i =  expression(atop("Stomatal conductance to water vapor", 
                         "(mol m"^{-2}~"s"^{-1}*")")),
    control_conditions = "",
    strip_normale = F,
    hex_pallet = c("#003049", "#780000", "#7FACC7", "#EC323E")
)

p <-p[["plot"]]+labs(color="Genotype",fill="Genotype",x="Genotype")
fig_export(here::here("report/physio/plot/licor/gsw_leaf_2_corrected"), p, height_i = 3.5, width_i = 4, res_i = 600)

# fluoro
p <- stat_analyse(
    data=df_licor_leaf_3 %>% 
      as.data.frame() %>% 
      mutate(genotype=fct_relevel(genotype, "WT1", "W78*", "WT2", "E568K")),
      #mutate(climat_condition=paste0(water_condition,"_",heat_condition)) %>% 
      #mutate(condition=factor(condition,levels=c("Sto_WW_OT","Stoc_WS_OT","Sto_WW_HS","Sto_WS_HS","Wen_WW_OT","Wen_WS_OT","Wen_WW_HS","Wen_WS_HS"))) %>% 
      
    column_value = "PhiPS2",
    category_variables = c("genotype"),
    grp_var = "",
    show_plot = T,
    outlier_show = F, 
    label_outlier = "plant_num",
    biologist_stats = T,
    Ylab_i =  expression("PhiPS2 (1-Fs/Fm’)"),
    control_conditions = "",
    strip_normale = F,
    hex_pallet = c("#003049", "#780000", "#7FACC7", "#EC323E")
)

p <-p[["plot"]]+labs(color="Genotype",fill="Genotype",x="Genotype")

fig_export(here::here("report/physio/plot/licor/PhiPS2_leaf_3"), p, height_i = 3.5, width_i = 4, res_i = 600)

# temperature leaf
p <- stat_analyse(
    data=df_licor_leaf_2 %>% 
      as.data.frame() %>% 
      mutate(genotype=fct_relevel(genotype, "WT1", "W78*", "WT2", "E568K")),
      #mutate(climat_condition=paste0(water_condition,"_",heat_condition)) %>% 
      #mutate(condition=factor(condition,levels=c("Sto_WW_OT","Stoc_WS_OT","Sto_WW_HS","Sto_WS_HS","Wen_WW_OT","Wen_WS_OT","Wen_WW_HS","Wen_WS_HS"))) %>% 
      
    column_value = "Tleaf",
    category_variables = c("genotype"),
    grp_var = "",
    show_plot = T,
    outlier_show = F, 
    label_outlier = "plant_num",
    biologist_stats = T,
    Ylab_i =  expression("Leaf temperature (°C)"),
    control_conditions = "",
    strip_normale = F,
    hex_pallet = c("#003049", "#780000", "#7FACC7", "#EC323E")
)

p <-p[["plot"]]+labs(color="Genotype",fill="Genotype",x="Genotype")

fig_export(here::here("report/physio/plot/licor/Tleaf_leaf_2"), p, height_i = 3.5, width_i = 4, res_i = 600)

df_licor_leaf_choice <- df_licor_leaf_2 %>% 
  dplyr::rename("Fm_bis" = "Fm'")

vars_non_nulles <- df_licor_leaf_choice %>%
  dplyr::select(-c("obs","plant_num","line","record")) %>% 
  dplyr::select(where(is.numeric)) %>%
  dplyr::summarise(across(everything(), var, na.rm = TRUE)) %>%
  pivot_longer(everything(), names_to = "variable", values_to = "variance") %>%
  filter(variance != 0) %>%
  pull(variable)

for (i in vars_non_nulles){
  p <- stat_analyse(
    data=df_licor_leaf_choice %>% 
      as.data.frame() %>% 
      mutate(genotype=fct_relevel(genotype, "WT1", "W78*", "WT2", "E568K")),
      #mutate(climat_condition=paste0(water_condition,"_",heat_condition)) %>% 
      #mutate(condition=factor(condition,levels=c("Sto_WW_OT","Stoc_WS_OT","Sto_WW_HS","Sto_WS_HS","Wen_WW_OT","Wen_WS_OT","Wen_WW_HS","Wen_WS_HS"))) %>% 
      
    column_value = i,
    category_variables = c("genotype"),
    grp_var = "",
    show_plot = T,
    outlier_show = F, 
    label_outlier = "plant_num",
    biologist_stats = T,
    Ylab_i =  i,
    control_conditions = "",
    strip_normale = F,
    hex_pallet = c("#003049", "#780000", "#7FACC7", "#EC323E")
)

p <-p[["plot"]]+labs(color="Genotype",fill="Genotype",x="Genotype")

fig_export(here::here(paste0("report/physio/plot/licor/test/",i)), p, height_i = 3.5, width_i = 4, res_i = 600, format = "png")
}

4.5 Cinetic of the different measure

Code
df_licor <- read_csv(here::here("data/physio/LI-COR_LI-600/output/raw_licor.csv"), show_col_types = FALSE) %>% 
  mutate(depodding = as.factor(depodding),
  depodding = factor(depodding,levels = c("Control",
                                   "Pod removal")))%>% 
  mutate(plant_num = as.factor(plant_num),
         leaf_stage = as.factor(leaf_stage),
         leaf_stage = factor(leaf_stage,
                        levels = c("Last fully expanded leaf",
                                   "First reproductive node",
                                   "Fourth vegetative node")),
         line = as.factor(line),
         genotype = as.factor(genotype),
         genotype=fct_relevel(genotype, "WT1", "W78*", "WT2", "E568K"), 
         DAP = as.factor(DAP)) # %>% 
         #  mutate(DAP = relevel(DAP, ref = "0"))
# gsw Tleaf
df_licor %>%
  mutate(leaf_stage = factor(leaf_stage,
                        levels = c("First fully expanded leaf",
                                   "First reproductive node",
                                   "Fourth vegetative node"))) %>% 
  dplyr::group_by(DAP, genotype, leaf_stage) %>%
  dplyr::summarise(
    gsw_mean = mean(gsw, na.rm = TRUE),
    gsw_sd = sd(gsw, na.rm = TRUE),
    PhiPS2_mean = mean(PhiPS2, na.rm = TRUE),
    PhiPS2_sd = sd(PhiPS2, na.rm = TRUE),
    .groups = "drop"
  ) %>%
  mutate(DAP = as.factor(DAP)) %>%   # <- important pour bien séparer les dates
  ggplot(aes(x = DAP, y = PhiPS2_mean, color = genotype)) +
  geom_point(position = position_dodge(width = 0.5), size = 2) +
  geom_errorbar(aes(ymin = PhiPS2_mean - PhiPS2_sd, ymax = PhiPS2_mean + PhiPS2_sd),
                width = 0.2, position = position_dodge(width = 0.5)) +
  facet_wrap(~ leaf_stage, nrow = 1) +
  theme_bw(base_size = 12) +
  theme(
    legend.position = "bottom",
    axis.text.x = element_text(hjust = 1),
    panel.spacing = unit(0.5, "lines")
  )+  scale_color_manual(values = mutant_palette)

# with smooth
p1 <- df_licor %>%
   mutate(depodding = as.factor(depodding),
  depodding = factor(depodding,levels = c("Control",
                                   "Pod removal")))%>% 
  mutate(DAP = as.numeric(as.character(DAP))) %>%
  ggplot(aes(x = DAP, y = PhiPS2, color = genotype, linetype = depodding)) +
  geom_smooth(method = "loess", se = TRUE, alpha = 0.2) +
  facet_wrap(~ leaf_stage, nrow = 1) +
  scale_x_continuous(breaks = unique(as.numeric(as.character(df_licor$DAP)))) +
  theme_bw(base_size = 12) +
  theme(
    panel.grid.major = element_line(color = "gray85"),  # Lignes de grille légères
    panel.grid.minor = element_blank(),  # Suppression des petites grilles
    strip.text = element_text(face = "bold"),  
    legend.position = "right"
  )+
  #scale_fill_manual(values = mutant_palette)+
  scale_color_manual(values = mutant_palette)+
  labs(y= "ΦPSII – Effective quantum yield \nof photosystem II", 
         color= "Genotype", 
         linetype = "Depodding") ; p1

p2 <- df_licor %>%
  mutate(depodding = as.factor(depodding),
  depodding = factor(depodding,levels = c("Control",
                                   "Pod removal")))%>% 
  mutate(DAP = as.numeric(as.character(DAP))) %>%
  ggplot(aes(x = DAP, y = gsw, color = genotype, linetype = depodding)) +
  geom_smooth(method = "loess", se = TRUE, alpha=0.2) +
  facet_wrap(~ leaf_stage, nrow = 1) +
  scale_color_manual(values = mutant_palette) +
  scale_x_continuous(breaks = unique(as.numeric(as.character(df_licor$DAP)))) +
  theme_bw(base_size = 12) +
  theme(
    legend.position = "bottom"
  ) +  labs(
    y = expression("Stomatal conductance"~(mol~m^{-2}~s^{-1})),
    color = "Genotype", 
    linetype = "Depodding"
  ) 

final_plot <- (p1 / p2) + plot_layout(guides = "collect") & theme(legend.position = "bottom")& plot_annotation(tag_levels = "A")

fig_export(here::here(paste0("report/physio/plot/licor/PhiPS2_gsw_cinetic")), final_plot, height_i = 8, width_i = 8, res_i = 600)

df_fig<- df_licor %>%
  filter(leaf_stage == "Fourth vegetative node") %>% 
  mutate(depodding = as.factor(depodding),
  depodding = factor(depodding,levels = c("Control",
                                   "Pod removal")), 
  for_article = ifelse(depodding == "Control", "All pod", "Consistent pod number"),
  for_article = factor(for_article,levels = c("All pod",
                                   "Consistent pod number"))
  )%>% 
  mutate(DAP = as.numeric(as.character(DAP)))

final_plot <- (p1 / p2) + plot_layout(guides = "collect") & theme(legend.position = "bottom")& plot_annotation(tag_levels = "A")
fig_export(here::here(paste0("report/physio/plot/licor/PhiPS2_gsw_cinetic")), final_plot, height_i = 8, width_i = 8, res_i = 600)

################# for article ###########################
p1_fig = ggplot(df_fig, aes(x = DAP, y = PhiPS2, color = genotype,fill = genotype,  linetype = for_article)) +
  geom_smooth(method = "loess", se = TRUE, alpha=0.10) +
  facet_wrap(~ leaf_stage, nrow = 1) +
  #geom_vline(xintercept=c(47), linetype="dotted", linewidth = 1.2)+
  scale_color_manual(values = mutant_palette) +
  scale_fill_manual(values = mutant_palette) +
  scale_x_continuous(breaks = unique(as.numeric(as.character(df_licor$DAP)))) +
  theme_bw(base_size = 12) +
  theme(
    legend.position = "bottom"
  ) +  labs(
    y =  "ΦPSII – Effective quantum yield \nof photosystem II",
    color = "Genotype", 
    fill = "Genotype", 
    linetype = "Depodding"
  ) ; p1_fig

p_fig_stats <- stat_analyse(
    data=df_fig %>% 
      # as.data.frame() %>% 
      # mutate(genotype=fct_relevel(genotype, "WT1", "W78*", "WT2", "E568K")) %>%
      mutate(geno_depod = paste0(genotype, "_", for_article), 
             geno_depod = factor(geno_depod, levels = c(
               "WT1_All pod","W78*_All pod","WT2_All pod","E568K_All pod",
               "WT1_Consistent pod number","W78*_Consistent pod number","WT2_Consistent pod number","E568K_Consistent pod number"))) %>% 
      filter(DAP == 47, leaf_stage == "Fourth vegetative node"),
      #mutate(climat_condition=paste0(water_condition,"_",heat_condition)) %>% 
      #mutate(condition=factor(condition,levels=c("Sto_WW_OT","Stoc_WS_OT","Sto_WW_HS","Sto_WS_HS","Wen_WW_OT","Wen_WS_OT","Wen_WW_HS","Wen_WS_HS"))) %>% 
      
    column_value = "PhiPS2",
    category_variables = c("geno_depod"),
    grp_var = "",
    show_plot = T,
    outlier_show = F, 
    label_outlier = "plant_num",
    biologist_stats = T,
    Ylab_i ="ΦPSII – Effective quantum yield of photosystem II\ at 41 DAF",
    control_conditions = "",
    strip_normale = F,
    hex_pallet = c("#003049", "#780000", "#7FACC7", "#EC323E", "#003049", "#780000", "#7FACC7", "#EC323E")
)

p_fig_stats_2 <- p_fig_stats[["plot"]]+theme(legend.position = "none", 
                                             axis.text.x = element_text(
                                               angle = 90,
                                               vjust = 0.5,
                                               hjust = 1))+
                                             labs(color = "Genotype", fill = "Genotype", x = "", y = "ΦPSII – Effective quantum yield of \nphotosystem II at 41 DAF")

p_fig_combine <- p1_fig/p_fig_stats_2+ plot_layout(guides = "collect") & theme(legend.position = "right")#& plot_annotation(tag_levels = "A")
 
fig_export(here::here(paste0("report/physio/plot/licor/PhiPS2_gsw_cinetic_vegetative_leaves_all")), p_fig_combine, height_i = 8, width_i = 6, res_i = 600)

############################## if i select only control condition ##################################

p1_fig = ggplot(df_fig %>% filter(depodding == "Control"), aes(x = DAP, y = PhiPS2, color = genotype,fill = genotype,  linetype = for_article)) +
  geom_smooth(method = "loess", se = TRUE, alpha=0.10) +
  facet_wrap(~ leaf_stage, nrow = 1) +
  #geom_vline(xintercept=c(47), linetype="dotted", linewidth = 1.2)+
  scale_color_manual(values = mutant_palette) +
  scale_fill_manual(values = mutant_palette) +
  scale_x_continuous(breaks = unique(as.numeric(as.character(df_licor$DAP)))) +
  theme_bw(base_size = 12) +
  theme(
    legend.position = "bottom"
  ) +  labs(
    y =  "ΦPSII – Effective quantum yield \nof photosystem II",
    color = "Genotype", 
    fill = "Genotype", 
    linetype = "Depodding"
  ) ; p1_fig

p_fig_stats <- stat_analyse(
    data=df_fig %>% 
      filter(depodding == "Control") %>% 
      # as.data.frame() %>% 
      # mutate(genotype=fct_relevel(genotype, "WT1", "W78*", "WT2", "E568K")) %>%
      mutate(geno_depod = paste0(genotype, "_", for_article), 
             geno_depod = factor(geno_depod, levels = c(
               "WT1_All pod","W78*_All pod","WT2_All pod","E568K_All pod",
               "WT1_Consistent pod number","W78*_Consistent pod number","WT2_Consistent pod number","E568K_Consistent pod number"))) %>% 
      filter(DAP == 47, leaf_stage == "Fourth vegetative node"),
      #mutate(climat_condition=paste0(water_condition,"_",heat_condition)) %>% 
      #mutate(condition=factor(condition,levels=c("Sto_WW_OT","Stoc_WS_OT","Sto_WW_HS","Sto_WS_HS","Wen_WW_OT","Wen_WS_OT","Wen_WW_HS","Wen_WS_HS"))) %>% 
      
    column_value = "PhiPS2",
    category_variables = c("geno_depod"),
    grp_var = "",
    show_plot = T,
    outlier_show = F, 
    label_outlier = "plant_num",
    biologist_stats = T,
    Ylab_i = "ΦPSII – Effective quantum yield of photosystem II at 41 DAF",
    control_conditions = "",
    strip_normale = F,
    hex_pallet = c("#003049", "#780000", "#7FACC7", "#EC323E", "#003049", "#780000", "#7FACC7", "#EC323E")
)

p_fig_stats_2 <- p_fig_stats[["plot"]]+theme(legend.position = "none", 
                                             axis.text.x = element_text(
                                               angle = 90,
                                               vjust = 0.5,
                                               hjust = 1)
                                             )+labs(color = "Genotype", fill = "Genotype", x = "", y = "ΦPSII – Effective quantum yield of \nphotosystem II at 41 DAF")

p_fig_combine <- p1_fig/p_fig_stats_2+ plot_layout(guides = "collect") & theme(legend.position = "right")#& plot_annotation(tag_levels = "A")
 
fig_export(here::here(paste0("report/physio/plot/licor/PhiPS2_gsw_cinetic_vegetative_leaves_control")), p_fig_combine, height_i = 7, width_i = 4.5, res_i = 600)

# measure last at 47 day
 p <- stat_analyse(
    data=df_licor %>% 
      as.data.frame() %>% 
      mutate(genotype=fct_relevel(genotype, "WT1", "W78*", "WT2", "E568K")) %>%
      mutate(geno_depod = paste0(genotype, "_", depodding)) %>% 
      filter(DAP == 47, leaf_stage == "Fourth vegetative node"),
      #mutate(climat_condition=paste0(water_condition,"_",heat_condition)) %>% 
      #mutate(condition=factor(condition,levels=c("Sto_WW_OT","Stoc_WS_OT","Sto_WW_HS","Sto_WS_HS","Wen_WW_OT","Wen_WS_OT","Wen_WW_HS","Wen_WS_HS"))) %>% 
      
    column_value = "PhiPS2",
    category_variables = c("geno_depod"),
    grp_var = "",
    show_plot = T,
    outlier_show = F, 
    label_outlier = "plant_num",
    biologist_stats = T,
    Ylab_i = "ΦPSII – Effective quantum yield \nof photosystem II",
    control_conditions = "",
    strip_normale = F,
    hex_pallet = c("#003049", "#780000", "#7FACC7", "#EC323E", "#003049", "#780000", "#7FACC7", "#EC323E")
)

p <-p[["plot"]]+labs(color="Genotype",fill="Genotype",x="Genotype")

# without taking into acount pod removal
 p <- stat_analyse(
    data=df_licor %>% 
      as.data.frame() %>% 
      mutate(genotype=fct_relevel(genotype, "WT1", "W78*", "WT2", "E568K")) %>%
      mutate(geno_depod = paste0(genotype, "_", depodding)) %>% 
      filter(DAP == 47, leaf_stage == "Fourth vegetative node"),
      #mutate(climat_condition=paste0(water_condition,"_",heat_condition)) %>% 
      #mutate(condition=factor(condition,levels=c("Sto_WW_OT","Stoc_WS_OT","Sto_WW_HS","Sto_WS_HS","Wen_WW_OT","Wen_WS_OT","Wen_WW_HS","Wen_WS_HS"))) %>% 
      
    column_value = "PhiPS2",
    category_variables = c("genotype"),
    grp_var = "",
    show_plot = T,
    outlier_show = F, 
    label_outlier = "plant_num",
    biologist_stats = T,
    Ylab_i = "ΦPSII – Effective quantum yield \nof photosystem II",
    control_conditions = "",
    strip_normale = F,
    hex_pallet = c("#003049", "#780000", "#7FACC7", "#EC323E", "#003049", "#780000", "#7FACC7", "#EC323E")
)

p <-p[["plot"]]+labs(color="Genotype",fill="Genotype",x="Genotype")