Skip to content

Commit

Permalink
Added steps 3 and 4
Browse files Browse the repository at this point in the history
  • Loading branch information
anitaapplegarth committed Jan 29, 2025
1 parent 8d781e4 commit de6c765
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 52 deletions.
62 changes: 31 additions & 31 deletions walk_through/EpigeoPop_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected]: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",
Expand All @@ -39,8 +39,8 @@
"<strong>Important:</strong> Make sure to copy your token immediately after creation - you won't be able to see it again!\n",
"</div>\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",
Expand All @@ -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",
Expand All @@ -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 [email protected]:SABS-R3-Epidemiology/EpiGeoPop.git\n",
"cd EpiGeoPop\n",
"```\n",
"\n",
"2. Create and activate a Python 3.11 environment:\n",
"\n",
" <div style=\"margin: 1em 0; padding: 1em; border-left: 4px solid #5bc0de; background-color: #f4f8fa;\">\n",
"<strong>Note:</strong> It will not run on Python 3.12.\n",
"</div>\n",
"**2. Create and activate a Python 3.11 environment:**\n",
"\n",
"```bash\n",
"/usr/local/opt/[email protected]/bin/python3.11 -m venv .venv\n",
"source .venv/bin/activate\n",
"```\n",
" \n",
"3. Install dependencies:\n",
"\n",
"<div style=\"margin: 1em 0; padding: 1em; border-left: 4px solid #5bc0de; background-color: #f4f8fa;\">\n",
"<strong>Note:</strong> It will not run on Python 3.12.\n",
"</div>\n",
"\n",
"**3. Install dependencies:**\n",
"\n",
"```bash\n",
"pip install -r requirements.txt\n",
"```\n",
"\n",
" <div style=\"margin: 1em 0; padding: 1em; border-left: 4px solid #5bc0de; background-color: #f4f8fa;\">\n",
"<strong>Note:</strong> If you encounter GDAL-related errors, install GDAL first:\n",
"<code>brew install gdal\n",
"<strong>Note:</strong> If you encounter GDAL-related errors, install GDAL first:<code>\n",
"brew install gdal\n",
"export GDAL_CONFIG=/usr/local/bin/gdal-config\n",
"export GDAL_VERSION=$(gdal-config --version)</code></div><br>\n",
"\n",
Expand All @@ -128,7 +128,7 @@
"source": [
"### Configuration steps\n",
"\n",
"1. Configure <your_country> parameters:\n",
"**1. Configure <your_country> parameters:**\n",
"\n",
"- Locate the parameter files in the `configs/countries` directory\n",
"- Edit or copy an existing parameter file\n",
Expand All @@ -147,13 +147,13 @@
"```\n",
"- Save file with <your_country> 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",
Expand All @@ -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",
"<div style=\"margin: 1em 0; padding: 1em; border-left: 4px solid #5bc0de; background-color: #f4f8fa;\">\n",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -250,7 +250,7 @@
"<strong>Tip:</strong> You can speed up the process by using multiple cores.\n",
"</div>\n",
"\n",
"3. Copy the generated files:\n",
"**3. Copy the generated files:**\n",
"\n",
"- Locate `<your_country_microcells>.csv` in `data/raw/processed/countries/`\n",
"- Copy it to your rEpiabm repository: `data/<your_country>/inputs/`\n",
Expand Down
57 changes: 36 additions & 21 deletions walk_through/toypop_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"</div>\n",
"\n",
"**3. Configure RStudio with your token:**\n",
"- in the console:\n",
"- In the console:\n",
"\n",
"```bash\n",
"file.edit(\"~/.Renviron\")\n",
Expand All @@ -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",
Expand All @@ -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",
"<div style=\"margin: 1em 0; padding: 1em; border-left: 4px solid #5bc0de; background-color: #f4f8fa;\">\n",
"<strong>Note:</strong> Simulation_duration unit is days and initial_infected unit is individuals.\n",
"</div>\n",
"\n",
"- Set population parameters:\n",
"\n",
"```bash\n",
Expand All @@ -113,10 +95,43 @@
"<div style=\"margin: 1em 0; padding: 1em; border-left: 4px solid #5bc0de; background-color: #f4f8fa;\">\n",
"<strong>Note:</strong> 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",
"</div>"
]
},
{
"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",
"<div style=\"margin: 1em 0; padding: 1em; border-left: 4px solid #5bc0de; background-color: #f4f8fa;\">\n",
"<strong>Note:</strong> Simulation_duration unit is days and initial_infected unit is individuals.\n",
"</div>\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": {
Expand Down

0 comments on commit de6c765

Please sign in to comment.