harpy.tb.add_table#
- harpy.tb.add_table(sdata, adata, output_table_name, region, instance_key='cell_ID', region_key='fov_labels', overwrite=False)#
Add an
AnnDataobject as a table element to aSpatialDataobject.This function stores the provided
AnnDataobject insdata.tables[output_table_name]. Whenregionis provided, the table is parsed as a SpatialData table and linked to one or more spatial elements viaregion_keyandinstance_key. IfregionisNone, the AnnData object is added as a regular table without region annotations.If
sdatais backed by a zarr store, the resulting table element is also written to that store.- Parameters:
sdata (
SpatialData) – TheSpatialDataobject to which the new table element will be added.adata (
AnnData) – TheAnnDataobject to add. Ifregionis notNone,adata.obsmust contain the columns specified byregion_keyandinstance_key.output_table_name (
str) – Name of the output table element insdata.tables.region (
list[str] |None) – Regions annotated by the table. Typically this is the list of unique values inadata.obs[region_key]. Set toNoneif the table should not annotate any spatial element.instance_key (
str(default:'cell_ID')) – Name of the column inadata.obsthat stores instance ids. Ignored ifregionisNone.region_key (
str(default:'fov_labels')) – Name of the column inadata.obsthat stores the region labels annotated by the table. Ignored ifregionisNone.overwrite (
bool(default:False)) – IfTrue, overwriteoutput_table_nameif it already exists insdata.
- Return type:
- Returns:
: The updated
SpatialDataobject.