scRNA Reference

sc_reference.construct_sc_ref(adata_sc: AnnData, key_type: str)[source]

Construct the scRNA reference from scRNA data.

Parameters:
  • adata_sc – scRNA data.

  • key_type – The key that is used to extract cell type information from adata_sc.obs.

Returns:

scRNA reference. Numpy assay with dimension n_type*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=None, filtering=True, verbose=0)[source]

Filter single cell data and spatial data, and normalize the data to count per million (CPM).

Parameters:
  • adata_sc (anndata.AnnData) – Single cell data.

  • adata_st (anndata.AnnData) – Spatial data.

  • min_genes (int) – Minimum number of genes expressed required for a cell to pass filtering.

  • min_cells (int) – Minimum number of cells expressed required for a gene to pass filtering.

  • min_std (float) – Minimum std of counts required for a gene to pass filtering after CPM normalization.

  • normalize_st (bool) – If False, spatial data is also normalized to one million. Otherwise, normalized_st should be np.ndarray, representing the number of cells in each spot, and the expression of each spot is normalized to n_cell million.

  • filtering (bool) – Whether to filter the genes in adata_sc.

  • verbose (int) – Verbose mode.

sc_reference.marker_selection(adata_sc: AnnData, key_type: str, threshold_cover=0.6, threshold_p=0.1, threshold_fold=1.5, n_select=40, verbose=0, return_dict=False, q=0)[source]

Find marker genes based on pairwise ratio test.

Parameters:
  • adata_sc – scRNA data (Anndata).

  • key_type – The key that is used to extract cell type information from adata_sc.obs.

  • threshold_cover – Minimum proportion of non-zero reads of a marker gene in assigned cell type.

  • threshold_p – Maximum p-value for a gene to be marker gene.

  • threshold_fold – Minimum fold change for a gene to be marker gene.

  • n_select – Number of marker genes selected for each cell type.

  • verbose – 0: silent. 1: print the number of marker genes of each cell type.

  • return_dict – If true, return a dictionary of marker genes, where the keys are the name of the cell types.

  • q – Quantile of the fold-change that we considered.

Returns:

List of the marker genes or a dictionary of marker genes, where the keys are the name of the cell types.

sc_reference.plot_heatmap(adata_sc, key_type, fig_size=(10, 4), dpi=300, save=False, out_dir='')[source]

Plot the heatmap of the mean expression.

Parameters:
  • adata_sc – scRNA data (Anndata).

  • key_type – The key that is used to extract cell type information from adata_sc.obs.

  • fig_size – Initial size of the figure.

  • dpi – Dots per inch (DPI) of the figure.

  • save – Whether to save the heatmap.

  • out_dir – Output directory.

sc_reference.plot_sc_ref(sc_ref, type_list, fig_size=(10, 4), dpi=300)[source]

Plot the heatmap of the single cell reference

Parameters:
  • sc_ref – scRNA reference. np.ndarray n_type*n_gene.

  • type_list – List of the cell types.

  • fig_size – Initial size of the figure.

  • dpi – Dots per inch (DPI) of the figure.