View cell type annotation results
mainAfter setting up the data, you can visualize the cell type annotation results using the provided Jupyter notebook:
- Open and run
celltype-plot.ipynbto generate and view the plot results.
repository·main·Indexed 19 days ago
https://github.com/biomap-research/scfoundationA large-scale foundation model for single-cell transcriptomics with 100M parameters. It provides high-dimensional gene and cell embeddings for downstream biological tasks, including cell type annotation, clustering, and drug sensitivity prediction via the DeepCDR model. The repository includes tools for inference, model finetuning, and reproduction notebooks for ablation studies and evaluation.
After setting up the data, you can visualize the cell type annotation results using the provided Jupyter notebook:
celltype-plot.ipynb to generate and view the plot results.preprocessing folder contains the code and demo usage for downloading and processing the data used for model pre-training, following a single-cell RNA-seq data collection workflow.To reproduce the results presented in the scFoundation paper, use the provided evaluation notebooks. These notebooks contain the workflows for evaluating the model on specific datasets.
Available notebooks:
Baron_evaluation.ipynbPBMC68k_evaluation.ipynbTo run DeepCDR, ensure the following Python packages are installed:
Keras==2.1.4
TensorFlow==1.13.1
hickle >= 2.1.0You can train the CDR (Cell-Drug Response) prediction model using the run_DeepCDR.py script. The project provides two training modes: a baseline model using gene expression data directly, and an embedding based model that utilizes scFoundation embeddings.
Before running, ensure you create log and checkpoint directories to capture output and save model weights. The scFoundation embeddings for gene expression data are located at DeepCDR/data/50M-0.1B-res_embedding.npy.
# Setup directories
mkdir log
mkdir checkpoint
cd ./prog/
## baseline model
CUDA_VISIBLE_DEVICES=0 python run_DeepCDR.py -use_gexp > ../log/Base_rep1.log 2>&1
## embedding based model
CUDA_VISIBLE_DEVICES=0 python run_DeepCDR.py --ckpt_name 50M-0.1B-res -use_gexp > ../log/50M-0.1B-res_rep1.log 2>&1To reproduce the gene embeddings results, use the notebook plot_geneemb.ipynb. Note that you must have an environment with pyscenic installed to run the reproduction steps successfully.
# Refer to plot_geneemb.ipynb for reproducing the gene embeddings' results.
# A environment with pyscenic is needed.Cell embeddings for downstream tasks can be obtained in two ways:
.npy files provided in this repository for specific datasets.Pre-computed Embedding Files:
baron_human_samp_19264_fromsaver_50M-0.1B-res_tgthighres5_embedding.npyscFoundation requires gene symbols to match the specific index provided in OS_scRNA_gene_index.19264.tsv. If your data uses different symbols, use the main_gene_selection function from get_embedding.py to align your data.
X_df should represent your single-cell data with cells in rows and genes in columns.
# X_df represents your single cell data with cells in rows and genes in columns
gene_list_df = pd.read_csv('../OS_scRNA_gene_index.19264.tsv', header=0, delimiter='\t')
gene_list = list(gene_list_df['gene_name'])
X_df, to_fill_columns, var = main_gene_selection(X_df, gene_list)genemodule directory.To download the raw data files required for the scRNA processing workflow, use the provided down.sh script. For a demonstration of the download process, you can run the demo.sh script.
bash demo.shTo enhance cell read depth for clustering using scFoundation, use the scripts provided in the enhancement folder. The implementation is demonstrated by running the run.sh bash script within that directory. Detailed documentation is available in enhancement/README.md.
# Located in the enhancement folder
run.sh