From f6bf7baebb256bdd21cad6ff48a3e36bb69f104c Mon Sep 17 00:00:00 2001 From: John Huddleston Date: Mon, 31 Jul 2023 14:10:53 -0700 Subject: [PATCH] Use vl-convert to save altair figures for reports --- notebooks/plot-counts-per-lineage.py.ipynb | 21 +++++++-------------- workflow/envs/notebook.yaml | 6 +++--- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/notebooks/plot-counts-per-lineage.py.ipynb b/notebooks/plot-counts-per-lineage.py.ipynb index 44effd4d..904755d0 100644 --- a/notebooks/plot-counts-per-lineage.py.ipynb +++ b/notebooks/plot-counts-per-lineage.py.ipynb @@ -4,7 +4,6 @@ "cell_type": "markdown", "id": "0c5449d8-365a-4292-a772-6c1a79f5e43d", "metadata": {}, - "outputs": [], "source": [ "# Plot counts per lineage through time" ] @@ -13,7 +12,6 @@ "cell_type": "markdown", "id": "4e0df709-e102-488f-8829-fe71a8433ae6", "metadata": {}, - "outputs": [], "source": [ "## Imports" ] @@ -26,7 +24,6 @@ "outputs": [], "source": [ "import altair as alt\n", - "from altair_saver import save\n", "import pandas as pd" ] }, @@ -34,7 +31,6 @@ "cell_type": "markdown", "id": "06cbed4f-f94d-4d33-9b83-7354626d791f", "metadata": {}, - "outputs": [], "source": [ "## Configuration" ] @@ -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" ] @@ -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", @@ -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)" ] }, { @@ -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)" ] }, { @@ -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)" ] }, { @@ -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)" ] }, { diff --git a/workflow/envs/notebook.yaml b/workflow/envs/notebook.yaml index 2f5cc0fb..fb8ad8c2 100644 --- a/workflow/envs/notebook.yaml +++ b/workflow/envs/notebook.yaml @@ -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