sliding_window#
- squidpy.tl.sliding_window(adata, *, library_key=None, window_size=None, overlap=0, coord_columns=('globalX', 'globalY'), sliding_window_key='sliding_window_assignment', spatial_key='spatial', drop_partial_windows=False, copy=False, table_key=None)[source]#
Divide a tissue slice into regulary shaped spatially contiguous regions (windows).
- Parameters:
- adata
AnnData|SpatialData Annotated data object.
- table_key
str|None(default:None) Key in
spatialdata.SpatialData.tableswhere the table is stored. Required whenadatais aspatialdata.SpatialDataobject and ignored otherwise.- window_size
int|None(default:None) Size of the sliding window.
- library_key
str|None(default:None) If multiple
library_id, column inanndata.AnnData.obswhich stores mapping betweenlibrary_idand obs.- coord_columns
tuple[str,str] (default:('globalX', 'globalY')) Tuple of column names in
adata.obsthat specify the coordinates (x, y), e.i. (‘globalX’, ‘globalY’)- sliding_window_key
str(default:'sliding_window_assignment') Base name for sliding window columns.
- overlap
int(default:0) Overlap size between consecutive windows. (0 = no overlap)
- spatial_key
str(default:'spatial') Key in
anndata.AnnData.obsmwhere spatial coordinates are stored.- drop_partial_windows
bool(default:False) If True, drop windows that are smaller than the window size at the borders.
- copy
bool(default:False) If True, return the result, otherwise save it to the adata object.
- adata
- Returns:
DataFrame|None– Ifcopy = True, returns the sliding window annotation(s) as pandas dataframe Otherwise, stores the sliding window annotation(s) in .obs.