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
10 changes: 10 additions & 0 deletions analysis/07_read_wwarn_pd.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ wwarn_pd <- wwarn_pd |>
wwarn_pd <- wwarn_pd |>
mutate(site = ifelse(is.na(site), country, site))

# replace study_end with study_start if NA
wwarn_pd <- wwarn_pd |>
mutate(study_end = ifelse(is.na(study_end), study_start, study_end))

# correct some mistakes in dates
wwarn_pd <- wwarn_pd |>
mutate(study_start = ifelse(PMID == 19236701, 2003, study_start),
study_end = ifelse(PMID == 19236701, 2006, study_end)) |>
mutate(study_start = ifelse(PMID == 27646822, 2013, study_start))

# make study and survey IDs
wwarn_pd <- wwarn_pd |>
left_join(data.frame(site = unique(wwarn_pd$site)) |>
Expand Down
17 changes: 9 additions & 8 deletions analysis/08_merge_wwarn.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ wwarn_combined <- wwarn_k13 |>
mutate(study_start = year,
study_end = year) |>
select(-year) |>
bind_rows(wwarn_pd)
bind_rows(wwarn_pd) |>
filter(tested != 0)

# ------------------------------------------------------------------------
# make STAVE objects

# study-level data frame
df_studies <- wwarn_k13 |>
df_studies <- wwarn_combined |>
group_by(study_id) |>
summarise(study_label = study_name[1],
contributors = authors[1],
Expand All @@ -55,16 +56,16 @@ df_studies <- wwarn_k13 |>
select(study_id, study_label, description, access_level, contributors, reference, reference_year, PMID)

# survey-level data frame
df_surveys <- wwarn_k13 |>
group_by(study_id, survey_id, country, site, year) |>
df_surveys <- wwarn_combined |>
group_by(study_id, survey_id, country, site, study_start, study_end) |>
summarise(latitude = lat[1],
longitude = lon[1],
.groups = "drop") |>
mutate(location_method = "WWARN coordinates",
location_notes = NA,
collection_start = as.Date(sprintf("%s-01-01", year)),
collection_end = as.Date(sprintf("%s-12-31", year)),
collection_day = as.Date(sprintf("%s-07-01", year)),
collection_start = as.Date(sprintf("%s-01-01", study_start)),
collection_end = as.Date(sprintf("%s-12-31", study_end)),
collection_day = collection_start + (collection_end - collection_start) / 2,
time_method = "Midpoint of WWARN recorded year",
time_notes = NA) |>
rename(country_name = country,
Expand All @@ -73,7 +74,7 @@ df_surveys <- wwarn_k13 |>
collection_start, collection_end, collection_day, time_method, time_notes)

# counts-level data frame
df_counts <- wwarn_k13 |>
df_counts <- wwarn_combined |>
select(study_id, survey_id, variant_string, variant_num = present, total_num = tested, notes)

# make STAVE object and append data
Expand Down
23 changes: 22 additions & 1 deletion analysis/11_merge_stave.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ l[[22]] <- s$get_prevalence("crt:76:T") |>
collection_year = year(collection_day))
l[[23]] <- s$get_prevalence("mdr1:86:Y") |>
select(survey_id, collection_day, denominator) |>
mutate(target_variant = "crt:86:Y",
mutate(target_variant = "mdr1:86:Y",
collection_year = year(collection_day))

df_l <- bind_rows(l)
Expand All @@ -99,3 +99,24 @@ df_comb <- df_l |>

# get total samples sequenced at any of our positions of interest
sum(df_comb$denom_max)

# get the equivalent number for k13 only
bind_rows(l[1:21]) |>
group_by(survey_id, collection_year) |>
summarise(denom_max = max(denominator)) |>
pull(denom_max) |>
sum()

# get the equivalent number for crt only
bind_rows(l[22]) |>
group_by(survey_id, collection_year) |>
summarise(denom_max = max(denominator)) |>
pull(denom_max) |>
sum()

# get the equivalent number for mdr1 only
bind_rows(l[23]) |>
group_by(survey_id, collection_year) |>
summarise(denom_max = max(denominator)) |>
pull(denom_max) |>
sum()
Binary file modified analysis/data-derived/WWARN_STAVE.rds
Binary file not shown.
Binary file modified analysis/data-derived/wwarn_pd_clean.rds
Binary file not shown.
Binary file modified analysis/data-out/stave_data_2025.12.19.rds
Binary file not shown.
Binary file modified analysis/data-raw/PMID_pd_replace.xlsx
Binary file not shown.
Loading