Chapter 11 Associate microbial community metrics with chicken body weight

11.1 Load MG and MT data

load("data/data_mg.Rdata")
load("data/alpha_div.Rdata")
load("data/mci_com.Rdata")

11.2 Associate alpha diversity metrics with chicken BW

The resulting plots are not included in Supplementary.

11.2.1 Neutral

ggplot(alpha_div, aes(x = neutral, y = chicken_body_weight)) +
  geom_point() +
  geom_smooth(method = "lm") +
  facet_wrap(~ sampling_time*trial, scales = 'free')

11.3 Phylogenetic

ggplot(alpha_div, aes(x = phylogenetic, y = chicken_body_weight)) +
  geom_point() +
  geom_smooth(method = "lm") +
  facet_wrap(~ sampling_time * trial, scales = 'free')

11.4 Functional KEGG

ggplot(alpha_div, aes(x = functional_kegg, y = chicken_body_weight)) +
  geom_point() +
  geom_smooth(method = "lm") +
  facet_wrap(~ sampling_time * trial, scales = 'free')

11.5 Linear regressions

11.5.1 Neutral

div_all_day_21 <-
  alpha_div %>%
  filter(sampling_time == '21')  

N21 <- lme(chicken_body_weight ~ age + trial + neutral,
         random = ~1|pen,
         data = div_all_day_21)

summary(N21)$tTable
                   Value   Std.Error DF    t-value     p-value
(Intercept) -708.2995569 525.3549611 76 -1.3482305 0.181588833
age           78.4120899  24.3751376 76  3.2168881 0.001904929
trialCB       19.3624050  24.4490263 46  0.7919499 0.432454991
neutral       -0.5109553   0.3755338 76 -1.3606104 0.177658403
anova(N21)
            numDF denDF  F-value p-value
(Intercept)     1    76 6027.187  <.0001
age             1    76    9.989  0.0023
trial           1    46    0.734  0.3959
neutral         1    76    1.851  0.1777
plot_model(N21,
           type = 'eff',
           title = 'Neutral diversity',
           terms = 'neutral',
           show.data = TRUE)

The resulting plot corresponds to Figure 3a.

div_all_day_35 <-
  alpha_div %>%
  filter(sampling_time == '35') 

N <- lme(chicken_body_weight ~ age + trial + neutral,
         random = ~1|pen,
         data = div_all_day_35)

summary(N)$tTable
                   Value    Std.Error DF    t-value      p-value
(Intercept) -2377.528166 1033.8704109 90 -2.2996385 2.378195e-02
age           136.609314   28.5987177 90  4.7767636 6.881135e-06
trialCB       -37.822793   63.4255713 46 -0.5963335 5.538759e-01
neutral        -2.899578    0.8470732 90 -3.4230549 9.337652e-04
anova(N)
            numDF denDF  F-value p-value
(Intercept)     1    90 5105.910  <.0001
age             1    90   23.632  <.0001
trial           1    46    0.006  0.9369
neutral         1    90   11.717  0.0009
plot_model(N,
           type = 'eff',
           title = 'Neutral diversity',
           terms = 'neutral',
           show.data = TRUE)

11.5.2 Phylogenetic

P <- lme(chicken_body_weight ~ age + trial + phylogenetic,
         random = ~1|pen,
         data = div_all_day_35)

summary(P)$tTable
                   Value  Std.Error DF    t-value      p-value
(Intercept)  -2405.58507 1082.18209 90 -2.2229023 2.872722e-02
age            142.66775   29.98571 90  4.7578581 7.415862e-06
trialCB         10.88858   62.33034 46  0.1746915 8.620887e-01
phylogenetic   -64.21942   33.33088 90 -1.9267245 5.716910e-02
anova(P)
             numDF denDF  F-value p-value
(Intercept)      1    90 5247.952  <.0001
age              1    90   21.150  <.0001
trial            1    46    0.004  0.9507
phylogenetic     1    90    3.712  0.0572
plot_p <-
  plot_model(P,
             type = 'eff',
             title = 'Phylogenetic diversity',
             terms = 'phylogenetic',
             show.data = TRUE)

11.5.3 Functional KEGG

Q_kegg <- lme(chicken_body_weight ~ age + trial + functional_kegg,
         random = ~1|pen,
         data = div_all_day_35)

summary(Q_kegg)$tTable
                       Value  Std.Error DF     t-value      p-value
(Intercept)     -3102.407715 1382.90001 90 -2.24340710 2.732461e-02
age               135.602504   30.31664 90  4.47287326 2.247265e-05
trialCB            -4.776721   63.68872 46 -0.07500106 9.405391e-01
functional_kegg   322.161132  726.21619 90  0.44361602 6.583849e-01
anova(Q_kegg)
                numDF denDF  F-value p-value
(Intercept)         1    90 4950.964  <.0001
age                 1    90   21.087  <.0001
trial               1    46    0.005  0.9462
functional_kegg     1    90    0.197  0.6584
plot_q <-
  plot_model(Q_kegg,
             type = 'eff',
             title = 'Functional diversity',
             terms = 'functional_kegg',
             show.data = TRUE)

11.6 Associate community MCI with diversity

domains_com_2 <-
  funcs_com %>%
  as.data.frame(optional = TRUE) %>% 
  rownames_to_column(var = "animal_code") %>% 
  rowwise() %>%
  mutate(overall_com_mci = mean(c_across(B01:D09))) %>%
  select(animal_code, overall_com_mci) %>%
  left_join(alpha_div) %>%
  filter(sampling_time == '35')

# Neutral
N <- lme(neutral ~ age + trial + overall_com_mci, 
         random = ~1|pen,
         data = domains_com_2)
summary(N)
Linear mixed-effects model fit by REML
  Data: domains_com_2 
       AIC      BIC    logLik
  1309.637 1327.113 -648.8184

Random effects:
 Formula: ~1 | pen
        (Intercept) Residual
StdDev:    12.86971 25.11553

Fixed effects:  neutral ~ age + trial + overall_com_mci 
                    Value Std.Error DF   t-value p-value
(Intercept)      442.6914 114.50849 90  3.866014  0.0002
age               -1.3636   2.68187 90 -0.508452  0.6124
trialCB          -12.9086   5.71716 46 -2.257870  0.0287
overall_com_mci -909.1033 180.81677 90 -5.027760  0.0000
 Correlation: 
                (Intr) age    trilCB
age             -0.867              
trialCB          0.027 -0.094       
overall_com_mci -0.541  0.052  0.055

Standardized Within-Group Residuals:
        Min          Q1         Med          Q3         Max 
-2.01837033 -0.68738375 -0.05166506  0.56790691  2.44376691 

Number of Observations: 140
Number of Groups: 48 
# Phylogenetic
P <- lme(phylogenetic ~ age + trial + overall_com_mci,
         random = ~1|pen,
         data = domains_com_2)
summary(P)
Linear mixed-effects model fit by REML
  Data: domains_com_2 
       AIC      BIC    logLik
  272.8188 290.2948 -130.4094

Random effects:
 Formula: ~1 | pen
         (Intercept)  Residual
StdDev: 4.217194e-05 0.6099878

Fixed effects:  phylogenetic ~ age + trial + overall_com_mci 
                    Value Std.Error DF   t-value p-value
(Intercept)      16.74885  2.645051 90  6.332146  0.0000
age               0.06901  0.062878 90  1.097553  0.2753
trialCB           0.17043  0.104053 46  1.637874  0.1083
overall_com_mci -36.22173  3.925729 90 -9.226751  0.0000
 Correlation: 
                (Intr) age    trilCB
age             -0.884              
trialCB          0.052 -0.116       
overall_com_mci -0.522  0.064  0.059

Standardized Within-Group Residuals:
        Min          Q1         Med          Q3         Max 
-3.09402112 -0.54578514  0.05390878  0.60148158  3.11538727 

Number of Observations: 140
Number of Groups: 48 
# Functional
Q <- lme(functional_kegg ~ age + trial + overall_com_mci,
         random = ~1|pen,
         data = domains_com_2)
summary(Q)
Linear mixed-effects model fit by REML
  Data: domains_com_2 
       AIC       BIC  logLik
  -500.516 -483.0401 256.258

Random effects:
 Formula: ~1 | pen
        (Intercept)   Residual
StdDev: 0.002372041 0.03545057

Fixed effects:  functional_kegg ~ age + trial + overall_com_mci 
                     Value  Std.Error DF   t-value p-value
(Intercept)      1.3205515 0.15393265 90  8.578761  0.0000
age              0.0056871 0.00365793 90  1.554730  0.1235
trialCB          0.0004502 0.00608846 46  0.073938  0.9414
overall_com_mci -0.4092000 0.22888069 90 -1.787831  0.0772
 Correlation: 
                (Intr) age    trilCB
age             -0.883              
trialCB          0.051 -0.116       
overall_com_mci -0.523  0.063  0.059

Standardized Within-Group Residuals:
       Min         Q1        Med         Q3        Max 
-2.4047065 -0.5785702 -0.1198138  0.4216641  4.1954558 

Number of Observations: 140
Number of Groups: 48 

11.7 Associate community MCI with chicken BW

mci <- lme(chicken_body_weight ~ age + trial + overall_com_mci,
         random = ~1|pen,
         data = domains_com_2)
summary(mci)
Linear mixed-effects model fit by REML
  Data: domains_com_2 
       AIC      BIC    logLik
  1966.759 1984.235 -977.3796

Random effects:
 Formula: ~1 | pen
        (Intercept) Residual
StdDev:    140.9066 282.3369

Fixed effects:  chicken_body_weight ~ age + trial + overall_com_mci 
                     Value Std.Error DF   t-value p-value
(Intercept)     -2992.2828 1285.1423 90 -2.328367  0.0221
age               137.9025   30.1147 90  4.579239  0.0000
trialCB            -2.8132   63.5521 46 -0.044266  0.9649
overall_com_mci   814.5620 2025.5024 90  0.402153  0.6885
 Correlation: 
                (Intr) age    trilCB
age             -0.868              
trialCB          0.028 -0.095       
overall_com_mci -0.541  0.052  0.055

Standardized Within-Group Residuals:
        Min          Q1         Med          Q3         Max 
-1.99872087 -0.61588910 -0.08184466  0.54575510  2.59044972 

Number of Observations: 140
Number of Groups: 48 

11.8 Associate community weighted genome size with chicken BW

metadata_day_35 <-
  chicken_metadata %>%
  filter(sampling_time == "35")

mag_lengthed <- 
  round(sweep(total, MARGIN = 1, genome_stats$mag_length, `*`), 0) %>% 
  t() %>% 
  as.data.frame() %>%
  rownames_to_column(var = "animal_code") %>%
  rowwise() %>% 
  mutate(comm_length = mean(c_across(2:389))) %>% 
  select(animal_code, comm_length) %>% 
  filter(animal_code %in% metadata_day_35$animal_code) %>% 
  left_join(metadata_day_35, by = 'animal_code')

L <- lme(chicken_body_weight ~ scale(age) + trial + scale(log(comm_length)),
         random = ~ 1|pen,
         data = mag_lengthed)
summary(L)
Linear mixed-effects model fit by REML
  Data: mag_lengthed 
       AIC      BIC    logLik
  1975.692 1993.168 -981.8459

Random effects:
 Formula: ~1 | pen
        (Intercept) Residual
StdDev:    144.7197 281.2538

Fixed effects:  chicken_body_weight ~ scale(age) + trial + scale(log(comm_length)) 
                            Value Std.Error DF  t-value p-value
(Intercept)             2231.4630  46.49952 90 47.98894  0.0000
scale(age)               114.0616  24.97663 90  4.56673  0.0000
trialCB                   -1.2398  66.94795 46 -0.01852  0.9853
scale(log(comm_length))   -4.9378  29.89947 90 -0.16515  0.8692
 Correlation: 
                        (Intr) scl(g) trilCB
scale(age)               0.088              
trialCB                 -0.728 -0.113       
scale(log(comm_length))  0.211  0.070 -0.291

Standardized Within-Group Residuals:
       Min         Q1        Med         Q3        Max 
-2.0015452 -0.6185148 -0.1001931  0.5667678  2.5817652 

Number of Observations: 140
Number of Groups: 48 
plot(L)

rm(list = ls())