Skip to content

Segmentation QC API Reference

Use celldega.qc to assess cell segmentation and transcript assignment from instrument output. qc_segmentation writes summary and gene-level CSV metrics; additional helpers compare expression patterns and cell classifications.

See the Python overview for where QC fits in a workflow, and the custom segmentation example for importing an alternative segmentation into DegaFiles.

classify_cells(dataframe, cell_a_name, cell_b_name, threshold_for_a_cell_classification, threshold_for_b_cell_classification)

Classify cells based on transcript thresholds.

Parameters: - dataframe: Input dataframe - cell_a_name: Name of cell type A - cell_b_name: Name of cell type B - threshold_for_a_cell_classification: Threshold for classifying cell type A - threshold_for_b_cell_classification: Threshold for classifying cell type B

Returns: - Dataframe with classification column added

filter_orthogonal_expression(dataframe, cell_a_name, cell_b_name, threshold_for_orthogonal_exp)

Filter cells with orthogonal expression.

Parameters: - dataframe: Input dataframe - cell_a_name: Name of cell type A - cell_b_name: Name of cell type B - threshold_for_orthogonal_exp: Threshold for orthogonal expression

Returns: - Tuple of proportions (A cells with B genes, B cells with A genes)

orthogonal_expression_calc(base_paths, cell_type_a_specific_genes, cell_type_b_specific_genes, cell_a_name, cell_b_name, threshold_for_a_cell_classification=3, threshold_for_b_cell_classification=3, threshold_for_orthogonal_exp=3)

Analyze orthogonal expression patterns of cell-type-specific genes across multiple segmentation algorithms.

This function calculates the overlap of specific genes for two cell types (A and B) within cells across multiple segmentation algorithms. It returns per-technology transcript totals plus a classified summary of orthogonal expression, which can be plotted with any plotting library (e.g. a 2D histogram of the transcript totals, a grouped bar chart of the summary).

Parameters

base_paths : list of str List of paths to data directories cell_type_a_specific_genes : list of str List of genes specific to cell type A. cell_type_b_specific_genes : list of str List of genes specific to cell type B. cell_a_name : str Name or label for cell type A (used in output column names). cell_b_name : str Name or label for cell type B (used in output column names). threshold_for_a_cell_classification : int, optional Threshold for classifying cell type A (default: 3). threshold_for_b_cell_classification : int, optional Threshold for classifying cell type B (default: 3). threshold_for_orthogonal_exp : int, optional Threshold to perform orthogonal expression quantification (default: 3).

Returns

tuple of pandas.DataFrame (results, orthogonal_summary) where results has one row per cell (across all technologies) with per-cell-type transcript totals and classification, and orthogonal_summary has "Technology", "Category", and "Count" columns summarizing classified orthogonal expression per technology.

Example

results, orthogonal_summary = orthogonal_expression_calc( base_paths=["path/to/data1", "path/to/data2"], cell_type_a_specific_genes=["GeneA1", "GeneA2"], cell_type_b_specific_genes=["GeneB1", "GeneB2"], cell_a_name="CellTypeA", cell_b_name="CellTypeB" )

qc_segmentation(base_path, technology=None, dataset_name=None)

Calculate segmentation quality control (QC) metrics for imaging spatial transcriptomics data.

This function computes QC metrics to assess the quality of cell segmentation and transcript assignment in spatial transcriptomics datasets. Metrics include transcript assignment proportion, cell count, mean cell area, and transcript and gene distribution statistics.

Parameters

base_path : str Path to the data directory path_output : str, optional Output path for results path_meta_cell_micron : str, optional Path to meta cell micron data

Returns

None Outputs two CSV files containing cell-level and gene-specific QC metrics.

Example

qc_segmentation(base_path="path/to/data")