Skip to content

Commit

Permalink
More progress on appendix and figures
Browse files Browse the repository at this point in the history
  • Loading branch information
romain-ragonnet committed Nov 30, 2023
1 parent 40da43b commit c32b2a8
Show file tree
Hide file tree
Showing 8 changed files with 361 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ def _plot_diff_outputs(axis, diff_quantiles_df, output_names):



def make_country_highlight_figure(iso3, uncertainty_dfs, diff_quantiles_df, derived_outputs):
def make_country_highlight_figure(iso3, uncertainty_dfs, diff_quantiles_df, derived_outputs, include_country_name=False):

plt.rcParams.update(
{
Expand Down Expand Up @@ -374,10 +374,28 @@ def make_country_highlight_figure(iso3, uncertainty_dfs, diff_quantiles_df, deri

country_name = INCLUDED_COUNTRIES['all'][iso3]
fig = plt.figure(figsize=(10.5, 5), dpi=300) # crete an A4 figure
outer = gridspec.GridSpec(
1, 3, wspace=.25, width_ratios=(41, 41, 18),
n_outer_rows = 2 if include_country_name else 1

super_outer = gridspec.GridSpec(
n_outer_rows, 1, height_ratios=(3, 97),
left=0.125, right=0.97, bottom=0.06, top =.97 # this affects the outer margins of the saved figure
)
#### Top row with country name
if include_country_name:
ax1 = fig.add_subplot(super_outer[0, 0])
t = ax1.text(0.5,0.5, country_name, fontsize=16)
t.set_ha('center')
t.set_va('center')
ax1.set_xticks([])
ax1.set_yticks([])
ax1.spines['top'].set_visible(False)
ax1.spines['right'].set_visible(False)
ax1.spines['bottom'].set_visible(False)
ax1.spines['left'].set_visible(False)

outer = gridspec.GridSpecFromSubplotSpec(
1, 3, subplot_spec=super_outer[n_outer_rows - 1, 0], wspace=.25, width_ratios=(41, 41, 18)
)

# LEFT column
outer_cell = outer[0, 0]
Expand Down
Binary file not shown.
Binary file not shown.
140 changes: 136 additions & 4 deletions docs/tex/tex_descriptions/projects/sm_covid/results.tex
Original file line number Diff line number Diff line change
@@ -1,14 +1,146 @@
\section{Sensitivity analyses}
\subsection{SA1: }
\subsection{SA2: }

\subsection{SA1: Increased household transmission during school closures}
In this sensitivity analysis, we assumed that effective contact rates within households were increased during school closure periods.
Specifically, we assumed that each individual had 20\% more household contact potential when schools were fully closed.\\
The results of this sensitivity analysis are presented in Figure \ref{fig:SA1_rel_outputs} and Figure \ref{fig:SA1_maps}.

\begin{figure}[!ht]
\begin{center}
\includegraphics[width=1.0\textwidth]{../../../../user/rragonnet/remote_run_outputs/31902886_full_analysis_05Oct2023_increased_hh_contacts/COMMON_DIRECTORY/relative_outputs.pdf}
\end{center}
\caption{Relative impact of school closures on COVID-19 infections, deaths and peak hospital occupancy (SA1: increased household transmission during closures)}
Results are presented as relative percentage reductions in COVID-19 infections (A),
COVID-19 deaths (B), and peak hospital occupancy (C). The counterfactual ``schools open'' scenario was used as reference.
Estimates are presented as medians (horizontal lines), interquartile ranges (boxes), and 95\% central credible intervals (vertical lines).
Countries are listed in descending order from left to right, based on the estimated median effect for each disease indicator. See Table 1 to find the country associated with each ISO3 code.
\label{fig:SA1_rel_outputs}
\end{figure}

\begin{figure}[!ht]
\begin{center}
\includegraphics[width=1.0\textwidth]{../../../../user/rragonnet/remote_run_outputs/31902886_full_analysis_05Oct2023_increased_hh_contacts/COMMON_DIRECTORY/maps/combined_single_page.pdf}
\end{center}
\caption{Geographic representation of the effects of school closures on COVID-19 (SA1: increased household transmission during closures)}
Results presented as median relative percentage reductions in SARS-CoV-2 infections (A), COVID-19 deaths (B), and peak hospital occupancy (C), due to school closures. The counterfactual “schools open” scenario was used as reference. Countries in light grey were not included in the analysis. Negative percentages indicate configurations where school closures are estimated to have had a negative impact on the considered indicator.
\label{fig:SA1_maps}
\end{figure}



\subsection{SA2: Google Mobility data not included}

In this sensitivity analysis, we removed the contribution of Google Mobility data from our model.
Under this configuration, we exclusively rely on the non-mechanistic component (i.e., random process) to capture
mobility changes in locations other than households and schools.
\\

The results of this sensitivity analysis are presented in Figure \ref{fig:SA2_rel_outputs} and Figure \ref{fig:SA2_maps}.

\begin{figure}[!ht]
\begin{center}
\includegraphics[width=1.0\textwidth]{../../../../user/rragonnet/remote_run_outputs/31915437_full_analysis_05Oct2023_no_google_mobility/COMMON_DIRECTORY/relative_outputs.pdf}
\end{center}
\caption{Relative impact of school closures on COVID-19 infections, deaths and peak hospital occupancy (SA2: no Google Mobility data)}
Results are presented as relative percentage reductions in COVID-19 infections (A),
COVID-19 deaths (B), and peak hospital occupancy (C). The counterfactual ``schools open'' scenario was used as reference.
Estimates are presented as medians (horizontal lines), interquartile ranges (boxes), and 95\% central credible intervals (vertical lines).
Countries are listed in descending order from left to right, based on the estimated median effect for each disease indicator. See Table 1 to find the country associated with each ISO3 code.
\label{fig:SA2_rel_outputs}
\end{figure}

\begin{figure}[!ht]
\begin{center}
\includegraphics[width=1.0\textwidth]{../../../../user/rragonnet/remote_run_outputs/31915437_full_analysis_05Oct2023_no_google_mobility/COMMON_DIRECTORY/maps/combined_single_page.pdf}
\end{center}
\caption{Geographic representation of the effects of school closures on COVID-19 (SA2: no Google Mobility data)}
Results presented as median relative percentage reductions in SARS-CoV-2 infections (A), COVID-19 deaths (B), and peak hospital occupancy (C), due to school closures. The counterfactual “schools open” scenario was used as reference. Countries in light grey were not included in the analysis. Negative percentages indicate configurations where school closures are estimated to have had a negative impact on the considered indicator.
\label{fig:SA2_maps}
\end{figure}




\subsection{Output comparisons between analyses}
In this section, we present side-by-side comparisons of the main outputs between the three analyses (Base-case, SA1 and SA2).
We present comparisons for the effect of school closures on infections (Figure \ref{fig:compare_infections}), deaths (Figure \ref{fig:compare_deaths}) and peak hospital occupancy (Figure \ref{fig:compare_hosp}).\\
Finally, Figure \ref{fig:compare_median} provides overall comparisons across all countries analysed, considering the estimated median effects alone.

\begin{figure}[!ht]
\begin{center}
\includegraphics[width=1.0\textwidth]{../../../../user/rragonnet/remote_run_outputs/analyses_compare_plots/analyses_compare_cases_averted_relative.pdf}
\end{center}
\caption{Comparison of school closure effects on SARS-CoV-2 infections}
\label{fig:compare_infections}
\end{figure}


\begin{figure}[!ht]
\begin{center}
\includegraphics[width=1.0\textwidth]{../../../../user/rragonnet/remote_run_outputs/analyses_compare_plots/analyses_compare_deaths_averted_relative.pdf}
\end{center}
\caption{Comparison of school closure effects on COVID-19 deaths}
\label{fig:compare_deaths}
\end{figure}


\begin{figure}[!ht]
\begin{center}
\includegraphics[width=1.0\textwidth]{../../../../user/rragonnet/remote_run_outputs/analyses_compare_plots/analyses_compare_delta_hospital_peak_relative.pdf}
\end{center}
\caption{Comparison of school closure effects on peak hospital occupancy}
\label{fig:compare_hosp}
\end{figure}


\begin{figure}[!ht]
\begin{center}
\includegraphics[width=0.7\textwidth]{../../../../user/rragonnet/remote_run_outputs/analyses_compare_plots/analyses_median_deltas.pdf}
\end{center}
\caption{Relative difference between median estimated effects of school closures between the different analyses}
\label{fig:compare_median}
\end{figure}






\subsection{Likelihood comparisons between analyses}

In this section, we aimed to compare the ability of the different models to fit the data. For this, we present the values of the a-posteriori log-likelihood
function (see Section \ref{calibration} for definition and Equation \ref{eq:acc_qtt}) obtained under the different configurations in Figure \ref{fig:compare_likelihood}.\\

\section{Detailed country-specific results}
To better understand the differences observed in the a-posteriori log-likelihood values, we also presented the likelihood component that is
relevant to the time-variant random-process in Figure \ref{fig:compare_rp_likelihood} (see Section \ref{eq:random_process} for definition).

\begin{figure}[!ht]
\begin{center}
\includegraphics[width=1.0\textwidth]{../../../../user/rragonnet/remote_run_outputs/analyses_compare_plots/ll_compare_logposterior.pdf}
\end{center}
\caption{Comparison of a-posteriori log-likelihood values between analyses}
The a-posteriori log-likelihood combines the model likelihood, the parameter priors and the random process likelihood. Higher values indicate
more realistic model fits. Note that the quantity presented in Equation \ref{eq:acc_qtt} is not exactly the a-posteriori likelihood but a quantity that
is proportional to the latter. This is why the log-likelihood quantity presented here includes an offset.
\label{fig:compare_likelihood}
\end{figure}


\begin{figure}[!ht]
\begin{center}
\includegraphics[width=1.0\textwidth]{../../../../user/rragonnet/remote_run_outputs/analyses_compare_plots/ll_compare_ll_extra_ll.pdf}
\end{center}
\caption{Comparison of likelihood-components relevant to the time-variant random process}
Higher values indicate less overall variability in the random-process.
\label{fig:compare_rp_likelihood}
\end{figure}




\clearpage
\newpage
\section{Detailed country-specific results}
The next pages include detailed country-specific results for the 74 countries included in
our analysis, under the base-case configuration. Detailed country-specific results associated
with the two sensitivity analyses (SA1 and SA2) are available online at \textcolor{red}{ADD LINK TO COUNTRY-SPECIFIC PROFILES SA1-2}.
Expand All @@ -25,4 +157,4 @@ \section{Detailed country-specific results}
\textcolor{blue}{\hyperlink{profiles.\x}{\pgfmathparse{\countrynames[\x]}\pgfmathresult} } \tab
}

\includepdf[pages=-,nup=2x2,frame=true,link=true,linkname=profiles]{../../../../user/rragonnet/remote_run_outputs/31747883_full_analysis_26Sep2023_main/COMMON_DIRECTORY/multi_tiling.pdf}
\includepdf[pages=-,nup=1x2,frame=true,link=true,linkname=profiles, delta=20mm 20mm]{../../../../user/rragonnet/remote_run_outputs/31747883_full_analysis_26Sep2023_main/COMMON_DIRECTORY/multi_highlights.pdf}
Binary file modified docs/tex/user/rragonnet/sm_covid.pdf
Binary file not shown.
168 changes: 117 additions & 51 deletions user/rragonnet/remote_run_outputs/country_highlights.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,75 +2,141 @@
"cells": [
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING (pytensor.tensor.blas): Using NumPy C-API based implementation for BLAS functions.\n",
"c:\\Users\\rrag0004\\.conda\\envs\\summer2\\lib\\site-packages\\summer\\runner\\vectorized_runner.py:363: NumbaDeprecationWarning: \u001b[1mThe 'nopython' keyword argument was not supplied to the 'numba.jit' decorator. The implicit default value for this argument is currently False, but it will be changed to True in Numba 0.59.0. See https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit for details.\u001b[0m\n",
" def get_strain_infection_values(\n"
]
}
],
"source": [
"import pandas as pd\n",
"from pathlib import Path\n",
"from importlib import reload\n",
"from autumn.projects.sm_covid2.common_school.output_plots import country_highlight as ch"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"analysis_folder = Path.cwd() / \"31747883_full_analysis_26Sep2023_main\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import yaml\n",
"from autumn.projects.sm_covid2.common_school.calibration import get_bcm_object\n",
"from estival.sampling import tools as esamp\n",
"from matplotlib import pyplot as plt \n",
"\n",
"def get_mle_derived_outputs(iso3): \n",
" best_params_path = analysis_folder / iso3 / \"retained_best_params.yml\"\n",
" with open(best_params_path, \"r\") as f:\n",
" best_params = yaml.unsafe_load(f)\n",
" mle_params = best_params[0]\n",
" \n",
" derived_outputs = {}\n",
" for sc in [\"baseline\", \"scenario_1\"]:\n",
" bcm = get_bcm_object(iso3, scenario=sc)\n",
" res = esamp.model_results_for_samples([mle_params], bcm)\n",
" derived_outputs[sc] = res.results.xs(0, level=\"sample\", axis=1)\n",
"\n",
" return derived_outputs"
"from autumn.projects.sm_covid2.common_school.output_plots import country_highlight as ch\n",
"from autumn.projects.sm_covid2.common_school.runner_tools import INCLUDED_COUNTRIES\n",
"full_iso3_list = list(INCLUDED_COUNTRIES['all'].keys())"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"for iso3 in [\"MAR\", \"IDN\", \"GBR\"]:\n",
"# for iso3 in [\"GBR\"]:\n",
"\n",
" uncertainty_dfs = {sc: pd.read_parquet(analysis_folder / iso3 / f\"uncertainty_df_{sc}.parquet\") for sc in [\"baseline\", \"scenario_1\"]}\n",
" diff_quantiles_df = pd.read_parquet(analysis_folder / iso3 / f\"diff_quantiles_df.parquet\")\n",
" derived_outputs = get_mle_derived_outputs(iso3)\n",
" fig = ch.make_country_highlight_figure(iso3, uncertainty_dfs, diff_quantiles_df, derived_outputs)\n",
" for file_format in [\"png\", \"pdf\"]:\n",
" fig.savefig(f\"highlights_{iso3}.{file_format}\", bbox_inches='tight')"
"analysis_folders = {\n",
" \"main\": Path.cwd() / \"31747883_full_analysis_26Sep2023_main\",\n",
" \"increased_hh_contacts\": Path.cwd() /\"31902886_full_analysis_05Oct2023_increased_hh_contacts\",\n",
" \"no_google_mobility\": Path.cwd() /\"31915437_full_analysis_05Oct2023_no_google_mobility\"\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"increased_hh_contacts: ARG\n",
"increased_hh_contacts: AUS\n",
"increased_hh_contacts: AUT\n",
"increased_hh_contacts: BEL\n",
"increased_hh_contacts: BGD\n",
"increased_hh_contacts: BGR\n",
"increased_hh_contacts: BIH\n",
"increased_hh_contacts: BOL\n",
"increased_hh_contacts: BRA\n",
"increased_hh_contacts: CAN\n",
"increased_hh_contacts: CHL\n",
"increased_hh_contacts: COL\n",
"increased_hh_contacts: CRI\n",
"increased_hh_contacts: CZE\n",
"increased_hh_contacts: DEU\n",
"increased_hh_contacts: DNK\n",
"increased_hh_contacts: ECU\n",
"increased_hh_contacts: EGY\n",
"increased_hh_contacts: ESP\n",
"increased_hh_contacts: FIN\n",
"increased_hh_contacts: FRA\n",
"increased_hh_contacts: GBR\n",
"increased_hh_contacts: GEO\n",
"increased_hh_contacts: GRC\n",
"increased_hh_contacts: GTM\n",
"increased_hh_contacts: HND\n",
"increased_hh_contacts: HRV\n",
"increased_hh_contacts: HUN\n",
"increased_hh_contacts: IDN\n",
"increased_hh_contacts: IND\n",
"increased_hh_contacts: IRL\n",
"increased_hh_contacts: IRQ\n",
"increased_hh_contacts: ISR\n",
"increased_hh_contacts: ITA\n",
"increased_hh_contacts: JOR\n",
"increased_hh_contacts: JPN\n",
"increased_hh_contacts: KAZ\n",
"increased_hh_contacts: KEN\n",
"increased_hh_contacts: KOR\n",
"increased_hh_contacts: LBN\n",
"increased_hh_contacts: LKA\n",
"increased_hh_contacts: LTU\n",
"increased_hh_contacts: LVA\n",
"increased_hh_contacts: MAR\n",
"increased_hh_contacts: MDA\n",
"increased_hh_contacts: MEX\n",
"increased_hh_contacts: MKD\n",
"increased_hh_contacts: MMR\n",
"increased_hh_contacts: MYS\n",
"increased_hh_contacts: NLD\n",
"increased_hh_contacts: NPL\n",
"increased_hh_contacts: PAK\n",
"increased_hh_contacts: PAN\n",
"increased_hh_contacts: PER\n",
"increased_hh_contacts: PHL\n",
"increased_hh_contacts: POL\n",
"increased_hh_contacts: PRT\n",
"increased_hh_contacts: PRY\n",
"increased_hh_contacts: ROU\n",
"increased_hh_contacts: RUS\n",
"increased_hh_contacts: SAU\n",
"increased_hh_contacts: SRB\n",
"increased_hh_contacts: SVK\n",
"increased_hh_contacts: SVN\n",
"increased_hh_contacts: SWE\n",
"increased_hh_contacts: THA\n",
"increased_hh_contacts: TUR\n",
"increased_hh_contacts: UKR\n",
"increased_hh_contacts: URY\n",
"increased_hh_contacts: USA\n",
"increased_hh_contacts: VEN\n",
"increased_hh_contacts: VNM\n",
"increased_hh_contacts: ZAF\n",
"increased_hh_contacts: ZWE\n"
]
}
],
"source": [
"reload(ch)\n",
"# fig = ch.make_country_highlight_figure(\"GBR\", uncertainty_dfs, diff_quantiles_df, derived_outputs)"
"for analysis in [\"increased_hh_contacts\"]: #analysis_folders:\n",
" for iso3 in full_iso3_list:\n",
" print(f\"{analysis}: {iso3}\")\n",
" folder_path = analysis_folders[analysis] / iso3\n",
" uncertainty_dfs = {sc: pd.read_parquet(folder_path/ f\"uncertainty_df_{sc}.parquet\") for sc in [\"baseline\", \"scenario_1\"]}\n",
" diff_quantiles_df = pd.read_parquet(folder_path / f\"diff_quantiles_df.parquet\")\n",
" derived_outputs = pd.read_pickle(folder_path / \"derived_outputs.pickle\") \n",
" fig = ch.make_country_highlight_figure(iso3, uncertainty_dfs, diff_quantiles_df, derived_outputs, include_country_name=True)\n",
" for file_format in [\"png\", \"pdf\"]:\n",
" fig.savefig(folder_path / f\"highlights_{iso3}.{file_format}\", bbox_inches='tight')\n",
"\n",
" plt.close()\n"
]
},
{
Expand Down
Loading

0 comments on commit c32b2a8

Please sign in to comment.