Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions analysis/03_process_geoff.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ library(writexl)
study_folders <- list.dirs(here("analysis", "data-geoff"), recursive = FALSE) |>
basename()

# skip over some folders, where STAVE format was extracted directly
study_folders <- setdiff(study_folders, c("s231_ali_2022_v01",
"s232_wamae_2022_v01",
"s233_issa_2022_v01"))

# read k13 dictionary and filter to target mutations
k13_dictionary <- read.csv(here("analysis", "data-raw", "k13_ref_protein_codon_dictionary.csv")) |>
filter(!is.na(WHO_TARGET))
Expand Down
2 changes: 1 addition & 1 deletion analysis/11_merge_stave.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ s$append_data(studies_dataframe = s_pf8$get_studies(),
counts_dataframe = s_pf8$get_counts())

# save combined object to file
saveRDS(s, file = here("analysis", "data-out", "stave_data_2026.03.08.rds"))
saveRDS(s, file = here("analysis", "data-out", "stave_data_2026.03.13.rds"))

# ------------------------------------------------------------------
# Some basic stats on the final object
Expand Down
97 changes: 97 additions & 0 deletions analysis/12_plot_samples.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# plot_sample_collection.R
#
# Author: Bob Verity
# Date: 2025-12-22
#
# Inputs:
# data-out/stave_data_ ... .rds
#
# Outputs:
# plots/sample_collection.pdf
#
# Purpose:
# (this is an example header)
#
# ------------------------------------------------------------------
library(tidyverse)
library(here)
library(STAVE)

# read in combined STAVE object
s <- readRDS(here("analysis", "data-out", "stave_data_2026.03.08.rds"))

# get WHO positions
k13_dictionary <- read.csv(here("analysis", "data-raw", "k13_ref_protein_codon_dictionary.csv")) |>
filter(!is.na(WHO_TARGET)) |>
mutate(WT_variant = sprintf("k13:%s:%s", CODON, REF))

# get prevalence (of WT) over all positions
l <- list()
for (i in 1:nrow(k13_dictionary)) {
message(sprintf("%s of %s", i, nrow(k13_dictionary)))
l[[i]] <- s$get_prevalence(k13_dictionary$WT_variant[i]) |>
select(study_id, survey_id, collection_day, denominator) |>
mutate(target_variant = k13_dictionary$WT_variant[i],
collection_year = year(collection_day))
}

# also get prevalence of PD
l[[22]] <- s$get_prevalence("crt:76:T") |>
select(study_id, survey_id, collection_day, denominator) |>
mutate(target_variant = "crt:76:T",
collection_year = year(collection_day))
l[[23]] <- s$get_prevalence("mdr1:86:Y") |>
select(study_id, survey_id, collection_day, denominator) |>
mutate(target_variant = "crt:86:Y",
collection_year = year(collection_day))

df_l <- bind_rows(l)

# find max denominator over all markers
df_comb <- df_l |>
group_by(study_id, survey_id, collection_year) |>
summarise(denom_max = max(denominator))

sum(df_comb$denom_max)

# ------------------------------------------------------------------------
# Plot samples collected over time

augmented_list <- c("s0002_ayelaw_eth2023",
"s0003_gidey_eth2022",
"s0006_WRAIR_kenread_ken",
"s0007_connelly_2024_zim",
"s0008_MSMT_TZA_22_23",
"s0010_karamoko_mgem_unpub",
"s0011_jacques-mari_gmms_unpub",
"s0021_roh_2023",
"s0063_ngasala_2024",
"s0074_lepiscopia_2025",
"s0075_eloff_2025")

mutate(bind_rows(l[1:21]), target_variant = "k13") |>
bind_rows(mutate(l[[22]], target_variant = "crt 76")) |>
bind_rows(mutate(l[[23]], target_variant = "mdr1 86")) |>
group_by(study_id, survey_id, collection_year, target_variant) |>
summarise(denom_max = max(denominator)) |>
mutate(source = ifelse(grepl("^WWARN_", study_id), "WWARN",
ifelse(grepl("^WHO_", study_id), "WHO MTM",
ifelse(grepl("^MalariaGEN_", study_id), "MalariaGen Pf8",
ifelse(study_id %in% augmented_list, "Augmented datasets", "PRISMA review")))),
source = factor(source, levels = c("PRISMA review", "Augmented datasets",
"WWARN", "WHO MTM", "MalariaGen Pf8"))) |>
group_by(collection_year, source, target_variant) |>
summarise(n = sum(denom_max)) |>
mutate(target_variant = factor(target_variant, levels = c("crt 76", "mdr1 86", "k13"))) |>
ggplot() + theme_bw() +
geom_col(aes(x = collection_year, y = n, fill = source)) +
labs(x = "Collection Year", y = "Samples Sequenced",
fill = "Data Source") +
facet_wrap(~target_variant) +
theme(legend.position = "bottom")

# save to file
ggsave(filename = here("analysis", "plots", "sample_collection.pdf"),
width = 8, height = 4)


22 changes: 3 additions & 19 deletions analysis/data-derived/geoff_to_k13_coverage.csv
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"s0013_MSMT_TZA_21_v01",1,726,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s0014_young_rwa_unpub_v01",1,726,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s0016_connelly_2024_elife_v01",1,726,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s0017_moser_mol_ecol_v01",1,726,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s0019a_conrad_v01",1,726,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s0020_some_2024_v01",1,726,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s0021_roh_2023_v01",1,726,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
Expand All @@ -22,32 +21,18 @@
"s0024_fola_2023_zambiamalj_v01",1,726,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s0025_ogwang_aac_v01",427,709,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s0026_verity_v01",1,726,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s0027_bayih_ajtmh_v01",427,709,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s0028_alemayehu_v01",427,709,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s0029_warsame_2019_v01",427,709,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s0030_uwimana_rwa_2014_v01",440,600,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580:PFGNCMAYRPNGRIPRVPC"
"s0031_bergmann_2021_v01",469,581,"k13:469_476_481_493_515_527_537_538_539_543_553_561_568_574_580:CMAYRPNGRIPRVPC"
"s0032_tacoli_v01",440,726,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s0033_straimer_v01",440,726,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s0034_uwimana_v01",442,727,"k13:446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:FGNCMAYRPNGRIPRVPCRA"
"s0035_kirby_v01",516,572,"k13:527_537_538_539_543_553_561_568:PNGRIPRV"
"s0036_schreidah_v01",1,726,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s0039_yobi_2020_plosone_v01",427,595,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580:PFGNCMAYRPNGRIPRVPC"
"s0040_mvumbi_2017_plosone_v01",427,709,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s0041_yobi_2022_v01",427,595,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580:PFGNCMAYRPNGRIPRVPC"
"s0042_mesiakahunu_v01",396,698,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s0043_vanloon_v01",469,581,"k13:469_476_481_493_515_527_537_538_539_543_553_561_568_574_580:CMAYRPNGRIPRVPC"
"s0045_bakari_v01",430,726,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s0046_bwire_v01",354,666,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622:PFGNCMAYRPNGRIPRVPCR"
"s0047_balikagala_v01",469,708,"k13:469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:CMAYRPNGRIPRVPCRA"
"s0048_vanloon_v01",469,581,"k13:469_476_481_493_515_527_537_538_539_543_553_561_568_574_580:CMAYRPNGRIPRVPC"
"s0049_plucinski_v01",1,726,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s0050_davlantes_v01",440,680,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s0052_ljolje_v01",440,726,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s0053_issa_v01",430,720,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s0054_laminou_v01",440,720,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s0055_dorkenoo_v01",430,720,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s0057_koko_v01",440,680,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s0059_osborne_v01",1,726,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s0060_angwe_2024_v01",445,727,"k13:446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:FGNCMAYRPNGRIPRVPCRA"
"s0061_kamaliddin_2024_v01",434,702,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
Expand All @@ -56,8 +41,6 @@
"s0065_ndiaye_v01",578,580,"k13:580:C"
"s0067_makenga_2022_v01",442,726,"k13:446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:FGNCMAYRPNGRIPRVPCRA"
"s0068_dasilva_2023_v01",412,723,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s0069_matrevi_2019_v01",430,699,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s0070_hamid_2019_v01",427,709,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s0071_mohammed_sdn_2018_v01",NA,NA,NA
"s0072_makau_ken_2024_v01",441,726,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s0073_agaba_uga_2024_v01",427,709,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
Expand Down Expand Up @@ -126,7 +109,6 @@
"s0184_mulenga_2021_v01",NA,NA,NA
"s0186_holzschuh_2023_v01",481,543,"k13:481_493_515_527_537_538_539_543:AYRPNGRI"
"s0189_kagoro_2022_v01",430,729,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s0191_mbacham_2010_v01",NA,NA,NA
"s0192_coonahan_2023_v01",440,726,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s0193_awor_2024_v01",1,726,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s0194_kassaza_2021_v01",NA,NA,NA
Expand All @@ -138,7 +120,6 @@
"s216_milongmelong_2025_v01",427,709,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s219_amusan_2024_v01",NA,NA,NA
"s220_onyamboko_2025_v01",440,727,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s221_joao_2025_v01",11,691,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s222_nuwa_2025_v01",469,675,"k13:469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:CMAYRPNGRIPRVPCRA"
"s223_kimani_2025_v01",432,702,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s224_nyamngee_2025_v01",NA,NA,NA
Expand All @@ -147,3 +128,6 @@
"s228_vanloon_2025_v01",426,709,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s229_adika_2025_v01",440,680,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s230_mihreteab_2025_v01",435,680,"k13:441_446_449_458_469_476_481_493_515_527_537_538_539_543_553_561_568_574_580_622_675:PFGNCMAYRPNGRIPRVPCRA"
"s231_ali_2022_v01",NA,NA,NA
"s232_wamae_2022_v01",NA,NA,NA
"s233_issa_2022_v01",NA,NA,NA
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified analysis/plots/sample_collection.pdf
Binary file not shown.
Loading