Skip to content

Commit

Permalink
Ensure that wildtype identity is always shown in heatmap tooltips eve…
Browse files Browse the repository at this point in the history
…n if mutation is filtered. (#178)
  • Loading branch information
jbloom authored Aug 18, 2023
1 parent 241a801 commit efafbd7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The format is based on `Keep a Changelog <https://keepachangelog.com>`_.
---
- Add ``heatmap_lims_from_slider_init`` option to ``lineplot_and_heatmap`` so that by default heatmap range is set by data shown with initial slider stats. Set this option to ``False`` if you want old behavior for plot limits
- Set default ``init_floor_at_zero`` for ``mut_icXX_plot`` to be ``True`` like for other plots.
- Ensure that wildtype identity is always shown in heatmap tooltips even if mutation is filtered.

6.6
---
Expand Down
13 changes: 13 additions & 0 deletions polyclonal/polyclonal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2725,6 +2725,7 @@ def _merge_df_to_merge(
if df_to_merge is None:
return data_df
else:
site_to_wt = data_df.set_index("site")["wildtype"].to_dict()
if isinstance(df_to_merge, pd.DataFrame):
df_to_merge = [df_to_merge]
elif not isinstance(df_to_merge, list):
Expand All @@ -2737,6 +2738,18 @@ def _merge_df_to_merge(
df = pd.concat(
[df.assign(epitope=e) for e in data_df["epitope"].unique()]
)
if "wildtype" not in df.columns:
df = df.assign(wildtype=lambda x: x["site"].map(site_to_wt))
else:
mapped_wt = df["site"].map(site_to_wt)
wt_mismatches = (mapped_wt != df["wildtype"]) & mapped_wt.notnull()
if any(wt_mismatches):
raise ValueError(
"wildtype mismatches\n"
+ str(df[wt_mismatches])
+ "\n"
+ str(data_df[wt_mismatches])
)
shared_cols = set(data_df.columns).intersection(df.columns)
if not shared_cols.issubset(mergeable_cols):
raise ValueError(
Expand Down

0 comments on commit efafbd7

Please sign in to comment.