scRNA Reference
- sc_reference.construct_sc_ref(adata_sc: AnnData, key_type: str) ndarray [source]
Construct the scRNA reference from scRNA data.
- Parameters:
adata_sc – scRNA data (AnnData).
key_type – Key for cell type in adata_sc.obs.
- Returns:
scRNA reference (np.ndarray, shape n_type x n_gene).
- sc_reference.initialization(adata_sc: AnnData, adata_st: AnnData, min_genes: int = 200, min_cells: int = 200, min_std: float = 20, normalize_st: ndarray | None = None, filtering: bool = True, verbose: int = 0) Tuple[AnnData, AnnData] [source]
Filter single cell and spatial data, normalize to CPM, and optionally filter genes/cells.
- Parameters:
adata_sc – Single cell data (AnnData).
adata_st – Spatial data (AnnData).
min_genes – Minimum genes per cell for filtering.
min_cells – Minimum cells per gene for filtering.
min_std – Minimum std for gene filtering after CPM normalization.
normalize_st – If None, spatial data is normalized to one million. If ndarray, represents cell counts per spot.
filtering – Whether to filter genes/cells in adata_sc.
verbose – Verbosity level.
- Returns:
Tuple of filtered and normalized (adata_sc, adata_st).
- sc_reference.marker_selection(adata_sc: AnnData, key_type: str, threshold_cover: float = 0.6, threshold_p: float = 0.1, threshold_fold: float = 1.5, n_select: int = 40, verbose: int = 0, return_dict: bool = False, q: float = 0.0) List[str] | Dict[str, List[str]] [source]
Find marker genes based on pairwise ratio test.
- Parameters:
adata_sc – scRNA data (AnnData).
key_type – Key for cell type in adata_sc.obs.
threshold_cover – Min proportion of non-zero reads in cell type.
threshold_p – Max p-value for marker gene.
threshold_fold – Min fold change for marker gene.
n_select – Number of marker genes per cell type.
verbose – Verbosity level.
return_dict – If True, return dict of marker genes by cell type.
q – Quantile for fold-change selection.
- Returns:
List or dict of marker genes.
- sc_reference.plot_heatmap(adata_sc: AnnData, key_type: str, fig_size: Tuple[int, int] = (10, 4), dpi: int = 300, save: bool = False, out_dir: str = '') None [source]
Plot the heatmap of the mean expression.
- Parameters:
adata_sc – scRNA data (AnnData).
key_type – Key for cell type in adata_sc.obs.
fig_size – Figure size.
dpi – Dots per inch.
save – Whether to save the heatmap.
out_dir – Output directory.
- sc_reference.plot_sc_ref(sc_ref: ndarray, type_list: List[str], fig_size: Tuple[int, int] = (10, 4), dpi: int = 300) None [source]
Plot the heatmap of the single cell reference.
- Parameters:
sc_ref – scRNA reference (np.ndarray, n_type x n_gene).
type_list – List of cell types.
fig_size – Figure size.
dpi – Dots per inch.