Pig PA ultrasound data

setup

Read in Data

readxl::read_excel(here("PIG PAUS data_yc.xlsx")) %>%
  janitor::clean_names() |> 
  janitor::remove_empty() |> 
  mutate(measurement_value = as.numeric(measurement_value)) ->
df
value for "which" not specified, defaulting to c("rows", "cols")
Warning: There was 1 warning in `mutate()`.
ℹ In argument: `measurement_value =
  as.numeric(measurement_value)`.
Caused by warning:
! NAs introduced by coercion

Analysis

df |> 
  group_by(pig, treated, wavelength) |>
  summarise(mean = mean(measurement_value, na.rm=TRUE), 
            sd = sd(measurement_value, na.rm=TRUE)) |> 
  gt() |> 
  tab_header(
    title = md("Data Grouped by Pig, Treatment, and Wavelength")
  )
`summarise()` has grouped output by 'pig', 'treated'. You
can override using the `.groups` argument.

Data Grouped by Pig, Treatment, and Wavelength

wavelength mean sd
PAPC-1 - 0
800 4283.677 423.8885
1200 3634.495 301.0695
PAPC-1 - 1
800 6255.793 203.0605
1200 5340.887 573.8289
PAPC-3 - 0
750 4633.550 143.4739
800 4625.280 309.0905
1200 3810.645 528.7532
1310 3709.348 535.2551
PAPC-3 - 1
800 6751.210 450.3719
1200 6448.237 622.0233
1310 5500.300 121.5375
df |> 
  group_by(treated, wavelength) |>
  summarise(mean = mean(measurement_value, na.rm=TRUE), 
            sd = sd(measurement_value, na.rm=TRUE)) |> 
  gt() |> 
  tab_header(
    title = md("Data Grouped by Treatment (0/1) and Wavelength")
  )
`summarise()` has grouped output by 'treated'. You can
override using the `.groups` argument.

Data Grouped by Treatment (0/1) and Wavelength

wavelength mean sd
0
750 4633.550 143.4739
800 4369.078 408.6534
1200 3678.533 333.6674
1310 3709.348 535.2551
1
800 6503.502 413.8341
1200 5894.562 808.9155
1310 5500.300 121.5375

We can perform unpaired t tests without regard to pig or esophageal location

df |> 
  filter(wavelength == 800) |> 
  rstatix::t_test(measurement_value ~ treated, var.equal = TRUE) 
# A tibble: 1 × 8
  .y.      group1 group2    n1    n2 statistic    df       p
* <chr>    <chr>  <chr>  <int> <int>     <dbl> <dbl>   <dbl>
1 measure… 0      1          8     6     -9.62    12 5.43e-7
df |> 
  filter(wavelength == 1200) |> 
  rstatix::t_test(measurement_value ~ treated, var.equal = TRUE) 
# A tibble: 1 × 8
  .y.      group1 group2    n1    n2 statistic    df       p
* <chr>    <chr>  <chr>  <int> <int>     <dbl> <dbl>   <dbl>
1 measure… 0      1          8     6     -7.06    12 1.32e-5
df |> 
  filter(wavelength ==1310) |> 
  rstatix::t_test(measurement_value ~ treated, var.equal = TRUE) 
# A tibble: 1 × 8
  .y.      group1 group2    n1    n2 statistic    df       p
* <chr>    <chr>  <chr>  <int> <int>     <dbl> <dbl>   <dbl>
1 measure… 0      1          5     2     -4.44     5 0.00675

There appear to be significant differences between treated and untreated pigs at all wavelengths. The differences are most pronounced at 800 nm.

Modeling measurement values

model <- lm(measurement_value ~ pig + treated + site_cm, data = df |> filter(wavelength == 800))

model |> 
  broom::tidy() 
# A tibble: 4 × 5
  term        estimate std.error statistic    p.value
  <chr>          <dbl>     <dbl>     <dbl>      <dbl>
1 (Intercept)  4047.       498.      8.12  0.0000103 
2 pigPAPC-3     411.       222.      1.85  0.0939    
3 treated      2020.       215.      9.38  0.00000284
4 site_cm         5.77      12.6     0.456 0.658     

Even with this small N, there is some variance from pig to pig at 800 nm. There is a trend toward higher values for Pig 3. There is a significant difference between treated and untreated pigs. Treatment increases signal at 800 nm by ~ 2020 AU. There is minimal difference between the different esophageal sites (with this small N). We are not controlling for pig age, which might correlate with higher signals.

model <- lm(measurement_value ~ pig + treated + site_cm, data = df |> filter(wavelength == 1200))

model |> 
  broom::tidy() 
# A tibble: 4 × 5
  term        estimate std.error statistic   p.value
  <chr>          <dbl>     <dbl>     <dbl>     <dbl>
1 (Intercept)   4014.      670.      5.99  0.000134 
2 pigPAPC-3      659.      298.      2.21  0.0516   
3 treated       2078.      289.      7.18  0.0000301
4 site_cm        -13.2      17.0    -0.775 0.457    

Even with this small N, there is some variance from pig to pig at 1200 nm. There is a trend toward higher values for Pig 3. There is a significant difference between treated and untreated pigs. Treatment increases signal at 1200 nm by ~ 2078 AU. There is minimal difference between the different esophageal sites (with this small N). We are not controlling for pig age, which might correlate with higher signals.

model <- lm(measurement_value ~ treated + site_cm, 
            data = df |> filter(wavelength == 1310))

model |> 
  broom::tidy() 
# A tibble: 3 × 5
  term        estimate std.error statistic p.value
  <chr>          <dbl>     <dbl>     <dbl>   <dbl>
1 (Intercept)   3181.     1238.      2.57   0.0620
2 treated       1857.      466.      3.99   0.0163
3 site_cm         13.2      30.4     0.434  0.686 

Only one pig was evaluated at 1310 nm. There is a significant difference between treated and untreated pigs.Treatment increases signal at 1310 nm by ~ 1857 AU. There is minimal difference between the different esophageal sites (with this small N). We are not controlling for pig age, which might correlate with higher signals.

Let’s look at paired t-tests - in the same pig at the same site.

First, let’s look at the differencs at 800 nm

df |> 
  filter(wavelength == 800) |>
             arrange(pig, site_cm, treated) |> 
  filter(lag(site_cm) == site_cm | lead(site_cm) == site_cm) |> 
  mutate(diff = measurement_value - lag(measurement_value)) |>
  filter(treated ==1) |> 
  gt()
pig date site_cm wavelength treated measurement_value diff
PAPC-1 2024-06-25 30 800 1 6162.62 1612.88
PAPC-1 2024-06-25 40 800 1 6488.72 1703.53
PAPC-1 2024-06-25 50 800 1 6116.04 1463.56

Now let’s perform the paired t-test at 800 nm - in two ways, first by looking at the differences in the same pig at the same site, then by using the official paired t test.

df |> 
  filter(wavelength == 800) |>
             arrange(pig, site_cm, treated) |> 
  filter(lag(site_cm) == site_cm | lead(site_cm) == site_cm) |> 
  mutate(diff = measurement_value - lag(measurement_value)) |>
  filter(treated ==1) |> 
  rstatix::t_test(diff ~ 1, mu = 0) 
# A tibble: 1 × 7
  .y.   group1 group2         n statistic    df       p
* <chr> <chr>  <chr>      <int>     <dbl> <dbl>   <dbl>
1 diff  1      null model     3      22.8     2 0.00192
df |> 
  filter(wavelength == 800) |>
             arrange(pig, site_cm, treated) |> 
  filter(site_cm %in% c(30,40,50)) |>
  filter(pig == 'PAPC-1') |>
  rstatix::t_test(measurement_value ~ treated, paired = TRUE)
# A tibble: 1 × 8
  .y.      group1 group2    n1    n2 statistic    df       p
* <chr>    <chr>  <chr>  <int> <int>     <dbl> <dbl>   <dbl>
1 measure… 0      1          3     3     -22.8     2 0.00192

Again, the differences with treatment are significant.

First, let’s look at the differencs at 800 nm

df |> 
  filter(wavelength == 800) |>
             arrange(pig, site_cm, treated) |> 
  filter(lag(site_cm) == site_cm | lead(site_cm) == site_cm) |> 
  mutate(diff = measurement_value - lag(measurement_value)) |>
  filter(treated ==1) |> 
  gt()
pig date site_cm wavelength treated measurement_value diff
PAPC-1 2024-06-25 30 800 1 6162.62 1612.88
PAPC-1 2024-06-25 40 800 1 6488.72 1703.53
PAPC-1 2024-06-25 50 800 1 6116.04 1463.56

Now let’s perform the paired t-test at 1200 nm - in two ways, first by looking at the differences in the same pig at the same site, then by using the official paired t test.

df |> 
  filter(wavelength == 1200) |>
             arrange(pig, site_cm, treated) |> 
  filter(lag(site_cm) == site_cm | lead(site_cm) == site_cm) |> 
  mutate(diff = measurement_value - lag(measurement_value)) |>
  filter(treated ==1) |> 
  rstatix::t_test(diff ~ 1, mu = 0) 
# A tibble: 1 × 7
  .y.   group1 group2         n statistic    df      p
* <chr> <chr>  <chr>      <int>     <dbl> <dbl>  <dbl>
1 diff  1      null model     3      3.57     2 0.0702
df |> 
  filter(wavelength == 1200) |>
             arrange(pig, site_cm, treated) |> 
  filter(site_cm %in% c(30,40,50)) |>
  filter(pig == 'PAPC-1') |>
  rstatix::t_test(measurement_value ~ treated, paired = TRUE) 
# A tibble: 1 × 8
  .y.       group1 group2    n1    n2 statistic    df      p
* <chr>     <chr>  <chr>  <int> <int>     <dbl> <dbl>  <dbl>
1 measurem… 0      1          3     3     -3.57     2 0.0702

Again, the differences with treatment are significant.

Now let’s perform the paired t-test at 1310 nm.

df |> 
  filter(wavelength == 1310) |>
             arrange(pig, site_cm, treated) |> 
  filter(lag(site_cm) == site_cm | lead(site_cm) == site_cm) |> 
  mutate(diff = measurement_value - lag(measurement_value)) |>
  filter(treated ==1) |> 
  rstatix::t_test(diff ~ 1, mu = 0) 
# A tibble: 1 × 7
  .y.   group1 group2         n statistic    df      p
* <chr> <chr>  <chr>      <int>     <dbl> <dbl>  <dbl>
1 diff  1      null model     2      16.2     1 0.0392

Again, the differences with treatment are significant.

Plotting the data

df |> 
  ggplot(aes(x = site_cm, y = measurement_value, color = factor(treated))) +
  geom_point() +
  facet_grid(pig ~ wavelength) +
  labs(title = "Measurement values by Wavelength, Pig, and APC treatment",
       x = "Site (cm)",
       y = "Measurement value (AU)",
       color = "Treated") +
  scale_color_manual(values = c("black", "red"),
                     labels = c("No Rx", "APC"),
                     guide = guide_legend(reverse = TRUE)) +
  theme_minimal(base_size = 16)
Warning: Removed 1 row containing missing values or values outside
the scale range (`geom_point()`).