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, shapes_layers_to_filter=None, overwrite=False)#
Allocates transcripts to cells via provided
labels_layerandpoints_layerand returns updated SpatialData object with a table layer (sdata.tables[output_layer]) holding the AnnData object with cell counts.It requires that
labels_layerandpoints_layerare registered. Relation betweento_coordinate_systemandpoints_layershould be aspatialdata.transformations.Identitytransformation. Relation betweento_coordinate_systemandlabels_layercan be aspatialdata.transformations.Identity,spatialdata.transformations.Translation, or aspatialdata.transformation.Sequenceof translations.- Parameters:
sdata (
SpatialData) – The SpatialData object.labels_layer (
str) – The labels layer (i.e. segmentation mask) insdatato be used to allocate the transcripts to cells.points_layer (
str(default:'transcripts')) – The points layer insdatathat contains the transcripts.output_layer (
str(default:'table_transcriptomics')) – The table layer insdatain which to save the AnnData object with the transcripts counts per cell.to_coordinate_system (
str(default:'global')) – The coordinate system that holdslabels_layerandpoints_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_layerrepresenting gene information.append (
bool(default:False)) – If set to True, and thelabels_layerdoes not yet exist as a_REGION_KEYinsdata.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_KEYequal tolabels_layer) will be removed from the shapes layers (via_INSTANCE_KEY) in thesdataobject. Filtered shapes will be added tosdatawith prefix ‘filtered_segmentation’.shapes_layers_to_filter (
list[str] |None(default:None)) – List of names of the shapes layers to filter. If None, and update_shapes_layers is True, all shapes layers insdatathat match the coordinate system of the labels layer will be filtered.overwrite (
bool(default:False)) – If True, overwrites theoutput_layerif it already exists insdata.
- Return type:
SpatialData- Returns:
: An updated SpatialData object with an AnnData table added to
sdata.tablesat slotoutput_layer.