From 03a5576934f8ad4fb8feb612783d16a6949b3563 Mon Sep 17 00:00:00 2001 From: jbloom Date: Mon, 29 Jan 2024 16:42:12 -0800 Subject: [PATCH 1/3] add `mean_abs` and `sum_abs` to `lineplot_and_heatmap` Allows display of site statistics reflecting the mean and sum of the absolute values of the mutation values. --- CHANGELOG.rst | 4 + notebooks/real_LyCoV1404.ipynb | 220 ++++++++++++++++++++++++--------- notebooks/visualize_RBD.ipynb | 196 ++++++++++++++--------------- polyclonal/__init__.py | 2 +- polyclonal/plot.py | 13 +- 5 files changed, 272 insertions(+), 163 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index c547f50..93601ec 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,10 @@ All notable changes to this project will be documented in this file. The format is based on `Keep a Changelog `_. +6.11 +---- +- In ``lineplot_and_heatmap``, add ``mean_abs`` and ``sum_abs`` as possible site statistics, reflecting the mean and sum of the absolute values of the mutation values. + 6.10 ---- - In ``lineplot_and_heatmap``, mutations that are hidden are by one slider filtered even if they fail other sliders. Addresses `this issue `_ diff --git a/notebooks/real_LyCoV1404.ipynb b/notebooks/real_LyCoV1404.ipynb index 6c7461c..85c7767 100644 --- a/notebooks/real_LyCoV1404.ipynb +++ b/notebooks/real_LyCoV1404.ipynb @@ -17,6 +17,13 @@ "execution_count": 1, "id": "0b46edd2", "metadata": { + "execution": { + "iopub.execute_input": "2024-01-30T00:31:05.986024Z", + "iopub.status.busy": "2024-01-30T00:31:05.985362Z", + "iopub.status.idle": "2024-01-30T00:31:09.251302Z", + "shell.execute_reply": "2024-01-30T00:31:09.250503Z", + "shell.execute_reply.started": "2024-01-30T00:31:05.985984Z" + }, "tags": [] }, "outputs": [], @@ -45,6 +52,13 @@ "execution_count": 2, "id": "46127941", "metadata": { + "execution": { + "iopub.execute_input": "2024-01-30T00:31:09.252784Z", + "iopub.status.busy": "2024-01-30T00:31:09.252414Z", + "iopub.status.idle": "2024-01-30T00:31:10.120975Z", + "shell.execute_reply": "2024-01-30T00:31:10.120248Z", + "shell.execute_reply.started": "2024-01-30T00:31:09.252760Z" + }, "tags": [] }, "outputs": [ @@ -212,6 +226,13 @@ "execution_count": 3, "id": "ad21ccc1", "metadata": { + "execution": { + "iopub.execute_input": "2024-01-30T00:31:10.122151Z", + "iopub.status.busy": "2024-01-30T00:31:10.121916Z", + "iopub.status.idle": "2024-01-30T00:31:10.262787Z", + "shell.execute_reply": "2024-01-30T00:31:10.261975Z", + "shell.execute_reply.started": "2024-01-30T00:31:10.122129Z" + }, "tags": [] }, "outputs": [ @@ -334,6 +355,13 @@ "execution_count": 4, "id": "2646efb0", "metadata": { + "execution": { + "iopub.execute_input": "2024-01-30T00:31:10.265476Z", + "iopub.status.busy": "2024-01-30T00:31:10.265178Z", + "iopub.status.idle": "2024-01-30T00:31:10.764362Z", + "shell.execute_reply": "2024-01-30T00:31:10.763650Z", + "shell.execute_reply.started": "2024-01-30T00:31:10.265453Z" + }, "tags": [] }, "outputs": [ @@ -342,28 +370,28 @@ "text/html": [ "\n", "\n", - "
\n", + "
\n", "" ], "text/plain": [ @@ -490,6 +518,13 @@ "execution_count": 5, "id": "9d265060", "metadata": { + "execution": { + "iopub.execute_input": "2024-01-30T00:31:10.767460Z", + "iopub.status.busy": "2024-01-30T00:31:10.767287Z", + "iopub.status.idle": "2024-01-30T00:33:16.269066Z", + "shell.execute_reply": "2024-01-30T00:33:16.267817Z", + "shell.execute_reply.started": "2024-01-30T00:31:10.767441Z" + }, "tags": [] }, "outputs": [ @@ -499,28 +534,28 @@ "text": [ "#\n", "# Fitting site-level fixed Hill coefficient and non-neutralized frac model.\n", - "# Starting optimization of 1248 parameters at Fri Jan 26 11:43:31 2024.\n", + "# Starting optimization of 1248 parameters at Mon Jan 29 16:31:23 2024.\n", " step time_sec loss fit_loss reg_escape reg_spread reg_spatial reg_uniqueness reg_uniqueness2 reg_activity reg_hill_coefficient reg_non_neutralized_frac\n", - " 0 0.036176 37333 37314 0 0 0 0 0 18.641 0 0\n", - " 100 4.0581 4910 4825 38.903 0 0 0 0 46.113 0 0\n", - " 187 7.4821 4908.2 4822.4 39.676 0 0 0 0 46.145 0 0\n", - "# Successfully finished at Fri Jan 26 11:43:39 2024.\n", + " 0 0.13355 37333 37314 0 0 0 0 0 18.641 0 0\n", + " 100 14.986 4910 4825 38.888 0 0 0 0 46.108 0 0\n", + " 177 26.404 4908.2 4822.5 39.589 0 0 0 0 46.145 0 0\n", + "# Successfully finished at Mon Jan 29 16:31:49 2024.\n", "#\n", "# Fitting fixed Hill coefficient and non-neutralized frac model.\n", - "# Starting optimization of 8450 parameters at Fri Jan 26 11:43:39 2024.\n", + "# Starting optimization of 8450 parameters at Mon Jan 29 16:31:50 2024.\n", " step time_sec loss fit_loss reg_escape reg_spread reg_spatial reg_uniqueness reg_uniqueness2 reg_activity reg_hill_coefficient reg_non_neutralized_frac\n", - " 0 0.057451 7348.1 7034.8 267.14 2.8796e-31 0 0 0 46.145 0 0\n", - " 100 6.7995 6863 6706.2 93.396 10.9 0 0 0 52.517 0 0\n", - " 200 13.405 6855 6701.6 89.267 11.691 0 0 0 52.449 0 0\n", - " 221 14.788 6854.7 6701.6 88.939 11.715 0 0 0 52.465 0 0\n", - "# Successfully finished at Fri Jan 26 11:43:54 2024.\n", + " 0 2.2456 7347.8 7034.8 266.82 3.6355e-31 0 0 0 46.145 0 0\n", + " 100 35.417 6864.9 6706.7 95.063 10.674 0 0 0 52.402 0 0\n", + " 200 65.438 6855.5 6701.8 89.625 11.611 0 0 0 52.473 0 0\n", + " 265 80.776 6854.7 6701.4 89.038 11.746 0 0 0 52.456 0 0\n", + "# Successfully finished at Mon Jan 29 16:33:11 2024.\n", "#\n", "# Fitting model.\n", - "# Starting optimization of 8452 parameters at Fri Jan 26 11:43:54 2024.\n", + "# Starting optimization of 8452 parameters at Mon Jan 29 16:33:11 2024.\n", " step time_sec loss fit_loss reg_escape reg_spread reg_spatial reg_uniqueness reg_uniqueness2 reg_activity reg_hill_coefficient reg_non_neutralized_frac\n", - " 0 0.056528 6812.7 6701.6 88.939 11.715 0 0 0 10.493 0 0\n", - " 15 0.95641 6750.3 6638.2 88.941 11.716 0 0 0 10.443 0.90755 0.07658\n", - "# Successfully finished at Fri Jan 26 11:43:55 2024.\n" + " 0 0.23519 6812.7 6701.4 89.038 11.746 0 0 0 10.491 0 0\n", + " 19 5.2434 6750.3 6638.1 89.041 11.747 0 0 0 10.444 0.90715 0.076633\n", + "# Successfully finished at Mon Jan 29 16:33:16 2024.\n" ] } ], @@ -558,6 +593,13 @@ "execution_count": 6, "id": "8e887519", "metadata": { + "execution": { + "iopub.execute_input": "2024-01-30T00:33:16.271248Z", + "iopub.status.busy": "2024-01-30T00:33:16.270761Z", + "iopub.status.idle": "2024-01-30T00:33:16.291062Z", + "shell.execute_reply": "2024-01-30T00:33:16.290394Z", + "shell.execute_reply.started": "2024-01-30T00:33:16.271214Z" + }, "tags": [] }, "outputs": [ @@ -631,6 +673,13 @@ "execution_count": 7, "id": "d7b168a4", "metadata": { + "execution": { + "iopub.execute_input": "2024-01-30T00:33:16.292741Z", + "iopub.status.busy": "2024-01-30T00:33:16.292354Z", + "iopub.status.idle": "2024-01-30T00:33:16.296224Z", + "shell.execute_reply": "2024-01-30T00:33:16.295398Z", + "shell.execute_reply.started": "2024-01-30T00:33:16.292714Z" + }, "tags": [] }, "outputs": [], @@ -652,6 +701,13 @@ "execution_count": 8, "id": "f7db9fc1-1a45-403e-b504-6cbc02f68af7", "metadata": { + "execution": { + "iopub.execute_input": "2024-01-30T00:33:16.298068Z", + "iopub.status.busy": "2024-01-30T00:33:16.297723Z", + "iopub.status.idle": "2024-01-30T00:33:16.403470Z", + "shell.execute_reply": "2024-01-30T00:33:16.402824Z", + "shell.execute_reply.started": "2024-01-30T00:33:16.298042Z" + }, "tags": [] }, "outputs": [ @@ -761,6 +817,13 @@ "execution_count": 9, "id": "1a9d6f5d", "metadata": { + "execution": { + "iopub.execute_input": "2024-01-30T00:33:16.405062Z", + "iopub.status.busy": "2024-01-30T00:33:16.404719Z", + "iopub.status.idle": "2024-01-30T00:33:22.850549Z", + "shell.execute_reply": "2024-01-30T00:33:22.849370Z", + "shell.execute_reply.started": "2024-01-30T00:33:16.405039Z" + }, "tags": [] }, "outputs": [ @@ -769,28 +832,28 @@ "text/html": [ "\n", "\n", - "
\n", + "
\n", "" ], "text/plain": [ @@ -874,6 +937,13 @@ "execution_count": 10, "id": "e06e0259-9ad4-4d3a-81bb-dbf38631d702", "metadata": { + "execution": { + "iopub.execute_input": "2024-01-30T00:33:22.853070Z", + "iopub.status.busy": "2024-01-30T00:33:22.852479Z", + "iopub.status.idle": "2024-01-30T00:33:37.048502Z", + "shell.execute_reply": "2024-01-30T00:33:37.047681Z", + "shell.execute_reply.started": "2024-01-30T00:33:22.853022Z" + }, "tags": [] }, "outputs": [ @@ -882,28 +952,28 @@ "text/html": [ "\n", "\n", - "
\n", + "
\n", "" ], "text/plain": [ @@ -982,6 +1052,13 @@ "execution_count": 11, "id": "837eb0ea-e56e-4b5a-badd-94923ceca75d", "metadata": { + "execution": { + "iopub.execute_input": "2024-01-30T00:33:37.049866Z", + "iopub.status.busy": "2024-01-30T00:33:37.049556Z", + "iopub.status.idle": "2024-01-30T00:33:40.016559Z", + "shell.execute_reply": "2024-01-30T00:33:40.015911Z", + "shell.execute_reply.started": "2024-01-30T00:33:37.049848Z" + }, "tags": [] }, "outputs": [ @@ -990,28 +1067,28 @@ "text/html": [ "\n", "\n", - "
\n", + "
\n", "" ], "text/plain": [ @@ -1090,6 +1167,13 @@ "execution_count": 12, "id": "f9d15bf6-c67b-46aa-9f69-96b97133e701", "metadata": { + "execution": { + "iopub.execute_input": "2024-01-30T00:33:40.019810Z", + "iopub.status.busy": "2024-01-30T00:33:40.019413Z", + "iopub.status.idle": "2024-01-30T00:33:42.895588Z", + "shell.execute_reply": "2024-01-30T00:33:42.894880Z", + "shell.execute_reply.started": "2024-01-30T00:33:40.019785Z" + }, "tags": [] }, "outputs": [ @@ -1098,28 +1182,28 @@ "text/html": [ "\n", "\n", - "
\n", + "
\n", "" ], "text/plain": [ @@ -1198,6 +1282,13 @@ "execution_count": 13, "id": "aeff75ca", "metadata": { + "execution": { + "iopub.execute_input": "2024-01-30T00:33:42.896845Z", + "iopub.status.busy": "2024-01-30T00:33:42.896610Z", + "iopub.status.idle": "2024-01-30T00:33:43.017592Z", + "shell.execute_reply": "2024-01-30T00:33:43.016901Z", + "shell.execute_reply.started": "2024-01-30T00:33:42.896823Z" + }, "tags": [] }, "outputs": [ @@ -1291,6 +1382,13 @@ "execution_count": 14, "id": "c05b9029-6c4b-4c14-88cd-ed997a32b84a", "metadata": { + "execution": { + "iopub.execute_input": "2024-01-30T00:33:43.019148Z", + "iopub.status.busy": "2024-01-30T00:33:43.018903Z", + "iopub.status.idle": "2024-01-30T00:33:43.023519Z", + "shell.execute_reply": "2024-01-30T00:33:43.022539Z", + "shell.execute_reply.started": "2024-01-30T00:33:43.019126Z" + }, "tags": [] }, "outputs": [], @@ -1323,7 +1421,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.7" + "version": "3.11.5" } }, "nbformat": 4, diff --git a/notebooks/visualize_RBD.ipynb b/notebooks/visualize_RBD.ipynb index bdd1930..c29a347 100644 --- a/notebooks/visualize_RBD.ipynb +++ b/notebooks/visualize_RBD.ipynb @@ -28,11 +28,11 @@ "execution_count": 1, "metadata": { "execution": { - "iopub.execute_input": "2023-08-18T19:33:49.466156Z", - "iopub.status.busy": "2023-08-18T19:33:49.465707Z", - "iopub.status.idle": "2023-08-18T19:33:50.002875Z", - "shell.execute_reply": "2023-08-18T19:33:50.002317Z", - "shell.execute_reply.started": "2023-08-18T19:33:49.466127Z" + "iopub.execute_input": "2024-01-30T00:27:07.868012Z", + "iopub.status.busy": "2024-01-30T00:27:07.867409Z", + "iopub.status.idle": "2024-01-30T00:27:08.693362Z", + "shell.execute_reply": "2024-01-30T00:27:08.692655Z", + "shell.execute_reply.started": "2024-01-30T00:27:07.867975Z" }, "tags": [] }, @@ -180,11 +180,11 @@ "execution_count": 2, "metadata": { "execution": { - "iopub.execute_input": "2023-08-18T19:33:50.007688Z", - "iopub.status.busy": "2023-08-18T19:33:50.007415Z", - "iopub.status.idle": "2023-08-18T19:33:50.015950Z", - "shell.execute_reply": "2023-08-18T19:33:50.015324Z", - "shell.execute_reply.started": "2023-08-18T19:33:50.007668Z" + "iopub.execute_input": "2024-01-30T00:27:08.701546Z", + "iopub.status.busy": "2024-01-30T00:27:08.701137Z", + "iopub.status.idle": "2024-01-30T00:27:08.712414Z", + "shell.execute_reply": "2024-01-30T00:27:08.711588Z", + "shell.execute_reply.started": "2024-01-30T00:27:08.701513Z" }, "tags": [] }, @@ -264,11 +264,11 @@ "execution_count": 3, "metadata": { "execution": { - "iopub.execute_input": "2023-08-18T19:33:50.018637Z", - "iopub.status.busy": "2023-08-18T19:33:50.018402Z", - "iopub.status.idle": "2023-08-18T19:33:51.534684Z", - "shell.execute_reply": "2023-08-18T19:33:51.533775Z", - "shell.execute_reply.started": "2023-08-18T19:33:50.018618Z" + "iopub.execute_input": "2024-01-30T00:27:08.716195Z", + "iopub.status.busy": "2024-01-30T00:27:08.715796Z", + "iopub.status.idle": "2024-01-30T00:27:13.300876Z", + "shell.execute_reply": "2024-01-30T00:27:13.300109Z", + "shell.execute_reply.started": "2024-01-30T00:27:08.716169Z" } }, "outputs": [ @@ -307,11 +307,11 @@ "execution_count": 4, "metadata": { "execution": { - "iopub.execute_input": "2023-08-18T19:33:51.538616Z", - "iopub.status.busy": "2023-08-18T19:33:51.538278Z", - "iopub.status.idle": "2023-08-18T19:33:51.553502Z", - "shell.execute_reply": "2023-08-18T19:33:51.552744Z", - "shell.execute_reply.started": "2023-08-18T19:33:51.538594Z" + "iopub.execute_input": "2024-01-30T00:27:13.304988Z", + "iopub.status.busy": "2024-01-30T00:27:13.304772Z", + "iopub.status.idle": "2024-01-30T00:27:13.323531Z", + "shell.execute_reply": "2024-01-30T00:27:13.322917Z", + "shell.execute_reply.started": "2024-01-30T00:27:13.304966Z" } }, "outputs": [ @@ -389,11 +389,11 @@ "execution_count": 5, "metadata": { "execution": { - "iopub.execute_input": "2023-08-18T19:33:51.556559Z", - "iopub.status.busy": "2023-08-18T19:33:51.556234Z", - "iopub.status.idle": "2023-08-18T19:33:51.584567Z", - "shell.execute_reply": "2023-08-18T19:33:51.583847Z", - "shell.execute_reply.started": "2023-08-18T19:33:51.556538Z" + "iopub.execute_input": "2024-01-30T00:27:13.329695Z", + "iopub.status.busy": "2024-01-30T00:27:13.329065Z", + "iopub.status.idle": "2024-01-30T00:27:13.384538Z", + "shell.execute_reply": "2024-01-30T00:27:13.383868Z", + "shell.execute_reply.started": "2024-01-30T00:27:13.329645Z" } }, "outputs": [ @@ -562,11 +562,11 @@ "execution_count": 6, "metadata": { "execution": { - "iopub.execute_input": "2023-08-18T19:33:51.587542Z", - "iopub.status.busy": "2023-08-18T19:33:51.587229Z", - "iopub.status.idle": "2023-08-18T19:33:51.631721Z", - "shell.execute_reply": "2023-08-18T19:33:51.630885Z", - "shell.execute_reply.started": "2023-08-18T19:33:51.587521Z" + "iopub.execute_input": "2024-01-30T00:27:13.388886Z", + "iopub.status.busy": "2024-01-30T00:27:13.388513Z", + "iopub.status.idle": "2024-01-30T00:27:13.465313Z", + "shell.execute_reply": "2024-01-30T00:27:13.464707Z", + "shell.execute_reply.started": "2024-01-30T00:27:13.388860Z" } }, "outputs": [ @@ -791,11 +791,11 @@ "execution_count": 7, "metadata": { "execution": { - "iopub.execute_input": "2023-08-18T19:33:51.632949Z", - "iopub.status.busy": "2023-08-18T19:33:51.632670Z", - "iopub.status.idle": "2023-08-18T19:33:52.537487Z", - "shell.execute_reply": "2023-08-18T19:33:52.536666Z", - "shell.execute_reply.started": "2023-08-18T19:33:51.632929Z" + "iopub.execute_input": "2024-01-30T00:27:13.471834Z", + "iopub.status.busy": "2024-01-30T00:27:13.471109Z", + "iopub.status.idle": "2024-01-30T00:27:15.245052Z", + "shell.execute_reply": "2024-01-30T00:27:15.244472Z", + "shell.execute_reply.started": "2024-01-30T00:27:13.471786Z" } }, "outputs": [ @@ -965,11 +965,11 @@ "execution_count": 8, "metadata": { "execution": { - "iopub.execute_input": "2023-08-18T19:33:52.538697Z", - "iopub.status.busy": "2023-08-18T19:33:52.538406Z", - "iopub.status.idle": "2023-08-18T19:33:52.569625Z", - "shell.execute_reply": "2023-08-18T19:33:52.568938Z", - "shell.execute_reply.started": "2023-08-18T19:33:52.538678Z" + "iopub.execute_input": "2024-01-30T00:27:15.248182Z", + "iopub.status.busy": "2024-01-30T00:27:15.247998Z", + "iopub.status.idle": "2024-01-30T00:27:15.306231Z", + "shell.execute_reply": "2024-01-30T00:27:15.305588Z", + "shell.execute_reply.started": "2024-01-30T00:27:15.248163Z" } }, "outputs": [ @@ -1082,11 +1082,11 @@ "execution_count": 9, "metadata": { "execution": { - "iopub.execute_input": "2023-08-18T19:33:52.570514Z", - "iopub.status.busy": "2023-08-18T19:33:52.570322Z", - "iopub.status.idle": "2023-08-18T19:33:52.651268Z", - "shell.execute_reply": "2023-08-18T19:33:52.650509Z", - "shell.execute_reply.started": "2023-08-18T19:33:52.570499Z" + "iopub.execute_input": "2024-01-30T00:27:15.307689Z", + "iopub.status.busy": "2024-01-30T00:27:15.307382Z", + "iopub.status.idle": "2024-01-30T00:27:15.552698Z", + "shell.execute_reply": "2024-01-30T00:27:15.551946Z", + "shell.execute_reply.started": "2024-01-30T00:27:15.307669Z" } }, "outputs": [ @@ -1095,28 +1095,28 @@ "text/html": [ "\n", "\n", - "
\n", + "
\n", "" ], "text/plain": [ @@ -1190,11 +1190,11 @@ "execution_count": 10, "metadata": { "execution": { - "iopub.execute_input": "2023-08-18T19:33:52.652358Z", - "iopub.status.busy": "2023-08-18T19:33:52.652114Z", - "iopub.status.idle": "2023-08-18T19:33:54.102032Z", - "shell.execute_reply": "2023-08-18T19:33:54.101265Z", - "shell.execute_reply.started": "2023-08-18T19:33:52.652338Z" + "iopub.execute_input": "2024-01-30T00:27:15.554286Z", + "iopub.status.busy": "2024-01-30T00:27:15.553962Z", + "iopub.status.idle": "2024-01-30T00:27:19.827384Z", + "shell.execute_reply": "2024-01-30T00:27:19.826643Z", + "shell.execute_reply.started": "2024-01-30T00:27:15.554264Z" }, "tags": [] }, @@ -1204,28 +1204,28 @@ "text/html": [ "\n", "\n", - "
\n", + "
\n", "" ], "text/plain": [ @@ -1296,11 +1296,11 @@ "execution_count": 11, "metadata": { "execution": { - "iopub.execute_input": "2023-08-18T19:33:54.103047Z", - "iopub.status.busy": "2023-08-18T19:33:54.102816Z", - "iopub.status.idle": "2023-08-18T19:33:55.717989Z", - "shell.execute_reply": "2023-08-18T19:33:55.717268Z", - "shell.execute_reply.started": "2023-08-18T19:33:54.103030Z" + "iopub.execute_input": "2024-01-30T00:27:19.829053Z", + "iopub.status.busy": "2024-01-30T00:27:19.828666Z", + "iopub.status.idle": "2024-01-30T00:27:23.997242Z", + "shell.execute_reply": "2024-01-30T00:27:23.996347Z", + "shell.execute_reply.started": "2024-01-30T00:27:19.829030Z" } }, "outputs": [ @@ -1309,28 +1309,28 @@ "text/html": [ "\n", "\n", - "
\n", + "
\n", "" ], "text/plain": [ @@ -1403,11 +1403,11 @@ "execution_count": 12, "metadata": { "execution": { - "iopub.execute_input": "2023-08-18T19:33:55.719096Z", - "iopub.status.busy": "2023-08-18T19:33:55.718883Z", - "iopub.status.idle": "2023-08-18T19:33:56.183673Z", - "shell.execute_reply": "2023-08-18T19:33:56.183052Z", - "shell.execute_reply.started": "2023-08-18T19:33:55.719080Z" + "iopub.execute_input": "2024-01-30T00:27:23.999385Z", + "iopub.status.busy": "2024-01-30T00:27:23.998926Z", + "iopub.status.idle": "2024-01-30T00:27:24.960839Z", + "shell.execute_reply": "2024-01-30T00:27:24.960114Z", + "shell.execute_reply.started": "2024-01-30T00:27:23.999359Z" } }, "outputs": [ @@ -1490,11 +1490,11 @@ "execution_count": 13, "metadata": { "execution": { - "iopub.execute_input": "2023-08-18T19:33:56.185036Z", - "iopub.status.busy": "2023-08-18T19:33:56.184722Z", - "iopub.status.idle": "2023-08-18T19:33:56.189010Z", - "shell.execute_reply": "2023-08-18T19:33:56.188310Z", - "shell.execute_reply.started": "2023-08-18T19:33:56.185017Z" + "iopub.execute_input": "2024-01-30T00:27:24.962493Z", + "iopub.status.busy": "2024-01-30T00:27:24.962168Z", + "iopub.status.idle": "2024-01-30T00:27:24.969123Z", + "shell.execute_reply": "2024-01-30T00:27:24.968205Z", + "shell.execute_reply.started": "2024-01-30T00:27:24.962463Z" } }, "outputs": [ @@ -1565,11 +1565,11 @@ "execution_count": 14, "metadata": { "execution": { - "iopub.execute_input": "2023-08-18T19:33:56.189954Z", - "iopub.status.busy": "2023-08-18T19:33:56.189736Z", - "iopub.status.idle": "2023-08-18T19:33:56.212175Z", - "shell.execute_reply": "2023-08-18T19:33:56.211488Z", - "shell.execute_reply.started": "2023-08-18T19:33:56.189936Z" + "iopub.execute_input": "2024-01-30T00:27:24.970645Z", + "iopub.status.busy": "2024-01-30T00:27:24.970250Z", + "iopub.status.idle": "2024-01-30T00:27:25.122190Z", + "shell.execute_reply": "2024-01-30T00:27:25.121527Z", + "shell.execute_reply.started": "2024-01-30T00:27:24.970615Z" }, "tags": [] }, @@ -1667,7 +1667,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.4" + "version": "3.11.5" } }, "nbformat": 4, diff --git a/polyclonal/__init__.py b/polyclonal/__init__.py index 5bba460..824ee6a 100644 --- a/polyclonal/__init__.py +++ b/polyclonal/__init__.py @@ -31,7 +31,7 @@ __author__ = "`the Bloom lab `_" __email__ = "jbloom@fredhutch.org" -__version__ = "6.10" +__version__ = "6.11" __url__ = "https://github.com/jbloomlab/polyclonal" from polyclonal.alphabets import AAS diff --git a/polyclonal/plot.py b/polyclonal/plot.py index 5f2b3bd..4510e93 100644 --- a/polyclonal/plot.py +++ b/polyclonal/plot.py @@ -520,7 +520,7 @@ def lineplot_and_heatmap( they fail other filters in `addtl_slider_stats`. init_floor_at_zero : bool Initial value for option to put floor of zero on value is `stat_col`. - init_site_statistic : {'sum', 'mean', 'max', 'min'} + init_site_statistic : {'sum', 'mean', 'max', 'min', 'mean_abs', 'sum_abs'} Initial value for site statistic in lineplot, calculated from `stat_col`. cell_size : float Size of cells in heatmap @@ -978,7 +978,7 @@ def replace_std(col): ) # make the site chart - site_statistics = ["sum", "mean", "max", "min"] + site_statistics = ["sum", "mean", "max", "min", "sum_abs", "mean_abs"] if init_site_statistic not in site_statistics: raise ValueError(f"invalid {init_site_statistic=}") if set(site_statistics).intersection(req_cols): @@ -998,8 +998,15 @@ def replace_std(col): base_chart.transform_filter( (alt.datum.wildtype != alt.datum.mutant) & ~alt.datum["_stat_hide"] ) + .transform_calculate(_stat_abs=alt.expr.abs(alt.datum["_stat"])) .transform_aggregate( - **{f"_stat_{stat}": f"{stat}(_stat)" for stat in site_statistics}, + **{ + f"_stat_{stat}": ( + stat.split("_")[0] + + f"({'_stat_abs' if stat.endswith('_abs') else '_stat'})" + ) + for stat in site_statistics + }, groupby=[*site_prop_cols, category_col], ) .transform_fold( From aa668324c7ebbd2ab34067c2ab4be0ff992528a0 Mon Sep 17 00:00:00 2001 From: jbloom Date: Tue, 30 Jan 2024 10:50:33 -0800 Subject: [PATCH 2/3] code linting / formatting --- polyclonal/plot.py | 1 + polyclonal/polyclonal.py | 2 ++ polyclonal/polyclonal_collection.py | 1 + 3 files changed, 4 insertions(+) diff --git a/polyclonal/plot.py b/polyclonal/plot.py index 4510e93..0a1d735 100644 --- a/polyclonal/plot.py +++ b/polyclonal/plot.py @@ -594,6 +594,7 @@ def lineplot_and_heatmap( ------- altair.Chart Interactive plot. + """ if addtl_tooltip_stats is None: addtl_tooltip_stats = [] diff --git a/polyclonal/polyclonal.py b/polyclonal/polyclonal.py index 3b137aa..1dc6033 100644 --- a/polyclonal/polyclonal.py +++ b/polyclonal/polyclonal.py @@ -2867,6 +2867,7 @@ def filter_variants_by_seen_muts( variants_df : pandas.DataFrame Copy of input dataframe, with rows of variants that have unseen mutations removed. + """ variants_df = variants_df.copy() @@ -3154,6 +3155,7 @@ def mut_escape_corr(self, ref_poly): ------- corr_df : pandas.DataFrame Pairwise epitope correlations for escape. + """ if self.mut_escape_df is None or ref_poly.mut_escape_df is None: raise ValueError("Both objects must have `mut_escape_df` initialized.") diff --git a/polyclonal/polyclonal_collection.py b/polyclonal/polyclonal_collection.py index 180a16f..748bc17 100644 --- a/polyclonal/polyclonal_collection.py +++ b/polyclonal/polyclonal_collection.py @@ -851,6 +851,7 @@ def mut_escape_corr_heatmap( Plot squared correlation (eg, :math:`R^2` rather :math:`R`). **kwargs Keyword args for :func:`polyclonal.plot.corr_heatmap` + """ corr_label = {"pearson": "r", "kendall": "tau", "spearman": "rho"}[method] corr2_label = f"{corr_label}2" From e54c4c34480844d4356dc409ab9fc0a39a207618 Mon Sep 17 00:00:00 2001 From: jbloom Date: Tue, 30 Jan 2024 10:52:27 -0800 Subject: [PATCH 3/3] update GitHub actions versions for testing --- .github/workflows/test.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 7931d9a..5cf3657 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -15,10 +15,10 @@ jobs: timeout-minutes: 60 steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: install python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.11"