diff --git a/src/agora/utils/merge.py b/src/agora/utils/merge.py index 442bdf0e399e07116713355858680241628296bb..b588871be583e8ce8478c581e9b24b1456677f33 100644 --- a/src/agora/utils/merge.py +++ b/src/agora/utils/merge.py @@ -48,7 +48,7 @@ def apply_merges(data: pd.DataFrame, merges: np.ndarray): # TODO Use matrices to perform merges in batch # for efficiency if valid_merges.any(): - to_merge = data.loc[indices] + to_merge = data.loc[indices].copy() targets, sources = zip(*merges[valid_merges]) for source, target in zip(sources, targets): target = tuple(target) diff --git a/src/postprocessor/core/reshapers/bud_metric.py b/src/postprocessor/core/reshapers/bud_metric.py index b5c9ab2c42bee387e8507a56e449d9ec485638ce..57c0106914885d2db2245a4945371c64ce227f27 100644 --- a/src/postprocessor/core/reshapers/bud_metric.py +++ b/src/postprocessor/core/reshapers/bud_metric.py @@ -78,7 +78,9 @@ class BudMetric(LineageProcess): else: md_index = md_index.droplevel("mother_label") if len(md_index) < len(signal): - print("Dropped cells before applying bud_metric") # TODO log + print( + f"Dropped {len(signal) - len(md_index)} cells before applying bud_metric" + ) # TODO log # restrict signal to the cells in md_index moving mother_label to do so signal = ( signal.reset_index("mother_label") @@ -90,7 +92,7 @@ class BudMetric(LineageProcess): daughter_df = signal.loc[mother_labels > 0] # join data for daughters with the same mother output_df = daughter_df.groupby(["trap", "mother_label"]).apply( - lambda x: _combine_daughter_tracks(x) + combine_daughter_tracks ) output_df.columns = signal.columns # daughter data is indexed by mothers, which themselves have no mothers @@ -101,7 +103,7 @@ class BudMetric(LineageProcess): return output_df -def _combine_daughter_tracks(tracks: pd.DataFrame): +def combine_daughter_tracks(tracks: pd.DataFrame): """ Combine multiple time series of daughter cells into one time series.