scgpt.utils package
scgpt.utils.util
- scgpt.utils.util.add_file_handler(logger: Logger, log_file_path: Path)[源代码]
Add a file handler to the logger.
- scgpt.utils.util.eval_scib_metrics(adata: AnnData, batch_key: str = 'str_batch', label_key: str = 'celltype', notes: str | None = None) Dict [源代码]
- scgpt.utils.util.find_required_colums(adata: AnnData, id: str, configs_dir: str | Path, update: bool = False) List[str | None] [源代码]
Find the required columns in AnnData, including celltype column, str_celltype column, the gene name column, and the experimental batch key.
This function asks the user to input the required column names if the first time loading the data. The names are saved in the config file and will be automatically loaded next time.
- 参数:
adata (AnnData) – The AnnData object.
id (str) – The id of the AnnData object, will be used as the file name for saving the config file.
configs_dir (Union[str, Path]) – The directory of saved config files.
update (bool) – Whether to update the config file.
- 返回:
- The required columns, including celltype_col, str_celltype_col,
gene_col, and batch_col.
- 返回类型:
List[Optional[str]]
- scgpt.utils.util.histogram(*data: List[ndarray], label: List[str] = ['train', 'valid'], color: List[str] = ['blue', 'red'], figsize: Tuple[int, int] = (9, 4), title: str | None = None, show: bool = False, save: str | None = None) Axes [源代码]
Plot histogram of the data.
- 参数:
data (List[np.ndarray]) – The data to plot.
label (List[str]) – The label of the data.
color (List[str]) – The color of the data.
figsize (Tuple[int, int]) – The size of the figure.
title (Optional[str]) – The title of the figure.
show (bool) – Whether to show the figure.
save (Optional[str]) – The path to save the figure.
- 返回:
The axes of the figure.
- 返回类型:
axes.Axes