We created the python package called TOSICA
that uses scanpy
ans torch
to explainablely annotate cell type on single-cell RNA-seq data.
- Linux or UNIX system
- Python >= 3.8
- torch >= 1.7.1
conda create -n TOSICA python=3.8 scanpy
conda activate TOSICA
conda install pytorch=1.7.1 torchvision=0.8.2 torchaudio=0.7.2 cudatoolkit=10.1 -c pytorch
The TOSICA
python package is in the folder TOSICA. You can simply install it from the root of this repository using
pip install .
Alternatively, you can also install the package directly from GitHub via
pip install git+https://github.com/JackieHanLab/TOSICA.git
TOSICA.yaml
TOSICA.train(ref_adata, gmt_path,label_name=<label_key>)
ref_adata
: anAnnData
object of reference dataset.gmt_path
: default pre-prepared mask or path to .gmt files.<label_key>
: the name of the label column inref_adata.obs
.
human_gobp
: GO_bp.gmthuman_immune
: immune.gmthuman_reactome
: reactome.gmthuman_tf
: TF.gmtmouse_gobp
: m_GO_bp.gmtmouse_reactome
: m_reactome.gmtmouse_tf
: m_TF.gmt
./mask.npy
: Mask matrix./pathway.csv
: Gene set list./label_dictionary.csv
: Label list./weights20220603/
: Weights
new_adata = TOSICA.pre(query_adata, model_weight_path = <path to optional weight>)
query_adata
: anAnnData
object of query dataset .model_weight_path
: the weights generated duringscTrans.train
, like:'./weights20220607/model-6.pth'
.
new_adata.X
: Attention matrixnew_adata.obs['Prediction']
: Predicted labelsnew_adata.obs['Probability']
: Probability of the predictionnew_adata.var['pathway_index']
: Gene set of each colume./gene2token_weights.csv
: The weights matrix of genes to tokens
Warning: the
var_names
(genes) of theref_adata
andquery_adata
must be consistent and in the same order.query_adata = query_adata[:,ref_adata.var_names]
Please run the code to make sure they are the same.