Skip to content

Commit

Permalink
nb WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
AngryMaciek committed Jul 22, 2024
1 parent d6a6546 commit 99c6efe
Showing 1 changed file with 237 additions and 3 deletions.
240 changes: 237 additions & 3 deletions notebook.ipynb
Original file line number Diff line number Diff line change
@@ -1,18 +1,252 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "1928a2a5",
"metadata": {
"tags": []
},
"source": [
"### _warlock_ vignette"
]
},
{
"cell_type": "markdown",
"id": "4450695b",
"metadata": {},
"source": [
"The following notebook demonstrates workflow execution with a simple set of simulation parameters."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "89b9ced8",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"from IPython.display import Image"
]
},
{
"cell_type": "markdown",
"id": "0a4b57d1",
"metadata": {},
"source": [
"## Prepare files for the workflow"
]
},
{
"cell_type": "markdown",
"id": "9f7ed01b",
"metadata": {},
"source": [
"In the example below we will prepare a configuration file varying one specific parameter: deme carrying capacity.\n",
"\n",
"All dependencies have been already installed while building a container for this notebook."
]
},
{
"cell_type": "markdown",
"id": "63403efe",
"metadata": {},
"source": [
"Compile _demon_"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "90a4c46c",
"metadata": {},
"outputs": [],
"source": []
"source": [
"%%bash\n",
"\n",
"g++ resources/demon_model/src/demon.cpp -o resources/demon_model/bin/demon -I/srv/conda/envs/notebook/include/ -lm"
]
},
{
"cell_type": "markdown",
"id": "cb706573",
"metadata": {},
"source": [
"Prepare configfile for the workflow (based on a template)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3aa3277f",
"metadata": {},
"outputs": [],
"source": [
"with open(\"tests/binder/config-template.yml\") as f:\n",
" configlines = f.read().splitlines()\n",
"\n",
"configlines[17] = \"workflow_repo_path: \\\"\" + os.getcwd() + \"\\\"\"\n",
"\n",
"outdir = os.path.join(\n",
" os.getcwd(),\n",
" \"tests\",\n",
" \"binder\",\n",
" \"output\"\n",
")\n",
"\n",
"configlines[22] = \"workflow_analysis_outdir: \\\"\" + outdir + \"\\\"\"\n",
"\n",
"with open(\"tests/binder/config.yml\", \"w\") as f:\n",
" for line in configlines:\n",
" f.write(line + os.linesep)"
]
},
{
"cell_type": "markdown",
"id": "5298889a",
"metadata": {},
"source": [
"## Execute the workflow"
]
},
{
"cell_type": "markdown",
"id": "59834894",
"metadata": {},
"source": [
"We trigger the snakemake workflow via our main bash script (~5min runtime)."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6f9a1e6a",
"metadata": {},
"outputs": [],
"source": [
"%%bash\n",
"\n",
"time \\\n",
"bash warlock.sh \\\n",
"--configfile tests/binder/config.yml \\\n",
"--environment local \\\n",
"--cores 3"
]
},
{
"cell_type": "markdown",
"id": "b6b91cc3",
"metadata": {},
"source": [
"## Example post-processing"
]
},
{
"cell_type": "markdown",
"id": "90a8045e",
"metadata": {},
"source": [
"In order to quickly glance over simulations' results we shall utilize a [previously developed package](https://github.com/robjohnnoble/demonanalysis) (which is outside the scope if this repository)."
]
},
{
"cell_type": "markdown",
"id": "7317904e",
"metadata": {},
"source": [
"### Inspect the summary plots:"
]
},
{
"cell_type": "markdown",
"id": "01c72cb9",
"metadata": {},
"source": [
"$\\log_2$[deme carrying capacity] = 8"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2b0f8217",
"metadata": {},
"outputs": [],
"source": [
"Image(filename=\"tests/binder/output/simulations/00000000/summary.png\") "
]
},
{
"cell_type": "markdown",
"id": "518dde2c",
"metadata": {},
"source": [
"$\\log_2$[deme carrying capacity] = 9"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0e4a74b6",
"metadata": {},
"outputs": [],
"source": [
"Image(filename=\"tests/binder/output/simulations/00000001/summary.png\") "
]
},
{
"cell_type": "markdown",
"id": "123529a1",
"metadata": {},
"source": [
"$\\log_2$[deme carrying capacity] = 10"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "018e1056",
"metadata": {},
"outputs": [],
"source": [
"Image(filename=\"tests/binder/output/simulations/00000002/summary.png\") "
]
},
{
"cell_type": "markdown",
"id": "dfdd7551",
"metadata": {},
"source": [
"**The simple example above highlights that the higher the deme carrying capacity is the sooner the tumor evolves within the population.**"
]
},
{
"cell_type": "markdown",
"id": "782ed072",
"metadata": {},
"source": [
"---"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python"
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.0"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 5
}

0 comments on commit 99c6efe

Please sign in to comment.