From 378618fa7a1b246494305d77f93e8a0aad41c1ba Mon Sep 17 00:00:00 2001 From: Jeremy Marcus Date: Tue, 25 Nov 2025 16:34:29 -0800 Subject: [PATCH 1/3] deep copy in make_browser_figure --- dimelo/plot_read_browser.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dimelo/plot_read_browser.py b/dimelo/plot_read_browser.py index a49d496..3aa8f17 100644 --- a/dimelo/plot_read_browser.py +++ b/dimelo/plot_read_browser.py @@ -342,13 +342,14 @@ def make_browser_figure( colorscales: dictionary mapping motif names to plotly colorscale specifications TODO: Think about how this interfaces with different types of initial sorting... - TODO: Make it so that this method does NOT modify the input dataframe TODO: Should this method do the collapsing, or should this method require collapsing outside? """ if collapse: index_map = collapse_rows(read_extent_df, **kwargs) - read_extent_df["y_index"] = read_extent_df["y_index"].map(index_map) - mod_event_df["y_index"] = mod_event_df["y_index"].map(index_map) + read_extent_df.copy() + # NOTE: `DataFrame.assign` performs a deep copy, preventing the modification of the array that is passed in. For very large datasets, this duplication may cause memory issues. + read_extent_df = read_extent_df.assign(y_index=read_extent_df["y_index"].map(index_map)) + mod_event_df = mod_event_df.assign(y_index=mod_event_df["y_index"].map(index_map)) # Build final figure # TODO: Enable setting some relevant parameters From b415cba0a45cc21093853c43922a1ac90aeb0d1c Mon Sep 17 00:00:00 2001 From: Jeremy Marcus Date: Wed, 26 Nov 2025 12:27:27 -0800 Subject: [PATCH 2/3] manually triggered pre-commit --- dimelo/plot_read_browser.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dimelo/plot_read_browser.py b/dimelo/plot_read_browser.py index 3aa8f17..84eaaa2 100644 --- a/dimelo/plot_read_browser.py +++ b/dimelo/plot_read_browser.py @@ -348,8 +348,12 @@ def make_browser_figure( index_map = collapse_rows(read_extent_df, **kwargs) read_extent_df.copy() # NOTE: `DataFrame.assign` performs a deep copy, preventing the modification of the array that is passed in. For very large datasets, this duplication may cause memory issues. - read_extent_df = read_extent_df.assign(y_index=read_extent_df["y_index"].map(index_map)) - mod_event_df = mod_event_df.assign(y_index=mod_event_df["y_index"].map(index_map)) + read_extent_df = read_extent_df.assign( + y_index=read_extent_df["y_index"].map(index_map) + ) + mod_event_df = mod_event_df.assign( + y_index=mod_event_df["y_index"].map(index_map) + ) # Build final figure # TODO: Enable setting some relevant parameters From eb5b9998d74c94e263a6ad709d910374186a8177 Mon Sep 17 00:00:00 2001 From: Jeremy Marcus Date: Wed, 26 Nov 2025 12:29:26 -0800 Subject: [PATCH 3/3] remove extraneous copy --- dimelo/plot_read_browser.py | 1 - 1 file changed, 1 deletion(-) diff --git a/dimelo/plot_read_browser.py b/dimelo/plot_read_browser.py index 84eaaa2..febccac 100644 --- a/dimelo/plot_read_browser.py +++ b/dimelo/plot_read_browser.py @@ -346,7 +346,6 @@ def make_browser_figure( """ if collapse: index_map = collapse_rows(read_extent_df, **kwargs) - read_extent_df.copy() # NOTE: `DataFrame.assign` performs a deep copy, preventing the modification of the array that is passed in. For very large datasets, this duplication may cause memory issues. read_extent_df = read_extent_df.assign( y_index=read_extent_df["y_index"].map(index_map)