xchrom.tl.crosssamples_nsls

xchrom.tl.crosssamples_nsls(cell_embedding_ad: str | Path | AnnData, input_folder: str | Path = './test_data', output_path: str | Path = './eval_out', model_path: str | Path = './train_out/E1000best_model.h5', cellembed_raw: str = 'X_pca_harmony', celltype: str = 'cell_type', save_pred: bool = False, plot_umap: bool = False, **kwargs)[source]

Evaluate the performance in cross-samples scenario, calculate neighbor score(k=10,50,100) and label score(k=10,50,100) for all cells.

Parameters:
  • cell_embedding_ad (str or Path or anndata.AnnData) – Path to the cell embedding adata file. provide cell input embedding for XChrom model prediction.

  • input_folder (str or Path) – Path to the test data folder. Should generate by XChrom_preprocess.py. Must contain ‘splits.h5’, ‘ad.h5ad’, ‘all_seqs.h5’.

  • output_path (str or Path) – Path to the output folder.

  • model_path (str or Path) – Path to the trained model.

  • cellembed_raw (str) – Key of the raw cell input embedding in the cell embedding adata,to calculate RNA neighbors and generate model input.

  • celltype (str) – Key of the cell type label in the cell embedding adata.

  • save_pred (bool) – Whether to save the prediction matrix with npy format.

  • plot_umap (bool) – Whether to plot the UMAP of the test cells.

Returns:

metrics – Dictionary containing neighbor score(k=10,50,100) and label score(k=10,50,100) for all cells.

Return type:

dict

Examples

>>> import xchrom as xc
metrics2 = xc.tl.crosssamples_nsls(
    cell_embedding_ad='./data/2_cross_samples/test_rna_harmony.h5ad',
    input_folder='./data/2_cross_samples/test_data',
    model_path='./data/2_cross_samples/train_out/E1000best_model.h5',
    output_path='./data/2_cross_samples/eval_out',
    cellembed_raw='X_pca_harmony',
    use_rep_rna='X_pca',
    celltype = 'cell_type',
    save_pred=True,
    plot_umap=True
    )