library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.2.1 ✔ readr 2.2.0
## ✔ forcats 1.0.1 ✔ stringr 1.6.0
## ✔ ggplot2 4.0.3 ✔ tibble 3.3.1
## ✔ lubridate 1.9.5 ✔ tidyr 1.3.2
## ✔ purrr 1.2.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
hai <- read_csv("sera_hai.csv")
## Rows: 684 Columns: 9
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (5): UniqueID, collect_time_group, cohort, data_source, target
## dbl (3): sample_id, replicate, titer
## date (1): date_collect
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
elisa <- read_csv("sera_elisa_auc.csv")
## Rows: 57 Columns: 9
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (4): UniqueID, collect_time_group, cohort, data_source
## dbl (4): sample_id, A/Victoria/22, A/Darwin/21, B/Phuket/13
## date (1): date_collect
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
# HAI IDs
length(unique(hai$UniqueID))
## [1] 16
head(unique(hai$UniqueID))
## [1] "R24b-Ctl1" "R24b-Ctl2" "R24b-Ctl3" "R24b-Ctl4" "R24b-Ctl5" "R24b-Int1"
# ELISA IDs
length(unique(elisa$UniqueID))
## [1] 16
head(unique(elisa$UniqueID))
## [1] "R24b-Ctl1" "R24b-Ctl2" "R24b-Ctl3" "R24b-Ctl4" "R24b-Ctl5" "R24b-Int1"
unique(hai$collect_time_group)
## [1] "screening" "admission" "discharge" "followup"
unique(elisa$collect_time_group)
## [1] "T0" "T1" "T2" "T3"
elisa_fixed <- elisa %>%
mutate(collect_time_group = case_when(
collect_time_group == "T0" ~ "screening",
collect_time_group == "T1" ~ "admission",
collect_time_group == "T2" ~ "discharge",
collect_time_group == "T3" ~ "followup"
))
hai_clean <- hai %>%
filter(collect_time_group == "screening") %>%
group_by(UniqueID, target) %>%
summarize(titer = mean(titer, na.rm = TRUE), .groups = "drop") %>%
pivot_wider(names_from = target, values_from = titer)
names(hai_clean) <- make.names(names(hai_clean))
elisa_clean <- elisa_fixed %>%
filter(collect_time_group == "screening")
names(elisa_clean) <- make.names(names(elisa_clean))
merged <- inner_join(hai_clean, elisa_clean, by = "UniqueID")
nrow(merged)
## [1] 11
p1 = ggplot(merged, aes(x = A.Darwin.21.y, y = A.Darwin.21.x)) +
geom_point(size = 3, alpha = 0.7) +
geom_smooth(method = "lm", linewidth = 1) +
scale_x_log10() +
scale_y_log10() +
labs(
title = "A/Darwin/21",
x = "ELISA AUC (log scale)",
y = "HAI Titer (log scale)"
) +
theme_minimal(base_size = 12)
p1
## `geom_smooth()` using formula = 'y ~ x'

ggsave("plot.png", plot = p1,, width = 7, height = 4)
## `geom_smooth()` using formula = 'y ~ x'
p2 = ggplot(merged, aes(x = B.Phuket.13.y, y = B.Phuket.13.x)) +
geom_point(size = 3, alpha = 0.7) +
geom_smooth(method = "lm") +
scale_x_log10() +
scale_y_log10() +
labs(
title = "B/Phuket/13",
x = "ELISA AUC (log scale)",
y = "HAI Titer (log scale)"
) +
theme_minimal(base_size = 12)
p3 = ggplot(merged, aes(x = A.Victoria.22.y, y = A.Victoria.22.x)) +
geom_point(size = 3, alpha = 0.7) +
geom_smooth(method = "lm") +
scale_x_log10() +
scale_y_log10() +
labs(
title = "A/Victoria/22",
x = "ELISA AUC (log scale)",
y = "HAI Titer (log scale)"
) +
theme_minimal(base_size = 12)
install.packages("patchwork")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.5'
## (as 'lib' is unspecified)
library(patchwork)
graph = p1 | p2 | p3
graph = (graph) +
plot_annotation(
title = "Relationship Between ELISA AUC and HAI Titer Across Influenza Strains"
)
ggsave("allthree.png", plot = graph, width = 12, height = 5)
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'