Skip to content
Merged

Dev #60

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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
53 changes: 46 additions & 7 deletions analysis/06_read_wwarn_k13.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,25 @@ wwarn_k13 <- readxl::read_xls(here("analysis", "data-raw", "WWARN_K13_database_0
PMID = as.numeric(pubMedId),
notes = as.character(NA))

# count studies
length(unique(wwarn_k13$authors))

# filter to Africa
wwarn_k13 <- wwarn_k13 |>
filter(continent == "Africa") |>
arrange(country, site, year, mutation) |>
select(country, site, year, mutation, present, tested, lat, lon, PMID)
select(country, site, year, mutation, present, tested, lat, lon, PMID, authors)

# count studies
length(unique(wwarn_k13$authors))

# drop studies with no PMID
wwarn_k13 <- wwarn_k13 |>
filter(!is.na(PMID))
filter(!is.na(PMID)) |>
select(-authors)

# count studies
length(unique(wwarn_k13$PMID))

# drop studies already in GEOFF
s <- readRDS(here("analysis", "data-derived", "geoff_STAVE.rds"))
Expand All @@ -59,6 +69,9 @@ PMID_geoff <- s$get_studies() |>
wwarn_k13 <- wwarn_k13|>
filter(!(PMID %in% PMID_geoff))

# count studies
length(unique(wwarn_k13$PMID))

# ------------------------------------------------------------------------
# remove some studies and fix errors in others

Expand Down Expand Up @@ -93,10 +106,6 @@ wwarn_k13 <- wwarn_k13 |>
filter(PMID != 33789667) |>
bind_rows(readxl::read_excel(here("analysis", "data-raw", "PMID_k13_replace.xlsx"), sheet = "33789667"))

# this study data has many errors, but replace at a later stage (see below)
wwarn_k13 <- wwarn_k13 |>
filter(PMID != 33146722)

# replace some bad characters in site names
wwarn_k13 <- wwarn_k13 |>
mutate(site = gsub("é", "e", site),
Expand Down Expand Up @@ -138,10 +147,16 @@ wwarn_k13 <- wwarn_k13 |>
select(PMID, WT_variant),
by = join_by(PMID))

# count studies
length(unique(wwarn_k13$PMID))

# drop studies for which WT is NA, implying that none of the target loci are covered
wwarn_k13 <- wwarn_k13 |>
filter(!is.na(WT_variant))

# count studies
length(unique(wwarn_k13$PMID))

# overlay variant on top of WT
wwarn_k13 <- wwarn_k13 |>
mutate(variant_string_combined = overlay_variant(variant_string, WT_variant))
Expand Down Expand Up @@ -188,7 +203,10 @@ wwarn_k13 <- wwarn_k13 |>

# ------------------------------------------------------------------------

# read back in Asua et al. data
# replace Asua et al. data
wwarn_k13 <- wwarn_k13 |>
filter(PMID != 33146722)

df_asua <- readxl::read_excel(here("analysis", "data-raw", "PMID_k13_replace.xlsx"), sheet = "33146722")

# merge with data on paper and tidy up to match wwarn_k13 format
Expand All @@ -206,6 +224,27 @@ df_asua <- df_asua |>

wwarn_k13 <- bind_rows(wwarn_k13, df_asua)

# count studies
length(unique(wwarn_k13$PMID))

# ------------------------------------------------------------------------
# import further cleaned datasets

import_PMIDs <- c(28594879, 35144535, 33107096, 26483118, 31296223, 33864801, 33350925,
27573632, 34216470, 32747827, 32822392, 34551228, 35477399, 31427297,
31034031, 29458380, 32103124)

wwarn_k13 <- wwarn_k13 |>
filter(!(PMID %in% import_PMIDs))
for (i in seq_along(import_PMIDs)) {
wwarn_k13 <- wwarn_k13 |>
bind_rows(readxl::read_excel(here("analysis", "data-raw", "PMID_k13_replace.xlsx"),
sheet = as.character(import_PMIDs[i])))
}

# count studies
length(unique(wwarn_k13$PMID))

# ------------------------------------------------------------------------

# save to file
Expand Down
26 changes: 23 additions & 3 deletions analysis/07_read_wwarn_pd.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ wwarn_pd <- readxl::read_xls(here("analysis", "data-raw", "WWARN_partnerdrug_dat
select(study_id, country, site, lon, lat, study_start, study_end, marker_type,
tested, present, mixed_present, url)

# count studies
# have to go with url as I know some study_ids are duplicates of the same data
length(unique(wwarn_pd$url))

# filter to Africa countries
wwarn_pd <- wwarn_pd |>
filter(country %in% c("Angola", "Benin", "Burkina Faso", "Burundi", "Cameroon", "Central African Republic",
Expand All @@ -54,6 +58,9 @@ wwarn_pd <- wwarn_pd |>
"Zimbabwe", "Eritrea", "South sudan", "Libya", "Djibouti", "Algeria", "Botswana",
"Somalia"))

# count studies
length(unique(wwarn_pd$url))

# merge with data on PMID
df_PMID <- read.csv(here("analysis", "data-raw", "WWARN_pd_PMID.csv"))
wwarn_pd <- wwarn_pd |>
Expand All @@ -63,6 +70,9 @@ wwarn_pd <- wwarn_pd |>
wwarn_pd <- wwarn_pd |>
filter(!is.na(PMID))

# count studies
length(unique(wwarn_pd$PMID))

# drop studies already in GEOFF
s <- readRDS(here("analysis", "data-derived", "geoff_STAVE.rds"))
PMID_geoff <- s$get_studies() |>
Expand All @@ -72,6 +82,9 @@ PMID_geoff <- s$get_studies() |>
wwarn_pd <- wwarn_pd|>
filter(!(PMID %in% PMID_geoff))

# count studies
length(unique(wwarn_pd$PMID))

# remove specific PMIDs
wwarn_pd <- wwarn_pd |>
filter(PMID != 26236581) |> # data has some issues (numerator doesn't sum to denominator) and the original paper does not provide sufficient detail to correct
Expand Down Expand Up @@ -119,25 +132,32 @@ wwarn_pd <- wwarn_pd |>
select(study_id, survey_id, country, site, lon, lat, study_start, study_end,
variant_string, present, tested, PMID)

# count studies
length(unique(wwarn_pd$PMID))

# replace some values manually from file where there are mistakes in the original
# note that this includes 5 studies identified through cleaning of WWARN k13 data where PD data are also available. Hence the total studies will increase by 5.
sheet_names <- excel_sheets(here("analysis", "data-raw", "PMID_pd_replace.xlsx"))
for (i in seq_along(sheet_names)) {
wwarn_pd <- wwarn_pd |>
filter(PMID != as.numeric(sheet_names[i])) |>
bind_rows(readxl::read_excel(here("analysis", "data-raw", "PMID_pd_replace.xlsx"), sheet = sheet_names[i]))
}

# count studies
length(unique(wwarn_pd$PMID))

# merge with info on paper
df_paper <- read.csv(here("analysis", "data-raw", "paper_info.csv")) |>
distinct(PMID, .keep_all = TRUE)
wwarn_pd <- wwarn_pd |>
left_join(df_paper,
by = join_by(PMID))

# ------------------------------------------------------------------------

# tidy up and save to file
# tidy up
wwarn_pd <- wwarn_pd |>
select(-c(url, doi))

# save to file
saveRDS(wwarn_pd, file = here("analysis", "data-derived", "wwarn_pd_clean.rds"))

30 changes: 27 additions & 3 deletions analysis/09_read_who.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ who <- left_join(who_res, who_df, by = "ID") |>
mutate(LATITUDE = as.numeric(LATITUDE),
LONGITUDE = as.numeric(LONGITUDE))

# Filter to k13, as mdr1 is copy number info only, and no crt left after previous filters
who <- who |>
filter(MM_TYPE == "Pfkelch13")

# count studies
who |>
group_by(DATA_SOURCE, CITATION_URL) |>
summarise() |>
nrow()

# Subset to African samples
who_countries <- c("Angola", "Benin", "Botswana", "Burkina Faso", "Burundi", "Côte d’Ivoire",
"Cabo Verde", "Cameroon", "Central African Republic", "Chad",
Expand All @@ -52,9 +62,11 @@ who_countries <- c("Angola", "Benin", "Botswana", "Burkina Faso", "Burundi", "C
who <- who |>
filter(COUNTRY_NAME %in% who_countries)

# Filter to k13, as mdr1 is copy number info only, and no crt left after previous filters
who <- who |>
filter(MM_TYPE == "Pfkelch13")
# count studies
who |>
group_by(DATA_SOURCE, CITATION_URL) |>
summarise() |>
nrow()

# filter to those with citation
who <- who |>
Expand All @@ -67,6 +79,9 @@ who <- who |>
rename(url = CITATION_URL) |>
left_join(paper_info, by = join_by(url))

# count studies
length(unique(who$PMID))

# drop studies already in GEOFF
s <- readRDS(here("analysis", "data-derived", "geoff_STAVE.rds"))
PMID_geoff <- s$get_studies()$PMID
Expand All @@ -75,13 +90,19 @@ PMID_geoff <- PMID_geoff[!is.na(PMID_geoff)]
who <- who |>
filter(!(PMID %in% PMID_geoff))

# count studies
length(unique(who$PMID))

# drop studies already in WWARN
s <- readRDS(here("analysis", "data-derived", "WWARN_STAVE.rds"))
PMID_wwarn <- s$get_studies()$PMID

who <- who |>
filter(!(PMID %in% PMID_wwarn))

# count studies
length(unique(who$PMID))

# get variant_num from proportion
who <- who |>
mutate(variant_num = round(as.numeric(PROPORTION) / 100 * SAMPLE_SIZE))
Expand Down Expand Up @@ -134,6 +155,9 @@ who <- who |>
who <- who |>
filter(!is.na(WT_variant))

# count studies
length(unique(who$PMID))

# overlay variant on top of WT
who <- who |>
mutate(variant_string_combined = overlay_variant(variant_string, WT_variant))
Expand Down
Loading
Loading