Estimating $R$ and overdispersion in secondary cases from the size of identical sequence clusters of SARS-CoV-2
This repository contains the code of the statistical analysis of the paper "Estimating
The aim of this repository is to provide everything necessary to reproduce the statistical analysis of the paper cited above. All files (R-scripts as well as data) used to obtain the results are contained in this repository. Furthermore, the complete simulated data used for the validation of the model as well as all stanfit files containing the results of the parameter estimation can be found in this repository.
- The whole R code is structured in an R-project (
R_overdispersion_cluster_size.Rproj
). - Before running any other R file, the file
setup.R
(contained in folderR
) needs to be run. In this file, all paths to data and results files are defined (with respect to the path ofR_overdispersion_cluster_size.Rproj
). - R files are grouped by topic (data processing, creating plots, ...).
- Running the file
main.R
(contained in folderR
) calls all R scripts necessary to redo the processing of data and results as well as the creation of plots and tables. Data and result files need to be stored at the paths defined insetup.R
. - Parameter estimation, both from simulated data and from data from Switzerland, Denmark and Germany, has been run on the high performance computing cluster of the University of Bern, UBELIX.
- Simulation of clusters for the simulation study and for the posterior predictive check have been run on the high performance computing cluster of the University of Bern, UBELIX.
The simulation of identical sequence clusters as well as the models to estimate parameters from the sequence cluster size distribution are implemented as functions in an R-package, called estRodis. The estRodis package can be found here: GitHub Martin Wohlfender: estRodis
The structuring of sequence data into clusters of identical sequences was done by Emma Hodcroft. Her code can be found here: GitHub Emma Hodcroft: sc2_rk_public
Whenever "model one" is mentioned in comments in the code, this refers to the standard model developed in the paper and "model two" refers to the alternative model described in the section "Sensitivity analysis" of the supplementary material.
Load all necessary R-packages and define paths. setup.R
needs to be run first.
Contains all steps needed to process data and results and to create figures and tables.
Custom functions for creating plots. All files in this folder are sourced when running setup.R
.
All R-scripts covering the processing of data and results.
01_sim_setup.R
setting up the simulation study: define parameter combinations for which clusters of identical sequences shall be simulated02_sim_simulate_data_parallel.R
simulation of identical sequence clusters (run in parallel on the high performance computing cluster of the University of Bern, UBELIX)03_sim_estimate_parameters_model_one_parallel.R
estimation of parameters from simulated data (run in parallel on the high performance computing cluster of the University of Bern, UBELIX)
All R-scripts to estimate parameters from data from Switzerland, Denmark and Germany using the main (model one) or the alternative model (mdoel two). These files were run in parallel on the high performance computing cluster of the University of Bern, UBELIX.
01_ppc_model_one_setup.R
setting up the posterior predictive check: define parameter combinations for which clusters of identical sequences shall be simulated02_ppc_model_one_simulations_parallel.R
simulation of identical sequence clusters (run in parallel on the high performance computing cluster of the University of Bern, UBELIX)
All R-scripts covering the creation of figures (contained in paper and supplementary material).
All R-scripts covering the creation of overview tables of data and results (contained in supplementary material).
The repository contains the following data files (see folder data
):
Switzerland_cluster_distribution_dates_100whole.tsv
distribution of size of identical sequence clusters (obtained from GitHub Emma Hodcroft: sc2_rk_public)data_new_confirmed_cases_ch_raw.csv
number of new confirmed cases (obtained from COVID-19 Switzerland)data_r_e_ch_raw.csv
estimate of effective reproduction number on daily basis based on number of confirmed cases (obtained from GitHub covid-19-Re: dailyRe-Data)switzerland_date_only.csv
date of sampling of all sequences contained in identical sequence clusters used for the analysis
data_cases_sequences_clusters_ch_2021_months.csv
overview of number of confirmed cases, number of sequences sampled, number of clusters and size of largest cluster per month in 2021data_cluster_sizes_ch_2021_months.csv
number of clusters of each size in each month of 2021data_clusters_ch_processed.csv
distribution of size of identical sequence clusters, clusters without a valid smapling date eliminateddata_new_confirmed_cases_ch_processed.csv
number of new confirmed cases, filtered to 2021data_r_e_ch_processed.csv
estimate of effective reproduction number on daily basis based on number of confirmed cases, filtered to 2021sequencing_probas_ch_2021_months.csv
probability of a confirmed case being sequenced on monthly basis during 2021
Denmark_cluster_distribution_dates_100whole.tsv
distribution of size of identical sequence clusters (obtained from GitHub Emma Hodcroft: sc2_rk_public)data_new_confirmed_cases_dk_raw.csv
number of new confirmed cases (obtained from Statens Serum Institut)data_r_e_dk_raw.csv
estimate of effective reproduction number on daily basis based on number of confirmed cases (obtained from GitHub covid-19-Re: dailyRe-Data)denmark_date_only.csv
date of sampling of all sequences contained in identical sequence clusters used for the analysis
data_cases_sequences_clusters_dk_2021_months.csv
overview of number of confirmed cases, number of sequences sampled, number of clusters and size of largest cluster per month in 2021data_cluster_sizes_dk_2021_months.csv
number of clusters of each size in each month of 2021data_clusters_dk_processed.csv
distribution of size of identical sequence clusters, clusters without a valid smapling date eliminateddata_new_confirmed_cases_dk_processed.csv
number of new confirmed cases, filtered to 2021data_r_e_dk_processed.csv
estimate of effective reproduction number on daily basis based on number of confirmed cases, filtered to 2021sequencing_probas_dk_2021_months.csv
probability of a confirmed case being sequenced on monthly basis during 2021
Germany_cluster_distribution_dates_100whole.tsv
distribution of size of identical sequence clusters (obtained from GitHub Emma Hodcroft: sc2_rk_public)data_new_confirmed_cases_de_raw.csv
number of new confirmed cases (obtained from GitHub Robert Koch Institut: COVID-19_7-Tage-Inzidenz_in_Deutschland)data_r_e_de_raw.csv
estimate of effective reproduction number on daily basis based on number of confirmed cases (obtained from GitHub covid-19-Re: dailyRe-Data)germany_date_only.csv
date of sampling of all sequences contained in identical sequence clusters used for the analysis
data_cases_sequences_clusters_de_2021_months.csv
overview of number of confirmed cases, number of sequences sampled, number of clusters and size of largest cluster per month in 2021data_cluster_sizes_de_2021_months.csv
number of clusters of each size in each month of 2021data_clusters_de_processed.csv
distribution of size of identical sequence clusters, clusters without a valid smapling date eliminateddata_new_confirmed_cases_de_processed.csv
number of new confirmed cases, filtered to 2021data_r_e_de_processed.csv
estimate of effective reproduction number on daily basis based on number of confirmed cases, filtered to 2021sequencing_probas_de_2021_months.csv
probability of a confirmed case being sequenced on monthly basis during 2021
data_variants_shares_ch_dk_de_raw.csv
shares of SARS-CoV-2 variants (alpha, delta, omicron and other) among sequences on bi-weekly interval during 2021 (obtained from CoVariants)
data_variants_shares_ch_dk_de_processed.csv
shares of SARS-CoV-2 variants (alpha, delta, omicron and other) among sequences on bi-weekly interval during 2021 and auxiliary variables needed for plotting
data_parameters_ppc_model_one.csv
all parameter combinations for which identical sequence clusters were simulated during the posterior predictive checkindex_parameters_ppc_model_one.txt
auxiliary file needed during the posterior predictive check for the parallel execution of cluster simulation
parameters_grid_simulation.csv
all parameter combinations for which identical sequence clusters were simulated during the simulation studyindices_simulation.txt
andindices_estimation.txt
auxiliary files needed during the simulation study for the parallel execution of cluster simulation, respectively parameter estimationsimulated_clusters
number of simulated clusters of each size for each combination of parameters contained inparameters_grid_simulation.csv
simulated_clusters
simulated data based on parameters defined inparameters_grid_simulation.csv
stanfit files containing the results of the parameter estimation from data of Switzerland using models one and two
stanfit files containing the results of the parameter estimation from data of Denmark using models one and two
stanfit files containing the results of the parameter estimation from data of Germany using models one and two
results_model_one_ch_dk_de_2021_months.csv
summary of the results of the parameter estimation from data of Switzerland, Denmark and Germany using model oneresults_model_two_ch_dk_de_2021_months.csv
summary of the results of the parameter estimation from data of Switzerland, Denmark and Germany using model two
results_ppc_model_one_ch_dk_de.csv
summary of the results of the posterior predictive check of the results of the parameter estimation from data of Switzerland, Denmark and Germany using model one
stanfit files containing the results of the parameter estimation from simulated data (see data/simulated_clusters
)
results_sim_model_one_processed.csv
summary of the results of the parameter estimation from simulated data (see data/simulated_clusters
)
Graphical and tabular representations of data, model and results of simulation study, parameter estimation and posterior predictive check both for Switzerland, Denmark and Germany individually and for all three countries together.