pyXenium.multimodal.export_for_stgpt#

export_for_stgpt(data, output_dir, *, contour_key=None, feature_table=None, sample_id=None, neighbor_k=6, include_expression_matrix=True, table_format='csv')#

Write a lightweight pyXenium-to-stGPT handoff bundle.

pyXenium owns Xenium loading and feature preparation; stGPT owns foundation model training/inference. This function writes only contract files that an external stGPT workflow can consume.

Parameters#

data:

An AnnData or XeniumSlide containing the Xenium cell table and optional contour shapes.

output_dir:

Directory where all handoff artifacts are written.

contour_key:

Key in sdata.shapes identifying the contour DataFrame to export.

feature_table:

Optional mapping of named DataFrames (e.g. "contour_features", "rna_pseudobulk") to include alongside the expression matrix.

sample_id:

Override the sample identifier; inferred from data when None.

neighbor_k:

Number of nearest spatial neighbours for the spatial edge graph.

include_expression_matrix:

When True (default), writes the sparse RNA count matrix as a scipy_sparse_csr_npz file.

table_format:

Output format for tabular data: "csv" (default) or "parquet". Use "parquet" for large datasets to reduce I/O overhead.

Parameters:
Return type:

dict[str, Any]