omicverse.single.run_cellphonedb_v5#
- omicverse.single.run_cellphonedb_v5(adata, cpdb_file_path, celltype_key='celltype', min_cell_fraction=0.005, min_genes=200, min_cells=3, iterations=1000, threshold=0.1, pvalue=0.05, threads=10, output_dir=None, temp_dir=None, cleanup_temp=True, debug=False, separator='|', results_key='cpdb_results', comm_key='cpdb_comm', method='statistical', degs_file_path=None, score_interactions=True, **kwargs)[source]#
Run CellPhoneDB statistical or DEGs-based analysis.
- Parameters:
adata (AnnData) – Annotated data matrix
cpdb_file_path (str) – Path to CellPhoneDB database zip file (REQUIRED) If file doesn’t exist, will attempt automatic download
celltype_key (str) – Column name in adata.obs containing cell type annotations
min_cell_fraction (float) – Minimum fraction of total cells required for a cell type to be included
min_genes (int) – Minimum number of genes required per cell
min_cells (int) – Minimum number of cells required per gene
iterations (int) – Number of shufflings performed in the analysis
threshold (float) – Min % of cells expressing a gene for this to be employed in the analysis
pvalue (float) – P-value threshold to employ for significance
threads (int) – Number of threads to use in the analysis
output_dir (str or None) – Directory to save results. If None, creates temporary directory
temp_dir (str or None) – Directory for temporary files. If None, uses system temp
cleanup_temp (bool) – Whether to clean up temporary files after analysis
debug (bool) – Saves all intermediate tables employed during the analysis
separator (str) – String to employ to separate cells in the results dataframes
method ({2, 3, 'statistical', 'degs'}) – CellPhoneDB method to run. Method 2 /
'statistical'is the historical permutation-based default. Method 3 /'degs'runs the DEGs-based analysis.degs_file_path (str or None) – CellPhoneDB DEG input file. Required when
method='degs'.score_interactions (bool) – Whether CellPhoneDB should calculate interaction scores.
**kwargs (dict) – Additional parameters forwarded to the selected CellPhoneDB method.
- Returns:
Raw CellPhoneDB result dict and visualization-ready communication AnnData. The same objects are also written to
adata.uns[results_key]andadata.uns[comm_key]so downstreamov.pl.ccc_*plots can work directly on the originaladata.- Return type:
Tuple[dict,anndata.AnnData]
Examples
# Basic usage - will download database automatically if needed cpdb_results, adata_cpdb = run_cellphonedb_v5(
adata, cpdb_file_path=’./cellphonedb.zip’, celltype_key=’celltype_minor’
)
# Advanced usage cpdb_results, adata_cpdb = run_cellphonedb_v5(
adata, cpdb_file_path=’/path/to/cellphonedb.zip’, celltype_key=’celltype_minor’, min_cell_fraction=0.01, iterations=2000, threads=20
)