From e823fe715ae613e6202e2dab7551d1b9b9829ea9 Mon Sep 17 00:00:00 2001 From: James Fellows Yates Date: Tue, 20 Dec 2022 21:45:07 +0100 Subject: [PATCH] Finalise auto-release stats script --- assets/analysis/release-stats-script.R | 90 ------------------- .../release-stats-statement-generator.R | 71 +++++++++++++++ .../release_stats_statement_generator.R | 39 -------- 3 files changed, 71 insertions(+), 129 deletions(-) delete mode 100644 assets/analysis/release-stats-script.R create mode 100644 assets/analysis/release-stats-statement-generator.R delete mode 100644 assets/utility/release_stats_statement_generator.R diff --git a/assets/analysis/release-stats-script.R b/assets/analysis/release-stats-script.R deleted file mode 100644 index cceea50cc..000000000 --- a/assets/analysis/release-stats-script.R +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/env R - -library(tidyverse) -library(zen4R) - -############################## -## Release Stats Generation ## -############################## - - -## Download previous release from Zenodo: https://doi.org/10.5281/zenodo.3980833 - -## Load previous release files -old_path <- "/home/jfellows/Downloads/AncientMetagenomeDir-v21.09/SPAAM-community-AncientMetagenomeDir-d9610d3/" - -old_senv <- read_tsv(paste0(old_path, "ancientmetagenome-environmental/ancientmetagenome-environmental.tsv")) -old_shos <- read_tsv(paste0(old_path, "ancientmetagenome-hostassociated/ancientmetagenome-hostassociated.tsv")) -old_ssin <- read_tsv(paste0(old_path, "ancientsinglegenome-hostassociated/ancientsinglegenome-hostassociated.tsv")) - -## after v22.09 onwards -#old_senv <- read_tsv(paste0(old_path, "ancientmetagenome-environmental/samples/ancientmetagenome-environmental_samples.tsv")) -#old_shos <- read_tsv(paste0(old_path, "ancientmetagenome-hostassociated/samples/ancientmetagenome-hostassociated_samples.tsv")) -#old_ssin <- read_tsv(paste0(old_path, "ancientsinglegenome-hostassociated/samples/ancientsinglegenome-hostassociated_samples.tsv")) -#old_lenv <- read_tsv(paste0(old_path, "ancientmetagenome-environmental/libraries/ancientmetagenome-environmental_libraries.tsv")) -#old_lhos <- read_tsv(paste0(old_path, "ancientmetagenome-hostassociated/libraries/ancientmetagenome-hostassociated_libraries.tsv")) -#old_lsin <- read_tsv(paste0(old_path, "ancientsinglegenome-hostassociated/libraries/ancientsinglegenome-hostassociated_libraries.tsv")) - -## Load new release files - -new_senv <- read_tsv("ancientmetagenome-environmental/samples/ancientmetagenome-environmental_samples.tsv") -new_shos <- read_tsv("ancientmetagenome-hostassociated/samples/ancientmetagenome-hostassociated_samples.tsv") -new_ssin <- read_tsv("ancientsinglegenome-hostassociated/samples/ancientsinglegenome-hostassociated_samples.tsv") -new_lenv <- read_tsv("ancientmetagenome-environmental/libraries/ancientmetagenome-environmental_libraries.tsv") -new_lhos <- read_tsv("ancientmetagenome-hostassociated/libraries/ancientmetagenome-hostassociated_libraries.tsv") -new_lsin <- read_tsv("ancientsinglegenome-hostassociated/libraries/ancientsinglegenome-hostassociated_libraries.tsv") - -## Find differences - -## New -print("PUBLICATIONS") - -old_pubs <- c(old_senv$project_name, old_shos$project_name, old_ssin$project_name) %>% unique -new_pubs <- c(new_senv$project_name, new_shos$project_name, new_ssin$project_name) %>% unique - -## DOESN'T REPORT REMOVED! -print(paste("New:", length(new_pubs), "Old:", length(old_pubs), "Gain:", length(new_pubs) - length(old_pubs))) - -print("SAMPLES") -for ( i in c("senv", "shos", "ssin")) { - old_res <- paste0("old_", i) - new_res <- paste0("new_", i) - - old_n <- nrow(eval(as.name(old_res))) - new_n <- nrow(eval(as.name(new_res))) - - new_diff <- new_n - old_n - - print(paste(old_res,":", old_n)) - print(paste(new_res,":", new_n)) - print(paste(i, "change:", new_diff)) -} - -print("LIBRARIES") -for ( i in c("lenv", "lhos", "lsin")) { - #old_res <- paste0("old_", i) - new_res <- paste0("new_", i) - - #old_n <- nrow(eval(as.name(old_res))) - new_n <- nrow(eval(as.name(new_res))) - - #new_diff <- new_n - old_n - - #print(paste(old_res,":", old_n)) - print(paste(new_res,":", new_n)) - #print(paste("change:", new_diff)) -} - -### MESSAGE - -##Release v22.09 includes 7 new publications, representing XXX new ancient host-associated metagenome samples, XX new ancient microbial genomes, and XX new ancient environmental samples. - -##It adds XXX new new ancient host-associated metagenome libraries, XX new ancient microbial genome libraries, and XX new ancient environmental libraries. - - -##This brings the repository to a total of 132 publications, 1038 new ancient host-associated metagenome samples, 368 ancient microbial genomes, and 375 new ancient environmental samples. - - -## Load latest release - -## Compare and print stats test diff --git a/assets/analysis/release-stats-statement-generator.R b/assets/analysis/release-stats-statement-generator.R new file mode 100644 index 000000000..c61f011ec --- /dev/null +++ b/assets/analysis/release-stats-statement-generator.R @@ -0,0 +1,71 @@ +suppressPackageStartupMessages(library(tidyverse)) + +previous_tag <- "v22.09" +release_tag <- "master" +new_release <- "v22.10" + +## SAMPLES + +previous_env_samples <- read_tsv(paste0("https://github.com/SPAAM-community/AncientMetagenomeDir/raw/", previous_tag, "/ancientmetagenome-environmental/samples/ancientmetagenome-environmental_samples.tsv"), show_col_types = FALSE) +previous_microb_samples <- read_tsv(paste0("https://github.com/SPAAM-community/AncientMetagenomeDir/raw/", previous_tag, "/ancientmetagenome-hostassociated/samples/ancientmetagenome-hostassociated_samples.tsv"), show_col_types = FALSE) +previous_single_samples <- read_tsv(paste0("https://github.com/SPAAM-community/AncientMetagenomeDir/raw/", previous_tag, "/ancientsinglegenome-hostassociated/samples/ancientsinglegenome-hostassociated_samples.tsv"), show_col_types = FALSE) +previous_pubs_samples <- c(previous_env_samples$publication_doi, previous_microb_samples$publication_doi, previous_single_samples$publication_doi) %>% unique() %>% length + +new_env_samples <- read_tsv(paste0("https://github.com/SPAAM-community/AncientMetagenomeDir/raw/", release_tag, "/ancientmetagenome-environmental/samples/ancientmetagenome-environmental_samples.tsv"), show_col_types = FALSE) +new_microb_samples <- read_tsv(paste0("https://github.com/SPAAM-community/AncientMetagenomeDir/raw/", release_tag, "/ancientmetagenome-hostassociated/samples/ancientmetagenome-hostassociated_samples.tsv"), show_col_types = FALSE) +new_single_samples <- read_tsv(paste0("https://github.com/SPAAM-community/AncientMetagenomeDir/raw/", release_tag, "/ancientsinglegenome-hostassociated/samples/ancientsinglegenome-hostassociated_samples.tsv"), show_col_types = FALSE) +new_pubs_samples <- c(new_env_samples$publication_doi, new_microb_samples$publication_doi, new_single_samples$publication_doi) %>% unique() %>% length + +adds_pubs_samples <- new_pubs_samples - previous_pubs_samples +adds_env_samples <- nrow(new_env_samples) - nrow(previous_env_samples) +adds_microb_samples <- nrow(new_microb_samples) - nrow(previous_microb_samples) +adds_single_samples <- nrow(new_single_samples) - nrow(previous_single_samples) + +tot_pubs_samples <- new_pubs_samples +tot_env_samples <- nrow(new_env_samples) +tot_microb_samples <- nrow(new_microb_samples) +tot_single_samples <- nrow(new_single_samples) + +## LIBRARIES + +previous_env_libraries <- read_tsv(paste0("https://github.com/SPAAM-community/AncientMetagenomeDir/raw/", previous_tag, "/ancientmetagenome-environmental/libraries/ancientmetagenome-environmental_libraries.tsv"), show_col_types = FALSE) +previous_microb_libraries <- read_tsv(paste0("https://github.com/SPAAM-community/AncientMetagenomeDir/raw/", previous_tag, "/ancientmetagenome-hostassociated/libraries/ancientmetagenome-hostassociated_libraries.tsv"), show_col_types = FALSE) +previous_single_libraries <- read_tsv(paste0("https://github.com/SPAAM-community/AncientMetagenomeDir/raw/", previous_tag, "/ancientsinglegenome-hostassociated/libraries/ancientsinglegenome-hostassociated_libraries.tsv"), show_col_types = FALSE) +previous_pubs_libraries <- c(previous_env_libraries$data_publication_doi, previous_microb_libraries$data_publication_doi, previous_single_libraries$data_publication_doi) %>% unique() %>% length + +new_env_libraries <- read_tsv(paste0("https://github.com/SPAAM-community/AncientMetagenomeDir/raw/", release_tag, "/ancientmetagenome-environmental/libraries/ancientmetagenome-environmental_libraries.tsv"), show_col_types = FALSE) +new_microb_libraries <- read_tsv(paste0("https://github.com/SPAAM-community/AncientMetagenomeDir/raw/", release_tag, "/ancientmetagenome-hostassociated/libraries/ancientmetagenome-hostassociated_libraries.tsv"), show_col_types = FALSE) +new_single_libraries <- read_tsv(paste0("https://github.com/SPAAM-community/AncientMetagenomeDir/raw/", release_tag, "/ancientsinglegenome-hostassociated/libraries/ancientsinglegenome-hostassociated_libraries.tsv"), show_col_types = FALSE) +new_pubs_libraries <- c(new_env_libraries$data_publication_doi, new_microb_libraries$data_publication_doi, new_single_libraries$data_publication_doi) %>% unique() %>% length + +adds_pubs_libraries <- new_pubs_libraries - previous_pubs_libraries +adds_env_libraries <- nrow(new_env_libraries) - nrow(previous_env_libraries) +adds_microb_libraries <- nrow(new_microb_libraries) - nrow(previous_microb_libraries) +adds_single_libraries <- nrow(new_single_libraries) - nrow(previous_single_libraries) + +tot_pubs_libraries <- new_pubs_libraries +tot_env_libraries <- nrow(new_env_libraries) +tot_microb_libraries <- nrow(new_microb_libraries) +tot_single_libraries <- nrow(new_single_libraries) + +## STATEMENTS + +cat("\nRelease ", new_release, + " includes ", adds_pubs_samples, " new publications, representing", + adds_microb_samples, "new ancient host-associated metagenome samples,", + adds_single_samples, "new ancient microbial genomes, and", + adds_env_samples, "new ancient environmental samples.", + "This brings the repository to a total of", + tot_pubs_samples, " publications,", + tot_microb_samples, "ancient host-associated metagenome samples,", + tot_single_samples, "ancient microbial genomes, and", + tot_env_samples, "ancient environmental samples\n\nFurthemermore, this release adds", + adds_microb_libraries, "new ancient host-associated metagenome libraries,", + adds_single_libraries, "new ancient microbial genome libraries, and", + adds_env_libraries, "new ancient environmental libraries.", + "This brings the repository to a total of", + tot_microb_libraries, "ancient host-associated metagenome libraries,", + tot_single_libraries, "ancient microbial genomes libraries, and", + tot_env_libraries, "ancient environmental libraries.\n\n" +) + diff --git a/assets/utility/release_stats_statement_generator.R b/assets/utility/release_stats_statement_generator.R deleted file mode 100644 index f3573ef82..000000000 --- a/assets/utility/release_stats_statement_generator.R +++ /dev/null @@ -1,39 +0,0 @@ -library(tidyverse) - -previous_tag <- "v21.09" -release_tag <- "master" -new_release <- "v22.09" - -previous_env <- read_tsv(paste0("https://github.com/SPAAM-community/AncientMetagenomeDir/raw/", previous_tag, "/ancientmetagenome-environmental/ancientmetagenome-environmental.tsv")) -previous_microb <- read_tsv(paste0("https://github.com/SPAAM-community/AncientMetagenomeDir/raw/", previous_tag, "/ancientmetagenome-hostassociated/ancientmetagenome-hostassociated.tsv")) -previous_single <- read_tsv(paste0("https://github.com/SPAAM-community/AncientMetagenomeDir/raw/", previous_tag, "/ancientsinglegenome-hostassociated/ancientsinglegenome-hostassociated.tsv")) -previous_pubs <- c(previous_env$publication_doi, previous_microb$publication_doi, previous_single$publication_doi) %>% unique() %>% length - -new_env <- read_tsv(paste0("https://github.com/SPAAM-community/AncientMetagenomeDir/raw/", release_tag, "/ancientmetagenome-environmental/samples/ancientmetagenome-environmental_samples.tsv")) -new_microb <- read_tsv(paste0("https://github.com/SPAAM-community/AncientMetagenomeDir/raw/", release_tag, "/ancientmetagenome-hostassociated/samples/ancientmetagenome-hostassociated_samples.tsv")) -new_single <- read_tsv(paste0("https://github.com/SPAAM-community/AncientMetagenomeDir/raw/", release_tag, "/ancientsinglegenome-hostassociated/samples/ancientsinglegenome-hostassociated_samples.tsv")) -new_pubs <- c(new_env$publication_doi, new_microb$publication_doi, new_single$publication_doi) %>% unique() %>% length - -adds_pubs <- new_pubs - previous_pubs -adds_env <- nrow(new_env) - nrow(previous_env) -adds_microb <- nrow(new_microb) - nrow(previous_microb) -adds_single <- nrow(new_single) - nrow(previous_single) - -tot_pubs <- new_pubs -tot_env <- nrow(new_env) -tot_microb <- nrow(new_microb) -tot_single <- nrow(new_single) - -## TODO TO EXTEND TO INCLUDE LIBRARY - -paste0("Release ", new_release, - " includes ", adds_pubs, " new publications, representing ", - adds_microb, " new ancient host-associated metagenome samples, ", - adds_single, " new ancient microbial genomes, and ", - adds_env , " new ancient environmental samples. ", - "This brings the repository to a total of ", - tot_pubs, " publications, ", - tot_microb, " new ancient host-associated metagenome samples, ", - tot_single, " ancient microbial genomes, and ", - tot_env, " new ancient environmental samples" - )