Data Preprocessing

Preparing data collected during animal experiment and ANOVA

Libraries

Load needed libraries and packages.

Hide code
library(tidyverse)
library(here)
library(pals)

Custom Functions

Load customized functions.

Hide code
source(here("R/utilities.R"))
source_dir(here("R"))

Read Data

Data collected during animal experiment.

Hide code
antem_df <- read_csv(here("local/bov_antemortem_2024.csv"))

# minimum date, donor inoculation
min_date <- min(antem_df$date)

# add variables 
antem_df <- antem_df %>%
  mutate(hpdi = as.numeric(difftime(date, min_date, units = "hours")), # hours post donor inoculation 
         hpe = dpe*24, # convert dpe to hpe
         exp_type = if_else(group == "donor", "inoc", "cont"), # exposed by inoculation or direct contact
         fever = if_else(temp >= 104, "fever", "no_fever"), # temp >= 104 constitutes fever
         censor_status = if_else(group == "Group 1" | animal == "BR23-24", 0, 1), # No obs symptoms (0) in these 
  )

Plots to Check Data

Donors

Hide code
plot_donors(antem_df)

Contact Groups

Hide code
plot_contact_groups(antem_df)

ANOVA

To evaluate the differences in nasal, serum, and lesion score among groups and over time, repeated measures ANOVAs were applied using the ezANOVA() function from the ez R-package. The analyses included within-subjects (days post-exposure, dpe) and between-subjects (group) factors, with nasal, serum, and lesion scores as the dependent variables. Mauchly’s test was conducted to test the assumption of sphericity. Where violations were found, Greenhouse-Geisser and Huynh-Feldt corrections were applied.

Prepare Data

Hide code
contact_groups <- antem_df %>%
  filter(group %in% c("Group 2", "Group 3", "Group 4")) %>%
  select(animal, group, nasal, serum, dpe, score) %>%
  mutate(
    score = replace_na(score, 0)) %>%
  drop_na() %>%
  mutate(
    score = replace_na(score, 0),          
    nasal = replace(nasal, nasal == 45, 0), # 45 indicates no detection
    serum = replace(serum, serum == 45, 0),
    dpe = as.factor(dpe),                   
    animal = as.factor(animal),            
    group = as.factor(group)                
  ) %>%
  as.data.frame()

Results indicate that nasal virus quantity differed significantly between the groups and across the days post-exposure, with an interaction effect suggesting that the temporal pattern of virus quantity varied among the groups.

Hide code
nasal_anova <- ez::ezANOVA(data = contact_groups, dv = .(nasal), wid = .(animal), within = .(dpe), between = .(group))
nasal_anova
$ANOVA
     Effect DFn DFd         F            p p<.05       ges
2     group   2   9  9.223642 6.619789e-03     * 0.2693092
3       dpe   6  54 33.985994 1.195097e-16     * 0.7559307
4 group:dpe  12  54  5.531737 4.748785e-06     * 0.5020495

$`Mauchly's Test for Sphericity`
     Effect           W           p p<.05
3       dpe 0.002507464 0.007421478     *
4 group:dpe 0.002507464 0.007421478     *

$`Sphericity Corrections`
     Effect       GGe        p[GG] p[GG]<.05       HFe        p[HF] p[HF]<.05
3       dpe 0.4698995 7.240063e-09         * 0.7063488 2.378893e-12         *
4 group:dpe 0.4698995 1.041644e-03         * 0.7063488 9.172502e-05         *

Results suggest that while there were no significant differences between groups, there were significant changes over time, and the pattern of these changes differed significantly among the groups.

Hide code
serum_anova <- ez::ezANOVA(data = contact_groups, dv = .(serum), wid = .(animal), within = .(dpe), between = .(group))
serum_anova
$ANOVA
     Effect DFn DFd         F            p p<.05       ges
2     group   2   9  2.789541 1.141052e-01       0.1386202
3       dpe   6  54 25.182482 5.082150e-14     * 0.6744439
4 group:dpe  12  54  7.951312 2.761527e-08     * 0.5667711

$`Mauchly's Test for Sphericity`
     Effect            W            p p<.05
3       dpe 1.265279e-05 6.228482e-08     *
4 group:dpe 1.265279e-05 6.228482e-08     *

$`Sphericity Corrections`
     Effect       GGe        p[GG] p[GG]<.05       HFe        p[HF] p[HF]<.05
3       dpe 0.2446423 7.610504e-05         * 0.2805428 2.727829e-05         *
4 group:dpe 0.2446423 2.894414e-03         * 0.2805428 1.633022e-03         *

Results indicate that lesion scores differed significantly between the groups and across the days post-exposure, with an interaction effect suggesting that the temporal pattern of lesion severity varied among the groups.

Hide code
score_anova <- ez::ezANOVA(data = contact_groups, dv = .(score), wid = .(animal), within = .(dpe), between = .(group))
score_anova
$ANOVA
     Effect DFn DFd         F            p p<.05       ges
2     group   2   9  5.860606 2.345433e-02     * 0.2550442
3       dpe   6  54 45.873199 1.823174e-19     * 0.7897890
4 group:dpe  12  54  3.038905 2.531711e-03     * 0.3323484

$`Mauchly's Test for Sphericity`
     Effect            W            p p<.05
3       dpe 6.163627e-19 5.763765e-47     *
4 group:dpe 6.163627e-19 5.763765e-47     *

$`Sphericity Corrections`
     Effect       GGe        p[GG] p[GG]<.05       HFe        p[HF] p[HF]<.05
3       dpe 0.4739793 2.829807e-10         * 0.7157848 1.639730e-14         *
4 group:dpe 0.4739793 2.364298e-02         * 0.7157848 8.310038e-03         *