sparrow.tb.allocate#
- sparrow.tb.allocate(sdata, labels_layer, points_layer='transcripts', output_layer='table_transcriptomics', to_coordinate_system='global', chunks=10000, name_gene_column='gene', append=False, update_shapes_layers=True, overwrite=False)#
Allocates transcripts to cells via provided
labels_layer
andpoints_layer
and returns updated SpatialData object with a table layer (sdata.tables[output_layer]
) holding the AnnData object with cell counts.- Parameters:
sdata (
SpatialData
) – The SpatialData object.labels_layer (
str
) – The labels layer (i.e. segmentation mask) insdata
to be used to allocate the transcripts to cells.points_layer (
str
(default:'transcripts'
)) – The points layer insdata
that contains the transcripts.output_layer (
str
(default:'table_transcriptomics'
)) – The table layer insdata
in which to save the AnnData object with the transcripts counts per cell.to_coordinate_system (
str
(default:'global'
)) – The coordinate system that holdslabels_layer
andpoints_layer
.chunks (
str
|tuple
[int
,...
] |int
|None
(default:10000
)) – Chunk sizes for processing. Can be a string, integer or tuple of integers. Consider setting the chunks to a relatively high value to speed up processing (>10000, or only chunk in z-dimension if data is 3D, and one z-slice fits in memory), taking into account the available memory of your system.name_gene_column (
str
(default:'gene'
)) – Column name in thepoints_layer
representing gene information.append (
bool
(default:False
)) – If set to True, and thelabels_layer
does not yet exist as a_REGION_KEY
insdata.tables[output_layer].obs
, the transcripts counts obtained during the current function call will be appended (along axis=0) to any existing transcript count values. within the SpatialData object’s table attribute. If False, and overwrite is set to True any existing data insdata.tables[output_layer]
will be overwritten by the newly extracted transcripts counts.update_shapes_layers (
bool
(default:True
)) – Whether to filter the shapes layers associated withlabels_layer
. If set toTrue
, cells that do not appear in resultingoutput_layer
(with_REGION_KEY
equal tolabels_layer
) will be removed from the shapes layers (via_INSTANCE_KEY
) in thesdata
object. Filtered shapes will be added tosdata
with prefix ‘filtered_segmentation’.overwrite (
bool
(default:False
)) – If True, overwrites theoutput_layer
if it already exists insdata
.
- Return type:
SpatialData
- Returns:
: An updated SpatialData object with an AnnData table added to
sdata.tables
at slotoutput_layer
.