squidpy.tl.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) – Key inspatialdata.SpatialData.tableswhere the table is stored. Required whenadatais aspatialdata.SpatialDataobject and ignored otherwise.library_key (
str|None) – If multiple library_id, column inanndata.AnnData.obswhich stores mapping betweenlibrary_idand obs.coord_columns (
tuple[str,str]) – Tuple of column names in adata.obs that specify the coordinates (x, y), e.i. (‘globalX’, ‘globalY’)sliding_window_key (
str) – Base name for sliding window columns.overlap (
int) – Overlap size between consecutive windows. (0 = no overlap)spatial_key (
str) – Key inanndata.AnnData.obsmwhere spatial coordinates are stored.drop_partial_windows (
bool) – If True, drop windows that are smaller than the window size at the borders.copy (
bool) – If True, return the result, otherwise save it to the adata object.
- Return type:
- Returns:
If
copy = True, returns the sliding window annotation(s) as pandas dataframe Otherwise, stores the sliding window annotation(s) in .obs.