File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed
Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -456,7 +456,9 @@ def _get_nhood_profile_niches(
456456 nhood_profile = weighted_profile
457457
458458 # create AnnData object from neighborhood profile to perform scanpy functions
459- adata_neighborhood = ad .AnnData (X = nhood_profile )
459+ # Use .to_numpy(copy=True) to ensure the array is writeable (required for pandas CoW compatibility)
460+ # Preserve the DataFrame index for later matching with adata_masked
461+ adata_neighborhood = ad .AnnData (X = nhood_profile .to_numpy (copy = True ), obs = pd .DataFrame (index = nhood_profile .index ))
460462
461463 # reason for scaling see https://monkeybread.readthedocs.io/en/latest/notebooks/tutorial.html#niche-analysis
462464 if scale :
Original file line number Diff line number Diff line change @@ -152,7 +152,8 @@ def sliding_window(
152152 else :
153153 col_name = f"{ sliding_window_key } _{ lib_key } window_{ idx } "
154154 sliding_window_df .loc [obs_indices , col_name ] = True
155- sliding_window_df .loc [:, col_name ].fillna (False , inplace = True )
155+ # Avoid chained assignment for pandas CoW compatibility
156+ sliding_window_df [col_name ] = sliding_window_df [col_name ].fillna (False )
156157
157158 if overlap == 0 :
158159 # create categorical variable for ordered windows
You can’t perform that action at this time.
0 commit comments