Experimento Acidos Grasos

Author

Javier Atalah

Published

June 11, 2024

1 Data preparation

Read the data and transpose it, meaning the variables become columns and the observations become rows. This is the recommended format for statistical data analysis.

Code
library(tidyverse)
library(readxl)
library(janitor)
library(skimr)
library(knitr)
library(ggord)
library(vegan, quietly = T)
library(ggvegan)
library(lmerTest, quietly = T)
library(broom.mixed)
options(knitr.kable.NA = '')

theme_set(theme_minimal())

path <- "data/Perfil Ácidos Grasos (Javier).xlsx"

data <-
  left_join(
  suppressMessages(read_excel(path, sheet = 1, col_names = F)) %>% 
  t() %>% 
  as_tibble() %>% 
  row_to_names(row_number = 1),  
  suppressMessages(read_excel(path, sheet = 2, col_names = F)) %>% 
  t() %>% 
  as_tibble() %>% 
  row_to_names(row_number = 1) %>% 
  mutate(across(-1, as.numeric)), join_by(Código)) %>% 
  drop_na() %>% 
  mutate(Tiempo = fct_relevel(Tiempo, "0", "3", "6", "12"))

2 Data exploration

Code
data %>% 
  group_by(Tiempo, Calor, Congelado, Tratamiento) %>% 
  count() %>% 
  kable()
Table 1: Number of observations by treatment levels.
Tiempo Calor Congelado Tratamiento n
0 - No Liofilizado 5
0 60 No Q1 4
0 75 No Q2 5
0 No No Fresco 4
3 - No Liofilizado 5
3 60 -20 Q1C 5
3 60 -80 Q1U 5
3 75 -20 Q2C 4
3 75 -80 Q2C 5
3 No -20 Congelado 5
3 No -80 Ultracongelado 5
6 - No Liofilizado 3
6 60 -20 Q1C 5
6 60 -80 Q1U 5
6 75 -20 Q2C 5
6 75 -80 Q2C 5
6 No -20 Congelado 5
6 No -80 Ultraongelado 4
12 - No Liofilizado 5
12 60 -20 Q1C 5
12 60 -80 Q1U 4
12 75 -20 Q2C 4
12 75 -80 Q2C 5
12 No -20 Congelado 5
12 No -80 Ultraongelado 4

Review the data using the skim function to gain a general understanding of the experimental design, response variables, and factors.

Based on the data summary provided by the skim function, the dataset consists of 87 rows and 39 columns. The variables include both categorical and numerical variables, with 7 categorical variables and 32 numerical variables, mosty fatty acids.

Upon reviewing the categorical variables, it is noted that the variable “Tiempo” has 3 unique values, “Calor” has 4 unique values, “Congelado” has 3 unique values, “Tratamiento” has 10 unique values, “Réplica” has 5 unique values, “Etiqueta original” has 87 unique values, and “Código” has 87 unique values.

Mean and standard deviations are recorded for the different fats and fatty acids, along with statistics such as the minimum value, the 25th percentile, the median, the 75th percentile, and the maximum value for each variable.

Code
skim(data)
Table 2: Data summaries
Data summary
Name data
Number of rows 116
Number of columns 39
_______________________
Column type frequency:
character 6
factor 1
numeric 32
________________________
Group variables None

Variable type: character

skim_variable n_missing complete_rate min max empty n_unique whitespace
Calor 0 1 1 2 0 4 0
Congelado 0 1 2 3 0 3 0
Tratamiento 0 1 2 14 0 10 0
Réplica 0 1 1 1 0 5 0
Etiqueta original 0 1 3 9 0 116 0
Código 0 1 4 8 0 116 0

Variable type: factor

skim_variable n_missing complete_rate ordered n_unique top_counts
Tiempo 0 1 FALSE 4 3: 34, 6: 32, 12: 32, 0: 18

Variable type: numeric

skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
C12 0 1 0.27 0.23 0.00 0.15 0.20 0.32 1.49 ▇▃▁▁▁
C16 0 1 21.96 3.76 16.27 19.65 20.93 22.89 34.47 ▅▇▁▁▁
C18 0 1 7.06 1.33 4.79 5.97 6.80 7.85 10.60 ▆▇▆▂▂
C20 0 1 0.29 0.20 0.00 0.00 0.35 0.40 0.90 ▆▅▇▁▁
C22 0 1 0.79 0.47 0.00 0.39 0.75 1.11 1.81 ▇▇▇▆▃
C24 0 1 0.85 0.66 0.00 0.38 0.73 1.02 4.18 ▇▅▁▁▁
Total saturados 0 1 31.22 4.96 23.90 27.56 30.24 33.47 44.63 ▆▇▅▁▂
C16:1 n-9 0 1 0.52 0.27 0.00 0.31 0.50 0.69 1.48 ▅▇▆▂▁
C16:1 n-7 0 1 1.28 0.26 0.77 1.12 1.25 1.37 2.25 ▂▇▂▁▁
C18:1 n-9 0 1 14.43 2.24 10.04 12.94 13.97 15.35 22.17 ▂▇▃▁▁
C18:1 n-7 0 1 1.95 0.51 1.23 1.67 1.81 2.07 4.58 ▇▃▁▁▁
C20:1 n-9 0 1 0.95 0.71 0.00 0.26 0.82 1.76 2.39 ▇▅▂▃▃
C22:1 n-9 0 1 0.28 0.19 0.00 0.19 0.23 0.29 0.91 ▃▇▁▂▁
C24:1 n-9 0 1 0.35 0.09 0.00 0.30 0.35 0.41 0.70 ▁▂▇▂▁
Total monosaturados 0 1 19.78 2.77 15.07 17.96 19.23 21.05 28.37 ▃▇▃▁▁
C18:2 n-6 0 1 4.49 0.99 2.16 3.79 4.46 4.98 7.36 ▂▇▇▃▁
C18:3 n-6 0 1 0.15 0.21 0.00 0.00 0.05 0.38 0.89 ▇▁▂▁▁
C20:2 n-6 0 1 1.30 0.25 0.00 1.17 1.25 1.37 2.28 ▁▁▇▂▁
C20:3n-6 0 1 0.26 0.28 0.00 0.12 0.18 0.28 1.55 ▇▁▁▁▁
C20:4 n-6 0 1 2.90 0.64 0.00 2.72 2.97 3.19 4.37 ▁▁▂▇▁
C22:2 n-6 0 1 0.24 0.25 0.00 0.16 0.21 0.27 2.14 ▇▁▁▁▁
C22:4 n-6 0 1 0.52 0.37 0.00 0.25 0.45 0.70 2.15 ▇▆▂▁▁
C22:5 n-6 0 1 0.68 0.18 0.00 0.62 0.70 0.78 1.26 ▁▁▇▃▁
PUFA - omega 6 0 1 10.54 1.37 6.12 9.69 10.73 11.40 13.44 ▁▁▇▇▃
C18:3 n-3 0 1 1.40 0.86 0.00 0.42 1.46 2.16 3.41 ▇▂▆▇▁
C18:4 n-3 0 1 0.63 0.14 0.00 0.56 0.62 0.69 1.04 ▁▁▇▇▁
C20:3 n-3 0 1 0.30 0.31 0.08 0.21 0.25 0.29 2.51 ▇▁▁▁▁
C20:5 n-3 0 1 15.03 2.07 8.20 14.22 15.64 16.43 18.96 ▁▁▃▇▂
C22:5 n-3 0 1 0.69 0.24 0.00 0.55 0.63 0.79 1.58 ▁▇▆▂▁
C22:6 n-3 0 1 20.42 4.29 6.65 19.57 21.50 23.00 26.70 ▁▁▂▇▅
PUFA - OMEGA 3 0 1 38.46 5.80 19.01 37.33 39.98 42.41 46.04 ▁▁▂▇▇
Ratio w3/w6 0 1 3.68 0.63 2.37 3.28 3.63 4.04 6.16 ▂▇▅▁▁
Code
data_long <-
  data %>%
  pivot_longer(cols = -c(Tiempo:Código)) %>%
  filter(
    name %in% c(
      "total saturados",
      "Total monosaturados",
      "PUFA - omega 6",
      "PUFA - OMEGA 3",
      "Ratio w3/w6"
    )
  )

# boxplot_func <- function(factor){
# ggplot(data_long, aes(y = value, name, fill = {{factor}})) +
#   geom_boxplot(size = .25) +
#   scale_y_continuous(trans = 'log10') +
#   coord_flip() +
#   labs(x = NULL, y = NULL) +
#   scale_fill_discrete() +
#   theme(legend.position = "bottom", legend.key.size = unit(.5, "cm")) +
#   facet_wrap( ~ Tiempo, labeller = label_both)}

lines_plot_func <- function(factor){
  ggplot(data_long,
         aes(
           y = value,
           Tiempo,
           group = {{factor}},
           color = {{factor}}
         ),
         position = position_dodge(width = .2)) +
    stat_summary(fun.data = "mean_cl_boot", size = .25) +
    stat_summary(fun = "mean", geom = 'line') +
    labs(y = "%") +
    theme(legend.position = "bottom",
          legend.key.size = unit(.5, "cm")) +
    facet_wrap(~ name, scales = 'free')}


lines_plot_func(factor = Calor)
Figure 1: Boxplot of fatty acids across different experimental times, categorised by calor levels. The y-axis is presented on a logarithmic scale.
Code
lines_plot_func(factor = Congelado)
Figure 2: Boxplot of fatty acids across different experimental times, categorised by Congelado levels. The y-axis is presented on a logarithmic scale.
Code
lines_plot_func(factor = Tratamiento)
Figure 3: Boxplot of fatty acids across different experimental times, categorised by Treatment levels. The y-axis is presented on a logarithmic scale.

3 Multivariate analysis

Multivariate analyses were conducted to describe patterns and identify drivers of changes in fatty acid composition using the vegan R library (Oksanen et al. 2012). Analyses were conducted based on Bray-Curtis dissimilarities of the log10 (x + 1) transformed data. Non-metric multidimensional scaling was used to visualise patterns in the multivariate data independent of predictor variables.

Code
t_data <-
  data %>%
  select(`Total saturados`:`Ratio w3/w6`) %>%
  mutate_all(
    .funs = function(x)
      log10((x + 1))
  )

ord <- metaMDS(t_data, trace = F)

ord_d <- 
fortify(ord) %>% 
  filter(Score == "sites") %>% 
  bind_cols(data)

ord_plot_func <- function(factor){
ggplot(ord_d, aes(NMDS1, NMDS2, color = {{factor}})) +
  geom_point() +
  stat_ellipse() +
  facet_wrap( ~ Tiempo, labeller = label_both) +
  theme(legend.position = 'bottom')}



ord_plot_func(factor = Tratamiento)
ord_plot_func(factor = Calor)
ord_plot_func(factor = Congelado)
Figure 4: MDS plot Tratamiento
Figure 5: MDS plot Calor
Figure 6: MDS plot Congelado

The differences in lipid profiles between Treatment, Time, Congelado, and Calor were tested using distance-based permutational multivariate multiple regression using 999 permutations.

Code
permanova_fa <-
  adonis2(
    t_data ~ (Calor + Congelado + Tratamiento)* Tiempo,
    data = data,
    method = 'bray',
    by = 'terms',
    permutations = 999
  )

permanova_fa %>%
  as_tibble(rownames = 'Term') %>%
  mutate(across(where(is.numeric), ~ round(.x, 3))) %>%
  rename(P = `Pr(>F)`, SS = SumOfSqs) %>%
  mutate(P = scales::pvalue(P)) %>% 
  kable(digits = 3)
Table 3: Results of PERMANOVA testing the effects of Calor, Congelado, Tratamiento and their interaction with Tiempo based on Bray-Curis dissimmilarities of the log transformed fatty acid data.
Term Df SS R2 F P
Calor 3 0.078 0.246 24.076 0.001
Congelado 2 0.014 0.045 6.609 0.001
Tratamiento 5 0.016 0.052 3.058 0.001
Tiempo 3 0.075 0.237 23.237 0.001
Calor:Tiempo 6 0.024 0.076 3.734 0.001
Congelado:Tiempo 2 0.005 0.017 2.456 0.019
Tratamiento:Tiempo 3 0.006 0.018 1.813 0.033
Residual 91 0.098 0.309
Total 115 0.316 1.000

4 Univariate analyses

Differences in fatty acid composition, including total saturated, total monounsaturated, PUFA - omega 6, PUFA - omega 3, and the omega 3 to omega 6 ratio, were assessed using linear mixed models. The fixed effects included Calor, Congelado, Tratamiento, and Tiempo. Sample ID was incorporated as a random effect to address the repeated measures experimental design.

Code
data_long <-
  data %>%
  pivot_longer(cols = c(`Total saturados`:`Ratio w3/w6`)) %>% 
  # mutate(ID = str_replace(Código, "T[0-9]+", "")) %>% 
  mutate(ID = paste(Calor, Congelado, Tratamiento, Réplica, sep = "_"), .after = "Réplica")


lmms <- 
  data_long %>%
    filter(
    name %in% c(
      "total saturados",
      "Total monosaturados",
      "PUFA - omega 6",
      "PUFA - OMEGA 3",
      "Ratio w3/w6"
    )) %>% 
  group_by(name) %>%
  mutate(value = value) %>%
  nest() %>%
  mutate(
    lmms = map(
      data,
      ~ lmerTest::lmer(
        value  ~
          Calor + Congelado + Tratamiento + Tiempo + (1|ID),
         data = .x
      )),
    lmms_table = map(lmms, tidy)
  )


lmms %>%
  select(lmms_table) %>%
  unnest(cols = c(lmms_table)) %>% 
  mutate(across(where(is.numeric), ~ round(.x, 2)),
         p.value  = scales::pvalue(p.value)) %>% 
  kable(digits = 2)
Table 4: Summary of linear mixed models testing the effects Calor, Congelado, Tratamiento, and Tiempo of selected fatty acid variables. Sample ID was incorporated as a random effect to address the repeated measures experimental design.
name effect group term estimate std.error statistic df p.value
Total monosaturados fixed (Intercept) 11.31 1.38 8.22 96.32 <0.001
Total monosaturados fixed Calor60 1.10 0.97 1.13 76.49 0.260
Total monosaturados fixed Calor75 0.65 0.82 0.79 99.07 0.430
Total monosaturados fixed CalorNo 1.75 0.98 1.80 77.08 0.080
Total monosaturados fixed Congelado-80 0.08 0.52 0.15 29.98 0.880
Total monosaturados fixed CongeladoNo 8.16 0.96 8.50 101.71 <0.001
Total monosaturados fixed TratamientoFresco -2.42 1.02 -2.38 79.23 0.020
Total monosaturados fixed TratamientoQ1 -0.53 1.01 -0.52 78.70 0.600
Total monosaturados fixed TratamientoQ1C 2.39 0.73 3.26 29.13 <0.001
Total monosaturados fixed TratamientoUltracongelado -0.02 0.88 -0.02 58.25 0.990
Total monosaturados fixed TratamientoUltraongelado -0.38 0.80 -0.48 39.40 0.630
Total monosaturados fixed Tiempo3 6.15 0.69 8.97 66.60 <0.001
Total monosaturados fixed Tiempo6 4.72 0.70 6.79 67.69 <0.001
Total monosaturados fixed Tiempo12 7.22 0.68 10.57 66.74 <0.001
Total monosaturados ran_pars ID sd__(Intercept) 0.34
Total monosaturados ran_pars Residual sd__Observation 1.26
PUFA - omega 6 fixed (Intercept) 10.90 1.11 9.81 102.00 <0.001
PUFA - omega 6 fixed Calor60 1.55 0.76 2.05 102.00 0.040
PUFA - omega 6 fixed Calor75 0.48 0.65 0.73 102.00 0.470
PUFA - omega 6 fixed CalorNo 2.00 0.76 2.63 102.00 0.010
PUFA - omega 6 fixed Congelado-80 0.74 0.39 1.89 102.00 0.060
PUFA - omega 6 fixed CongeladoNo -0.56 0.77 -0.73 102.00 0.470
PUFA - omega 6 fixed TratamientoFresco -2.18 0.80 -2.74 102.00 0.010
PUFA - omega 6 fixed TratamientoQ1 -0.21 0.79 -0.26 102.00 0.790
PUFA - omega 6 fixed TratamientoQ1C 0.42 0.55 0.77 102.00 0.440
PUFA - omega 6 fixed TratamientoUltracongelado -1.68 0.68 -2.48 102.00 0.010
PUFA - omega 6 fixed TratamientoUltraongelado -0.68 0.60 -1.12 102.00 0.270
PUFA - omega 6 fixed Tiempo3 -1.57 0.56 -2.80 102.00 0.010
PUFA - omega 6 fixed Tiempo6 -2.35 0.57 -4.12 102.00 <0.001
PUFA - omega 6 fixed Tiempo12 -1.27 0.56 -2.27 102.00 0.030
PUFA - omega 6 ran_pars ID sd__(Intercept) 0.00
PUFA - omega 6 ran_pars Residual sd__Observation 1.03
PUFA - OMEGA 3 fixed (Intercept) 53.93 2.84 18.99 102.00 <0.001
PUFA - OMEGA 3 fixed Calor60 0.65 1.94 0.33 102.00 0.740
PUFA - OMEGA 3 fixed Calor75 1.54 1.67 0.92 102.00 0.360
PUFA - OMEGA 3 fixed CalorNo 2.14 1.95 1.10 102.00 0.280
PUFA - OMEGA 3 fixed Congelado-80 2.58 1.00 2.57 102.00 0.010
PUFA - OMEGA 3 fixed CongeladoNo -13.00 1.97 -6.60 102.00 <0.001
PUFA - OMEGA 3 fixed TratamientoFresco -3.03 2.04 -1.49 102.00 0.140
PUFA - OMEGA 3 fixed TratamientoQ1 1.61 2.03 0.79 102.00 0.430
PUFA - OMEGA 3 fixed TratamientoQ1C -0.35 1.40 -0.25 102.00 0.800
PUFA - OMEGA 3 fixed TratamientoUltracongelado -3.38 1.74 -1.95 102.00 0.050
PUFA - OMEGA 3 fixed TratamientoUltraongelado -2.62 1.55 -1.70 102.00 0.090
PUFA - OMEGA 3 fixed Tiempo3 -14.07 1.44 -9.77 102.00 <0.001
PUFA - OMEGA 3 fixed Tiempo6 -17.49 1.46 -11.97 102.00 <0.001
PUFA - OMEGA 3 fixed Tiempo12 -17.29 1.44 -12.03 102.00 <0.001
PUFA - OMEGA 3 ran_pars ID sd__(Intercept) 0.00
PUFA - OMEGA 3 ran_pars Residual sd__Observation 2.64
Ratio w3/w6 fixed (Intercept) 5.28 0.54 9.86 102.00 <0.001
Ratio w3/w6 fixed Calor60 -0.47 0.37 -1.30 102.00 0.200
Ratio w3/w6 fixed Calor75 -0.01 0.32 -0.04 102.00 0.970
Ratio w3/w6 fixed CalorNo -0.57 0.37 -1.56 102.00 0.120
Ratio w3/w6 fixed Congelado-80 -0.14 0.19 -0.72 102.00 0.470
Ratio w3/w6 fixed CongeladoNo -1.31 0.37 -3.54 102.00 <0.001
Ratio w3/w6 fixed TratamientoFresco 0.63 0.38 1.64 102.00 0.100
Ratio w3/w6 fixed TratamientoQ1 0.21 0.38 0.54 102.00 0.590
Ratio w3/w6 fixed TratamientoQ1C -0.21 0.26 -0.80 102.00 0.420
Ratio w3/w6 fixed TratamientoUltracongelado 0.39 0.33 1.20 102.00 0.230
Ratio w3/w6 fixed TratamientoUltraongelado 0.06 0.29 0.22 102.00 0.830
Ratio w3/w6 fixed Tiempo3 -0.96 0.27 -3.54 102.00 <0.001
Ratio w3/w6 fixed Tiempo6 -0.96 0.28 -3.47 102.00 <0.001
Ratio w3/w6 fixed Tiempo12 -1.38 0.27 -5.07 102.00 <0.001
Ratio w3/w6 ran_pars ID sd__(Intercept) 0.00
Ratio w3/w6 ran_pars Residual sd__Observation 0.50