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/10_read_pf8k.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ mdf <- mdf |>
mutate(country = ifelse(country == "Côte d'Ivoire", "Cote d'Ivoire", country)) |>
filter(country %in% pf8_Africa)

# drop one study that is duplicated with published paper (PMID 27899115
# corresponding to MalariaGen study 1248-PF-MW-MCCANN-SM)
mdf <- mdf |>
filter(study_id != "MalariaGEN_1248_PF_MW_MCCANN_SM")

# count studies
length(unique(mdf$study_id))

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.13.rds"))
saveRDS(s, file = here("analysis", "data-out", "stave_data_2026.03.17.rds"))

# ------------------------------------------------------------------
# Some basic stats on the final object
Expand Down
95 changes: 95 additions & 0 deletions analysis/13_deduplicate_pf8.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@

# ------------------------------------------------------------
# get abstracts from PMID for all non-pf8 studies
# (NB, if complains because too many queries, break PMID vector into multiple
# sections and stick back together)

library(rentrez)
library(xml2)

s_geoff <- readRDS(file = here("analysis", "data-derived", "geoff_STAVE.rds"))
s_wwarn <- readRDS(file = here("analysis", "data-derived", "WWARN_STAVE.rds"))
s_who <- readRDS(file = here("analysis", "data-derived", "WHO_STAVE.rds"))

# Input PMIDs
pmids <- c(s_geoff$get_studies()$PMID,
s_wwarn$get_studies()$PMID,
s_who$get_studies()$PMID)

pmids <- pmids[!is.na(pmids)]

# Fetch PubMed records as XML
xml_text_raw <- entrez_fetch(
db = "pubmed",
id = pmids,
rettype = "xml",
retmode = "xml"
)

# Parse XML
doc <- read_xml(xml_text_raw)

# Find all PubMed articles
articles <- xml_find_all(doc, ".//PubmedArticle")

# Extract fields
results <- lapply(articles, function(article) {

pmid_node <- xml_find_first(article, ".//PMID")
title_node <- xml_find_first(article, ".//ArticleTitle")
abstract_nodes <- xml_find_all(article, ".//Abstract/AbstractText")
journal_node <- xml_find_first(article, ".//Journal/Title")
year_node <- xml_find_first(article, ".//PubDate/Year")

pmid <- if (inherits(pmid_node, "xml_missing")) NA_character_ else xml_text(pmid_node)
title <- if (inherits(title_node, "xml_missing")) NA_character_ else xml_text(title_node)
journal <- if (inherits(journal_node, "xml_missing")) NA_character_ else xml_text(journal_node)
year <- if (inherits(year_node, "xml_missing")) NA_character_ else xml_text(year_node)

abstract <- if (length(abstract_nodes) == 0) {
NA_character_
} else {
paste(xml_text(abstract_nodes), collapse = " ")
}

data.frame(
PMID = pmid,
Title = title,
Abstract = abstract,
Journal = journal,
Year = year,
stringsAsFactors = FALSE
)
})

# Combine into one data frame
pubmed_data <- do.call(rbind, results)

# ------------------------------------------------------------
# search for WGS data

# option to read in pre-computed from file
#pubmed <- readRDS("/Users/rverity/Desktop/pubmed.rds")

# Patterns related to whole genome sequencing
wgs_patterns <- c(
"\\bwhole genomes? sequenc\\w*\\b",
"\\bwhole-genome sequenc\\w*\\b",
"\\bsequencing of the whole genome\\b",
"\\bwhole genome data\\b",
"\\bwgs\\b",
"\\bgenome[- ]wide sequencing\\b"
)

# match abstracts against patterns
pubmed$WGS <- FALSE
for (i in 1:nrow(pubmed)) {
pubmed$WGS[i] <- any(str_detect(tolower(pubmed$Abstract[[i]]), wgs_patterns))
}

# manually fix papers where cannot get the abstract automatically
pubmed$WGS[346] <- FALSE

pubmed |>
filter(WGS) |>
View()
Binary file modified analysis/data-derived/pf8_STAVE.rds
Binary file not shown.
Binary file removed analysis/data-out/stave_data_2026.03.13.rds
Binary file not shown.
Binary file added analysis/data-out/stave_data_2026.03.17.rds
Binary file not shown.
Binary file modified analysis/data-raw/WWARN_partnerdrug_database_04-12-2023.xls
Binary file not shown.
Binary file modified analysis/plots/sample_collection.pdf
Binary file not shown.
Loading