diff --git a/R/zika_maps.R b/R/zika_maps.R index 417dce8b..33677a0a 100644 --- a/R/zika_maps.R +++ b/R/zika_maps.R @@ -1,3 +1,5 @@ +# moved to an orderly task within priority pathogens project + library(ggplot2) library(sf) library(rnaturalearth) diff --git a/orderly_config.yml b/orderly_config.yml index a42e95dd..df36e653 100644 --- a/orderly_config.yml +++ b/orderly_config.yml @@ -1,4 +1,4 @@ -minimum_orderly_version: "1.99.0" +minimum_orderly_version: "2.0.2" plugins: orderly.sharedfile: lassasingledb: "Z:/Lassa/Databases/Single Extractions" diff --git a/shared/lassa_functions.R b/shared/lassa_functions.R index 62897c1e..32f82490 100644 --- a/shared/lassa_functions.R +++ b/shared/lassa_functions.R @@ -534,6 +534,8 @@ metaprop_wrap <- function(dataframe, subgroup, method.tau = "ML") png(file = "temp.png", width = width, height = height, res = resolution) + # postscript("CZS_metaanalysis_trimester.eps", width = 15, height = 37, horizontal = FALSE) + # pdf("CZS_metaanalysis_trimester.pdf", width = 10, height = 15) forest(mtan, layout = "RevMan5", overall = plot_pooled, pooled.events = TRUE, print.subgroup.name = FALSE, sort.subgroup = sort_by_subg, @@ -543,9 +545,12 @@ metaprop_wrap <- function(dataframe, subgroup, col.diamond.lines = "black",col.diamond.common = colour, col.diamond.random = colour, col.subgroup = "black", col.inside = "black", weight.study = "same", #col.square.lines = "green", col.square = "blue", #not working - at = at, xlim = xlim, xlab=xlabel, fontsize=11) + at = at, xlim = xlim, xlab=xlabel, fontsize = 11) + # fontsize=9, # Reduce font size + # spacing = 0.7, # Reduce spacing between studies + # squaresize = 0.5) dev.off() - } else { + } else { mtan <- metaprop(data = dataframe, studlab = dataframe[[studylabels]], event = cfr_ifr_numerator, diff --git a/src/zika_compilation/zika_cleaning.R b/src/zika_compilation/zika_cleaning.R index 6179315d..3d92e8d4 100644 --- a/src/zika_compilation/zika_cleaning.R +++ b/src/zika_compilation/zika_cleaning.R @@ -164,6 +164,7 @@ zika_clean_articles <- function(df, pathogen){ df <- df %>% mutate(# Fix issues with dois doi = str_remove_all(doi, 'doi:'), + doi = str_remove_all(doi, 'DOI: '), doi = str_remove_all(doi, 'http://dx.doi.org/'), doi = str_remove_all(doi, 'https://doi.org/'), doi = str_remove(doi, "^/"), @@ -173,7 +174,17 @@ zika_clean_articles <- function(df, pathogen){ covidence_id %in% 1154 ~ "10.1136/bmjgh-2017-000309", covidence_id %in% 1993 ~ "10.1080/00034983.1983.11811687", covidence_id %in% 3042 ~ "10.1371/journal.pntd.0004726", + covidence_id %in% 5695 ~ '10.3390/ijerph18041831', + covidence_id %in% 8141 ~ '10.1016/j.ijid.2023.01.033', + covidence_id %in% 11565 ~ '10.3390/v13030523', + covidence_id %in% 31965 ~ '10.1001/jamanetworkopen.2019.8124', TRUE ~ doi + ), + journal = case_when( + covidence_id %in% 5695 ~ 'INTERNATIONAL JOURNAL OF ENVIRONMENTAL RESEARCH AND PUBLIC HEALTH', + covidence_id %in% 8141 ~ 'INTERNATIONAL JOURNAL OF INFECTIOUS DISEASES', + covidence_id %in% 11565 ~ 'Viruses', + TRUE ~ journal )) #%>% # # Update article label # # for different articles by the same author in the same year diff --git a/src/zika_compilation/zika_compilation.R b/src/zika_compilation/zika_compilation.R index 68983a87..ebe77839 100644 --- a/src/zika_compilation/zika_compilation.R +++ b/src/zika_compilation/zika_compilation.R @@ -3,7 +3,7 @@ # install.packages('rio') library(dplyr) library(janitor) -library(orderly2) +library(orderly) library(readr) library(stringr) library(stringi) @@ -237,12 +237,12 @@ saveRDS(params_clean, 'parameters.rds') params_clean_epireview <- params_clean %>% select(-pathogen, -starts_with('parameter_2'), -delay_start, -access_param_id, -other_delay_start, -other_delay_end, -method_2_from_supplement, - -starts_with('distribution_2'), -exponent_2, inverse_param_2, name_data_entry, + -starts_with('distribution_2'), -exponent_2, -inverse_param_2, -name_data_entry, -other_delay) %>% mutate(prnt_on_elisa = ifelse(prnt_on_elisa == 'V', TRUE, ifelse(prnt_on_elisa == 'F', FALSE, NA))) articles_qa_epireview <- articles_qa %>% - select(-name_data_entry, -covidence_id_text, -qa_denominator, -qa_numerator, -qa_score) + select(-name_data_entry, -notes, -covidence_id_text, -qa_denominator, -qa_numerator, -qa_score) write_csv(articles_qa_epireview, 'zika_articles.csv') write_csv(models_clean, 'zika_models.csv') diff --git a/src/zika_delays/zika_delays.R b/src/zika_delays/zika_delays.R index f6adc147..f3699121 100644 --- a/src/zika_delays/zika_delays.R +++ b/src/zika_delays/zika_delays.R @@ -14,7 +14,7 @@ library(png) library(grid) library(patchwork) library(gridExtra) -library(orderly2) +library(orderly) library(countrycode) #orderly preparation @@ -391,7 +391,8 @@ CCDD EEEE" delays_plot <- incp2 + IP_forest + lat_onset_serialplt + outcome_forest + eip_forest+ plot_layout(design = layout) + plot_annotation(tag_levels = 'A') -ggsave("delays.png", plot = delays_plot, width = 24, height = 25, bg = 'white') +ggsave("delays.png", plot = delays_plot, width = 24, height = 25, bg = 'white', device = cairo_pdf) +ggsave("delays.eps", plot = delays_plot, width = 24, height = 25, bg = 'white', device = cairo_ps) ggsave("delays.pdf", plot = delays_plot, width = 24, height = 25, bg = 'white') delays_plotSI <- incp2_noqa + IP_forest_noqa + lat_onset_serialplt_noqa + outcome_forest_noqa + eip_forest_noqa + diff --git a/src/zika_outbreaks/zika_outbreaks.R b/src/zika_outbreaks/zika_outbreaks.R index c87c6030..9865077d 100644 --- a/src/zika_outbreaks/zika_outbreaks.R +++ b/src/zika_outbreaks/zika_outbreaks.R @@ -1,4 +1,4 @@ -# Task to produce results for outbreaks +# Task to produce results for outbreaks library(tidyverse) library(ggplot2) @@ -10,7 +10,7 @@ library(ggrepel) library(countrycode) library(ggpattern) -#orderly preparation +#orderly preparation orderly_strict_mode() orderly_parameters(pathogen = NULL) orderly_dependency("zika_prep_data", "latest(parameter:pathogen == this:pathogen && @@ -24,7 +24,7 @@ outbreaks <- readRDS('outbreaks_curated.rds') articles <- readRDS('articles_curated.rds') world <- ne_countries(scale = 'medium', returnclass = 'sf') -outbreaks <- merge(outbreaks, articles, by = "covidence_id") +outbreaks <- merge(outbreaks, articles, by = "covidence_id") outbreaks <- filter(outbreaks, !qa_score < 0.5) outbreaks.WHO <- c( @@ -32,18 +32,18 @@ outbreaks.WHO <- c( "Côte d’Ivoire", "Ethiopia", "Gabon", "Guinea-Bissau", "Kenya", "Nigeria", "Senegal", "Uganda", "Anguilla", "Antigua and Barbuda" , "Argentina", "Aruba", "Bahamas", "Barbados", "Belize", "Bolivia", "Bonaire", "Sint Eustatius", "Saba", "Brazil", "British Virgin Islands", - "Cayman Islands", "Colombia", "Costa Rica", "Cuba", "Curaçao", "Dominica", "Dominican Republic", + "Cayman Islands", "Colombia", "Costa Rica", "Cuba", "Curaçao", "Dominica", "Dominican Republic", "Ecuador", "El Salvador", "French Guiana", "Grenada", "Guadeloupe", "Guatemala", "Guyana", "Haiti", "Honduras", "Easter Island– Chile", "Jamaica", "Martinique", "Mexico", "Montserrat", "Nicaragua", "Panama", "Paraguay", "Peru", "Puerto Rico", "Saint Barthélemy", "Saint Kitts", "Nevis", "Saint Lucia", "Saint Martin", "Saint Vincent", "Grenadines", - "Saint Maarten", "Suriname", "Trinidad", "Tobago", "Turks", "Caicos", - "United States of America", "United States Virgin Islands", "Venezuela", + "Saint Maarten", "Suriname", "Trinidad", "Tobago", "Turks", "Caicos", + "United States of America", "United States Virgin Islands", "Venezuela", "Bangladesh", "India", "Indonesia", "Maldives", "Myanmar", "Thailand", - "American Samoa", "Cambodia", "Cook Islands", "Fiji", "French Polynesia", + "American Samoa", "Cambodia", "Cook Islands", "Fiji", "French Polynesia", "Lao People’s Democratic Republic","Marshall Islands", "Malaysia", "Micronesia" , "New Caledonia", "Palau", "Papua New Guinea", "Philippines", "Samoa", "Singapore", - "Solomon Islands", "Tonga", "Vanuatu", "Vietnam", "France", "The Bahamas" + "Solomon Islands", "Tonga", "Vanuatu", "Vietnam", "France", "The Bahamas" ) outbreaks_agg <- outbreaks %>% @@ -70,7 +70,7 @@ out_sf <- out_sf %>% out_plt <- ggplot() + # Layer based on n outbreaks geom_sf(data = out_sf, aes(fill = as.factor(n)), color = "gray50", lwd = 0.3) + - + # Layer for outbreak.WHO geom_sf_pattern( data = filter(out_sf, is_outbreak_who), @@ -85,26 +85,46 @@ out_plt <- ggplot() + pattern_size = 0.01, color = NA ) + - + # Viridis scale - scale_fill_viridis_d(na.value = 'grey90', guide = guide_legend(na.translate = FALSE)) + + scale_fill_viridis_d(na.value = 'grey90', guide = guide_legend( + na.translate = FALSE, + keywidth = unit(0.3, "cm"), + keyheight = unit(0.3, "cm") + )) + theme_void() + theme(axis.text = element_blank(), text = element_text(size = 14)) + labs(fill = 'Number of papers\nreporting outbreaks', x = '', y = '') + - + # labels geom_label_repel(data = out_sf %>% filter(!is.na(n)), - aes(x = label_x, y = label_y, label = paste0(admin, ": ", n)), + aes(x = label_x, y = label_y, label = paste0(admin, ": ", n)), fontface = "bold", size = 3, max.overlaps = 50, label.padding = 0.2) + - + theme(legend.position = c(0.1,0.2), + legend.text = element_text(size = 6), + legend.title = element_text(size = 6))+ + coord_sf(xlim = c(-180, 180), ylim = c(-60, 90)) +ggsave( + "outbreaks_QA2.pdf", + device = cairo_pdf, + plot = out_plt, + width = 180, + height = 100, + scale = 1.2, + units = "mm", + bg = "white" + ) + ggsave("outbreaks_QA.png", out_plt, bg = 'white', height = 8, width = 14, dpi =300) +ggsave("outbreaks_QA.svg", out_plt, bg = 'white', height = 8, width = 14, dpi =300) +ggsave("outbreaks_QA.eps", out_plt, device = eps, bg = 'white', height = 8, width = 14, dpi =300) # ggsave("outbreaks.png", out_plt, bg = 'white', height = 8, width = 14, dpi =300) # ggsave("sero_all.png", sero_all, bg = 'white') # ggsave("sero_general.png", sero_gen, bg = 'white') @@ -114,13 +134,13 @@ ggsave("outbreaks_QA.png", out_plt, bg = 'white', height = 8, width = 14, dpi =3 # nrow(outbreaks) # length(unique(outbreaks$covidence_id)) # length(unique(outbreaks$outbreak_country)) -# +# # table(outbreaks$outbreak_country) # outsumm <- as.data.frame(table(outbreaks$outbreak_country, outbreaks$covidence_id)) %>% # filter(Freq > 0) %>% # group_by(Var1) %>% # count() -# +# # outbreaks <- outbreaks %>% # mutate(continent = countrycode(sourcevar = outbreak_country, # origin = "country.name", diff --git a/src/zika_prep_data/zika_prep_data.R b/src/zika_prep_data/zika_prep_data.R index 2efdc574..c619f8bc 100644 --- a/src/zika_prep_data/zika_prep_data.R +++ b/src/zika_prep_data/zika_prep_data.R @@ -5,6 +5,7 @@ # as well as the ad-hoc data cleaning in each of the analysis orderly tasks library(dplyr) library(stringr) +library(readr) #orderly preparation orderly_strict_mode() diff --git a/src/zika_reproduction_numbers/zika_reproduction_numbers.R b/src/zika_reproduction_numbers/zika_reproduction_numbers.R index e056d7e8..48c1030c 100644 --- a/src/zika_reproduction_numbers/zika_reproduction_numbers.R +++ b/src/zika_reproduction_numbers/zika_reproduction_numbers.R @@ -14,7 +14,7 @@ library(png) library(grid) library(patchwork) library(gridExtra) -library(orderly2) +library(orderly) library(countrycode) library(janitor) @@ -320,13 +320,21 @@ re_mosquito <- forest_plot_zika(parameters %>% filter(parameter_type == 'Reprodu HEIGHT = 25 WIDTH = 20 -ggsave("r0_pc.pdf", r0_pc, height = HEIGHT, width = WIDTH, bg = 'white') -ggsave("r0_sampletype.pdf", r0_sampletype, height = 24, width = WIDTH, bg = 'white') -ggsave("r0_human.pdf", r0_human, height = 10, width = WIDTH, bg = 'white') -ggsave("r0_mosquito.pdf", r0_mosquito, height = 8, width = WIDTH, bg = 'white') -ggsave("re.pdf", re, height = 14, width = WIDTH, bg = 'white') -ggsave("re_human.pdf", re_human, height = 12, width = 12, bg = 'white') -ggsave("re_mosquito.pdf", re_mosquito, height = 10, width = 12, bg = 'white') +ggsave("r0_pc.pdf", r0_pc, height = HEIGHT, width = WIDTH, bg = 'white', device = cairo_pdf) +ggsave("r0_sampletype.pdf", r0_sampletype, height = 24, width = WIDTH, bg = 'white', device = cairo_pdf) +ggsave("r0_human.pdf", r0_human, height = 10, width = WIDTH, bg = 'white', device = cairo_pdf) +ggsave("r0_mosquito.pdf", r0_mosquito, height = 8, width = WIDTH, bg = 'white', device = cairo_pdf) +ggsave("re.pdf", re, height = 14, width = WIDTH, bg = 'white', device = cairo_pdf) +ggsave("re_human.pdf", re_human, height = 12, width = 12, bg = 'white', device = cairo_pdf) +ggsave("re_mosquito.pdf", re_mosquito, height = 10, width = 12, bg = 'white', device = cairo_pdf) + +ggsave("r0_pc.eps", r0_pc, height = HEIGHT, width = WIDTH, bg = 'white', device = cairo_ps) +ggsave("r0_sampletype.eps", r0_sampletype, height = 24, width = WIDTH, bg = 'white', device = cairo_ps) +ggsave("r0_human.eps", r0_human, height = 10, width = WIDTH, bg = 'white', device = cairo_ps) +ggsave("r0_mosquito.eps", r0_mosquito, height = 8, width = WIDTH, bg = 'white', device = cairo_ps) +ggsave("re.eps", re, height = 14, width = WIDTH, bg = 'white', device = cairo_ps) +ggsave("re_human.eps", re_human, height = 12, width = 12, bg = 'white', device = cairo_ps) +ggsave("re_mosquito.eps", re_mosquito, height = 10, width = 12, bg = 'white', device = cairo_ps) ggsave("r0_pc.png", r0_pc, height = HEIGHT, width = WIDTH, bg = 'white') ggsave("r0_sampletype.png", r0_sampletype, height = 24, width = WIDTH, bg = 'white') @@ -375,6 +383,11 @@ ggsave("r0_plnoqa.pdf", r0__plnoqa, height = 25, width = 20, bg = 'white') ggsave("re_pl.pdf", re_pl, height = 12, width = 20, bg = 'white') ggsave("re_plnoqa.pdf", re_plnoqa, height = 12, width = 20, bg = 'white') +ggsave("r0_pl.eps", r0_pl, height = 25, width = 20, bg = 'white', device = cairo_ps) +ggsave("r0_plnoqa.eps", r0__plnoqa, height = 25, width = 20, bg = 'white', device = cairo_ps) +ggsave("re_pl.eps", re_pl, height = 12, width = 20, bg = 'white', device = cairo_ps) +ggsave("re_plnoqa.eps", re_plnoqa, height = 12, width = 20, bg = 'white', device = cairo_ps) + ggsave("r0_pl.png", r0_pl, height = 25, width = 20, bg = 'white', dpi = 400) ggsave("r0_plnoqa.png", r0__plnoqa, height = 25, width = 20, bg = 'white', dpi = 400) ggsave("re_pl.png", re_pl, height = 12, width = 20, bg = 'white', dpi = 400) diff --git a/src/zika_serop/zika_serop.R b/src/zika_serop/zika_serop.R index 5a6bebd4..48cab720 100644 --- a/src/zika_serop/zika_serop.R +++ b/src/zika_serop/zika_serop.R @@ -307,8 +307,8 @@ central_africa <- ggplot() + central_africa <- central_africa+ labs(fill = NULL, col = NULL) + theme(legend.position = c(0.2,0.3), - legend.text = element_text(size = 6), - legend.title = element_text(size = 6))+ + legend.text = element_text(size = 12), + legend.title = element_text(size = 12))+ # theme(legend.position = "none")+ # legend.background = element_rect(fill = "transparent"))+ #theme(legend.position = c(0.1,0.2))+ @@ -334,9 +334,22 @@ central_asia <- central_asia + axis.title = element_blank() # Remove axis titles ) +# coord <- coord_sf(expand = FALSE) + +# south_america <- south_america + coord +# central_africa <- central_africa + coord +# central_asia <- central_asia + coord + +final_plot <- ggarrange( + south_america, + central_africa, + central_asia, + ncol = 3, + align = "hv" +) # Final multipanel plot -final_plot <- wrap_plots(south_america, central_africa, central_asia, ncol = 3) +final_plot <- ggarrange(south_america, central_africa, central_asia, ncol = 3) # + # plot_layout(guides = "none") # final_plot @@ -348,8 +361,42 @@ ggsave( paste0("ZIKA_serop_map_QA.png"), plot = final_plot, device = png, + scale = 1, - height = 50, + height = 100, + width = 200, + units = "mm", + dpi = 300) + +ggsave( + paste0("ZIKA_serop_map_QA_AF.pdf"), + plot = central_africa, + # device = pdf, + device = cairo_pdf, + scale = 1, + height = 200, + width = 200, + units = "mm", + dpi = 300) + +ggsave( + paste0("ZIKA_serop_map_QA_SA.pdf"), + plot = south_america, + # device = pdf, + device = cairo_pdf, + scale = 1, + height = 200, + width = 200, + units = "mm", + dpi = 300) + +ggsave( + paste0("ZIKA_serop_map_QA_AS.pdf"), + plot = central_asia, + device = cairo_pdf, + # device = pdf, + scale = 1, + height = 200, width = 200, units = "mm", dpi = 300) diff --git a/src/zika_zcs_microcephaly/zika_zcs_microcephaly.R b/src/zika_zcs_microcephaly/zika_zcs_microcephaly.R index 3956018a..6b292f73 100644 --- a/src/zika_zcs_microcephaly/zika_zcs_microcephaly.R +++ b/src/zika_zcs_microcephaly/zika_zcs_microcephaly.R @@ -14,7 +14,7 @@ library(png) library(grid) library(patchwork) library(gridExtra) -library(orderly2) +library(orderly) library(countrycode) #orderly preparation @@ -181,7 +181,8 @@ CZSplot_noqa <- forest_plot_zika(CZS_rate %>% arrange(central) , custom_colours = cols) + theme(legend.position = 'inside', legend.position.inside = c(.66, 0.36)) # ggsave(filename = 'CZS_plot_loc_country.svg', CZSplot, height =26, width = 14, bg = 'white') -ggsave(filename = 'CZS_plot_loc_country.pdf', CZSplot, height =24, width = 15, bg = 'white') +ggsave(filename = 'CZS_plot_loc_country.pdf', CZSplot, height =24, width = 15, bg = 'white', device = cairo_pdf) +ggsave(filename = 'CZS_plot_loc_country.eps', CZSplot, height =24, width = 15, bg = 'white', device = cairo_ps) # ggsave(filename = 'CZS_plot_loc_country_noqa.svg', CZSplot_noqa, height =32, width = 16, bg = 'white') ggsave(filename = 'CZS_plot_loc_country_noqa.pdf', CZSplot_noqa, height =32, width = 16, bg = 'white') @@ -360,7 +361,8 @@ metaanalysis_CZS_trimester <- metaprop_wrap(dataframe = CZSqa , CZS_meta_trimester <- metaanalysis_CZS_trimester$plot ggsave(filename = "CZS_metaanalysis_trimester.svg", plot = CZS_meta_trimester, width = 5, height = 9) -ggsave(filename = "CZS_metaanalysis_trimester.pdf", plot = CZS_meta_trimester, width = 5, height = 9) +ggsave(filename = "CZS_metaanalysis_trimester.pdf", plot = CZS_meta_trimester, width = 5, height = 9, device = cairo_pdf) +ggsave(filename = "CZS_metaanalysis_trimester.eps", plot = CZS_meta_trimester, width = 9, height = 5, device = cairo_ps, dpi = 500) metaanalysis_CZS_trimester_noqa <- metaprop_wrap(dataframe = CZS_meta_noqa, plot_pooled = FALSE, subgroup = 'trimester_exposed', diff --git a/zika_workflow.R b/zika_workflow.R index ff02e1e7..2f863ded 100644 --- a/zika_workflow.R +++ b/zika_workflow.R @@ -4,7 +4,7 @@ # install.packages("orderly2", repos = c("https://mrc-ide.r-universe.dev", "https://cloud.r-project.org")) # remotes::install_github("mrc-ide/orderly.sharedfile") #orderly2::orderly_init(".") -library(orderly2) +library(orderly) library(optparse) library(ids) library(zip) @@ -90,9 +90,9 @@ orderly_run("zika_compilation", parameters = list(pathogen = "ZIKA")) ############## # Data curation for analysis -orderly2::orderly_run('zika_prep_data', parameters = list(pathogen = 'ZIKA', +orderly::orderly_run('zika_prep_data', parameters = list(pathogen = 'ZIKA', plotting = TRUE)) -orderly2::orderly_run('zika_prep_data', parameters = list(pathogen = 'ZIKA', +orderly::orderly_run('zika_prep_data', parameters = list(pathogen = 'ZIKA', plotting = FALSE)) # Delay figures