opendvp.io.quant_to_adata

Contents

opendvp.io.quant_to_adata#

opendvp.io.quant_to_adata(path, index_into_1_based='CellID', meta_columns=None)#

Convert cell quantification CSV data to an AnnData object for downstream analysis.

This module provides a function to read a CSV file containing single-cell quantification data, extract metadata and marker intensities, and return an AnnData object suitable for spatial omics workflows. The function expects specific metadata columns and parses marker columns by splitting their names into mathematical operation and marker name.

Return type:

AnnData

Parameters#

pathstr

Path to the CSV file containing cell quantification data.

index_into_1_basedstr | None

Column name to which to check if 0 exists, and if so add 1 to all values This is done so that cell index matches segmentation mask values If None, no modifications will be performed

Returns:#

ad.AnnData

AnnData object with cell metadata in .obs and marker intensities in .X and .var.

Examples:#

>>> from opendvp.io import quant_to_adata
>>> adata = quant_to_adata('my_quantification.csv')
>>> print(adata)
AnnData object with n_obs * n_vars = ...
>>> adata.obs.head()
>>> adata.var.head()

Notes:#

  • The CSV file must contain the following metadata columns: ‘CellID’, ‘Y_centroid’, ‘X_centroid’, ‘Area’, ‘MajorAxisLength’, ‘MinorAxisLength’, ‘Eccentricity’, ‘Orientation’, ‘Extent’, ‘Solidity’.

  • All other columns are treated as marker intensities and are split into ‘math’ and ‘marker’ components for AnnData.var.

  • Raises ValueError if required metadata columns are missing or if the file is not a CSV.

  • The function logs the number of cells and variables loaded, and the time taken for the operation.