Skip to content

Commit

Permalink
Use vl-convert to save altair figures for reports
Browse files Browse the repository at this point in the history
  • Loading branch information
huddlej committed Jul 31, 2023
1 parent f932c67 commit f6bf7ba
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
21 changes: 7 additions & 14 deletions notebooks/plot-counts-per-lineage.py.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"cell_type": "markdown",
"id": "0c5449d8-365a-4292-a772-6c1a79f5e43d",
"metadata": {},
"outputs": [],
"source": [
"# Plot counts per lineage through time"
]
Expand All @@ -13,7 +12,6 @@
"cell_type": "markdown",
"id": "4e0df709-e102-488f-8829-fe71a8433ae6",
"metadata": {},
"outputs": [],
"source": [
"## Imports"
]
Expand All @@ -26,15 +24,13 @@
"outputs": [],
"source": [
"import altair as alt\n",
"from altair_saver import save\n",
"import pandas as pd"
]
},
{
"cell_type": "markdown",
"id": "06cbed4f-f94d-4d33-9b83-7354626d791f",
"metadata": {},
"outputs": [],
"source": [
"## Configuration"
]
Expand All @@ -46,14 +42,13 @@
"metadata": {},
"outputs": [],
"source": [
"min_date = \"2021-08-01\""
"min_date = \"2022-01-01\""
]
},
{
"cell_type": "markdown",
"id": "43c90ae7-2cac-44d1-9f8f-da40a0db7f20",
"metadata": {},
"outputs": [],
"source": [
"## Load metadata"
]
Expand Down Expand Up @@ -217,9 +212,7 @@
"cell_type": "code",
"execution_count": null,
"id": "038b9332-fcf1-49ac-9342-4e9503fe8ec2",
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"all_lineages_chart = alt.Chart(binned_counts).mark_line(point=alt.OverlayMarkDef(size=100)).encode(\n",
Expand All @@ -243,11 +236,11 @@
{
"cell_type": "code",
"execution_count": null,
"id": "72a0bb83",
"id": "03d21429-ec5e-4bf6-b4fc-108d6f3a6e72",
"metadata": {},
"outputs": [],
"source": [
"save(all_lineages_chart, snakemake.output.total_sample_count_by_lineage)"
"all_lineages_chart.save(snakemake.output.total_sample_count_by_lineage, scale_factor=2.0)"
]
},
{
Expand Down Expand Up @@ -306,7 +299,7 @@
"metadata": {},
"outputs": [],
"source": [
"save(h1n1pdm_chart, snakemake.output.total_sample_count_h1n1pdm)"
"h1n1pdm_chart.save(snakemake.output.total_sample_count_h1n1pdm, scale_factor=2.0)"
]
},
{
Expand Down Expand Up @@ -365,7 +358,7 @@
"metadata": {},
"outputs": [],
"source": [
"save(h3n2_chart, snakemake.output.total_sample_count_h3n2)"
"h3n2_chart.save(snakemake.output.total_sample_count_h3n2, scale_factor=2.0)"
]
},
{
Expand Down Expand Up @@ -414,7 +407,7 @@
"metadata": {},
"outputs": [],
"source": [
"save(vic_chart, snakemake.output.total_sample_count_vic)"
"vic_chart.save(snakemake.output.total_sample_count_vic, scale_factor=2.0)"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions workflow/envs/notebook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ channels:
- conda-forge
- defaults
dependencies:
- altair=4.2.0
- altair_saver=0.5.0
- altair=5.0.1
- jupyter=1.0
- jupyterlab_code_formatter=1.4
- jupyterlab_code_formatter=2.2.1
- pandas=1.5.0
- python=3.9*
- vl-convert-python=0.11.1

0 comments on commit f6bf7ba

Please sign in to comment.