Skip to content

mergeAdataObs

mergeAdataObs

mergeAdataObs(
    data, outputDir=None, verbose=True, sdataTable=None
)

Concatenate the obs tables of one or more objects.

Reads only the cell metadata, so it is cheap even across many large files. The result is a plain DataFrame, not an AnnData — this is for inspection and export, not for continuing an analysis.

Parameters:

Name Type Description Default
data (AnnData | SpatialData | str | list, required)

One cell table, or a list of them. Each may be an AnnData, an .h5ad path, a SpatialData, or a .zarr store.

required
outputDir str

Directory to write merged_adata_obs.csv into. With None nothing is written.

None
verbose bool

Print progress messages.

True
sdataTable str

Which SpatialData table to read. Applied to every item.

None

Returns:

Name Type Description
merged DataFrame

The obs tables stacked row-wise, always returned whether or not outputDir was given.

Example
obs = sp.pp.mergeAdataObs(["sample_1.h5ad", "sample_2.h5ad", "sample_3.h5ad"])
obs.groupby("imageid")["phenotype"].value_counts()

sp.pp.mergeAdataObs(["sample_1.h5ad", "sample_2.h5ad"], outputDir="results")