From de6c76510a82df31b93b4b3930531c436b2e88c1 Mon Sep 17 00:00:00 2001 From: Anita Applegarth Date: Wed, 29 Jan 2025 14:09:13 +0000 Subject: [PATCH] Added steps 3 and 4 --- walk_through/EpigeoPop_example.ipynb | 62 ++++++++++++++-------------- walk_through/toypop_example.ipynb | 57 +++++++++++++++---------- 2 files changed, 67 insertions(+), 52 deletions(-) diff --git a/walk_through/EpigeoPop_example.ipynb b/walk_through/EpigeoPop_example.ipynb index d0544d9..da2fa2e 100644 --- a/walk_through/EpigeoPop_example.ipynb +++ b/walk_through/EpigeoPop_example.ipynb @@ -22,14 +22,14 @@ "\n", "### Installation Steps\n", "\n", - "1. Clone the Github rEpiabm repository:\n", + "**1. Clone the Github rEpiabm repository:**\n", "\n", "```bash\n", "git clone git@github.com:SABS-R3-Epidemiology/rEpiabm.git\n", "cd rEpiabm\n", "```\n", "\n", - "2. Create a GitHub Personal Access Token:\n", + "**2. Create a GitHub Personal Access Token:**\n", "\n", "- Navigate to GitHub Settings → Developer Settings\n", "- Select \"Personal access tokens (fine-grained)\"\n", @@ -39,8 +39,8 @@ "Important: Make sure to copy your token immediately after creation - you won't be able to see it again!\n", "\n", "\n", - "3. Configure RStudio with your token:\n", - "- in the console:\n", + "**3. Configure RStudio with your token:**\n", + "- In the console:\n", "\n", "```bash\n", "file.edit(\"~/.Renviron\")\n", @@ -58,15 +58,15 @@ "\n", "- Save file and restart RStudio\n", "\n", - "4. Install required R packages:\n", - " In the console:\n", + "**4. Install required R packages:**\n", + "- In the console:\n", " \n", "```bash\n", "install.packages(\"devtools\")\n", "devtools::install_github(\"SABS-R3-Epidemiology/rEpiabm\")\n", "```\n", "\n", - "5. Set up your country's data structure\n", + "**5. Set up your country's data structure**\n", "- Navigate to the `data` folder\n", "- Copy the `Andorra` folder structure\n", "- Rename the copy with your country's name (capitalize the initial letter)\n", @@ -89,33 +89,33 @@ "\n", "### Environment Setup\n", "\n", - "1. Clone the [EpiGeoPop](https://github.com/SABS-R3-Epidemiology/EpiGeoPop) repository:\n", + "**1. Clone the [EpiGeoPop](https://github.com/SABS-R3-Epidemiology/EpiGeoPop) repository:**\n", "\n", "```bash\n", "git clone git@github.com:SABS-R3-Epidemiology/EpiGeoPop.git\n", "cd EpiGeoPop\n", "```\n", "\n", - "2. Create and activate a Python 3.11 environment:\n", - "\n", - "
\n", - "Note: It will not run on Python 3.12.\n", - "
\n", + "**2. Create and activate a Python 3.11 environment:**\n", "\n", "```bash\n", "/usr/local/opt/python@3.11/bin/python3.11 -m venv .venv\n", "source .venv/bin/activate\n", "```\n", - " \n", - "3. Install dependencies:\n", + "\n", + "
\n", + "Note: It will not run on Python 3.12.\n", + "
\n", + "\n", + "**3. Install dependencies:**\n", "\n", "```bash\n", "pip install -r requirements.txt\n", "```\n", "\n", "
\n", - "Note: If you encounter GDAL-related errors, install GDAL first:\n", - "brew install gdal\n", + "Note: If you encounter GDAL-related errors, install GDAL first:\n", + "brew install gdal\n", "export GDAL_CONFIG=/usr/local/bin/gdal-config\n", "export GDAL_VERSION=$(gdal-config --version)

\n", "\n", @@ -128,7 +128,7 @@ "source": [ "### Configuration steps\n", "\n", - "1. Configure parameters:\n", + "**1. Configure parameters:**\n", "\n", "- Locate the parameter files in the `configs/countries` directory\n", "- Edit or copy an existing parameter file\n", @@ -147,13 +147,13 @@ "```\n", "- Save file with at start of filename\n", "\n", - "2. Update the data preparation script:\n", + "**2. Update the data preparation script:**\n", "- Open `prep.sh`\n", "- Replace the population data URL:\n", "\n", "```bash\n", "# Comment out old URL\n", - "# curl -O https://jeodpp.jrc.ec.europa.eu/ftp/jrc-opendata/GHSL/GHS_POP_MT_GLOBE_R2019A/GHS_POP_E2015_GLOBE_R2019A_4326_30ss/V1-0/GHS_POP_E2015_GLOBE_R2019A_4326_30ss_V1_0.zip\n", + "curl -O https://jeodpp.jrc.ec.europa.eu/ftp/jrc-opendata/GHSL/GHS_POP_MT_GLOBE_R2019A/GHS_POP_E2015_GLOBE_R2019A_4326_30ss/V1-0/GHS_POP_E2015_GLOBE_R2019A_4326_30ss_V1_0.zip\n", "\n", "# Add new URL\n", "curl -O https://jeodpp.jrc.ec.europa.eu/ftp/jrc-opendata/GHSL/GHS_POP_GLOBE_R2023A/GHS_POP_E2025_GLOBE_R2023A_4326_30ss/V1-0/GHS_POP_E2025_GLOBE_R2023A_4326_30ss_V1_0.zip\n", @@ -170,13 +170,13 @@ "Comment out the remaining lines of code.\n", "\n", "```bash\n", - "# curl -LO \"https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_admin_0_countries_lakes.zip\"\n", - "# curl -LO \"https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_admin_1_states_provinces.zip\"\n", - "# curl -LO \"https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_urban_areas_landscan.zip\"\n", - "# echo \"Downloading population age file...\"\n", - "# # This server uses an outdated SSL protocol so we need to enable legacy renegotiation\n", - "# OPENSSL_CONF=../../openssl.cnf curl -O \"https://population.un.org/wpp/Download/Files/1_Indicators%20(Standard)/CSV_FILES/WPP2022_PopulationByAge5GroupSex_Medium.zip\"\n", - "# unzip WPP2022_PopulationByAge5GroupSex_Medium.zip\n", + "curl -LO \"https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_admin_0_countries_lakes.zip\"\n", + "curl -LO \"https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_admin_1_states_provinces.zip\"\n", + "curl -LO \"https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_urban_areas_landscan.zip\"\n", + "echo \"Downloading population age file...\"\n", + "# This server uses an outdated SSL protocol so we need to enable legacy renegotiation\n", + "OPENSSL_CONF=../../openssl.cnf curl -O \"https://population.un.org/wpp/Download/Files/1_Indicators%20(Standard)/CSV_FILES/WPP2022_PopulationByAge5GroupSex_Medium.zip\"\n", + "unzip WPP2022_PopulationByAge5GroupSex_Medium.zip\n", "```\n", "\n", "
\n", @@ -189,7 +189,7 @@ "bash prep.sh\n", "```\n", "\n", - "3. Download additional required data manually:\n", + "**3. Download additional required data manually:**\n", "\n", "- Visit [Natural Earth](https://www.naturalearthdata.com/downloads/10m-cultural-vectors/)\n", "- Under Admin 0 - Countries, click on link `Download without boundary lakes`\n", @@ -205,7 +205,7 @@ "source": [ "### Generate Population Data\n", "\n", - "1. Update the Snakefile configuration:\n", + "**1. Update the Snakefile configuration:**\n", "\n", "```bash\n", "# Replace country name\n", @@ -240,7 +240,7 @@ " \"scripts/get_pop_dist.py\"\n", "```\n", "\n", - "2. Generate the population data:\n", + "**2. Generate the population data:**\n", "\n", "```bash\n", "snakemake --cores 1\n", @@ -250,7 +250,7 @@ "Tip: You can speed up the process by using multiple cores.\n", "
\n", "\n", - "3. Copy the generated files:\n", + "**3. Copy the generated files:**\n", "\n", "- Locate `.csv` in `data/raw/processed/countries/`\n", "- Copy it to your rEpiabm repository: `data//inputs/`\n", diff --git a/walk_through/toypop_example.ipynb b/walk_through/toypop_example.ipynb index 6154b03..5f19b3f 100644 --- a/walk_through/toypop_example.ipynb +++ b/walk_through/toypop_example.ipynb @@ -40,7 +40,7 @@ "\n", "\n", "**3. Configure RStudio with your token:**\n", - "- in the console:\n", + "- In the console:\n", "\n", "```bash\n", "file.edit(\"~/.Renviron\")\n", @@ -59,7 +59,7 @@ "- Save file and restart RStudio\n", "\n", "**4. Install required R packages:**\n", - " In the console:\n", + "- In the console:\n", " \n", "```bash\n", "install.packages(\"devtools\")\n", @@ -74,29 +74,11 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Step 2. Configuration of toy population\n", + "## Step 2. Configure the toy population\n", "\n", "It is common to set these parameters with low values in order to run and compare many simulations.\n", "\n", "- Open `R/simulation_toy.R`\n", - "- Set simulation parameters:\n", - "\n", - "```bash\n", - "# Amend simulation_duration and initial_infected to your values\n", - "run_complete_simulation <- function(output_dir=\"data/simulation_outputs\",\n", - " output_file = \"output.csv\",\n", - " sir_plot_file = \"SIR_plot.png\",\n", - " rt_plot_file = \"Rt_plot.png\",\n", - " si_plot_file = \"SerialInterval_plot.png\",\n", - " use_toy_example = TRUE,\n", - " simulation_duration = 60,\n", - " initial_infected = 10) {\n", - "```\n", - "\n", - "
\n", - "Note: Simulation_duration unit is days and initial_infected unit is individuals.\n", - "
\n", - "\n", "- Set population parameters:\n", "\n", "```bash\n", @@ -113,10 +95,43 @@ "
\n", "Note: This example sets 100 individuals to be distributed across 2 cells.\n", "Each cell contains 2 microcells, which each contain 5 households and 2 places.\n", + "
" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Step 3. Configure the simulation\n", + "\n", + "These are set within the same `simulation_toy.R` file\n", + "- Set simulation parameters:\n", + "\n", + "```bash\n", + "# Amend simulation_duration and initial_infected to your values\n", + "run_complete_simulation <- function(output_dir=\"data/simulation_outputs\",\n", + " output_file = \"output.csv\",\n", + " sir_plot_file = \"SIR_plot.png\",\n", + " rt_plot_file = \"Rt_plot.png\",\n", + " si_plot_file = \"SerialInterval_plot.png\",\n", + " use_toy_example = TRUE,\n", + " simulation_duration = 60,\n", + " initial_infected = 10) {\n", + "```\n", + "\n", + "
\n", + "Note: Simulation_duration unit is days and initial_infected unit is individuals.\n", "
\n", "\n", "You're now ready to run simulations with your toy population data." ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Step 4. Run the simulation" + ] } ], "metadata": {