Views
No views yet
| Model | F1-score |
|---|---|
| GB.Tissue | 0.67 |
| scFoundation | 0.53 |
| Nicheformer | 0.50 |
| Task | Mean absolute error | R square |
|---|---|---|
| GB.Tissue | 4.44 | 0.55 |
| scFoundation | 6.17 | 0.11 |
| Nicheformer | 7.08 | -0.07 |
ModelGenerator/.ModelGenerator/downloads as cell_density or niche_type_classification. Under each sub-directory, there are three files denote different split (xx.train.h5ad, xx.val.h5ad, xx.test.h5ad)..h5ad, several obs attributes should be included to reprezent the spatial (coordinate) information (like x, y), the label information (like niche_label). All the column fields will be specified in the following config.yaml file.scRNA_genename_and_index.tsv includes all the corresponding gene name and index in h5ad file.CUDA_VISIBLE_DEVICES=7 nohup mgen fit --config experiments/GB.Tissue/niche_type_classfification.yaml > logs/nohup/GB.Tissue.niche_type_classfification.yaml.log 2>&1 &filter_columns includes label column and spatial coordinate column. rename_columns keep unchanged and will be used for running.ckpt file under the specified output directory default_root_dir. Then we can use the ckpt to evaluate on test dataset.1CUDA_VISIBLE_DEVICES=6 nohup mgen test --config experiments/GB.Tissue/niche_type_classfification.yaml \
2 --ckpt_path ckpt_path \
3 > ckpt_path.pred.log 2>&1 &ckpt_path is the finetuned checkpoint path.experiments/GB.Tissue/cell_density_regression.yaml, all the fintuning running and evaluation are similar as classification task..h5ad file. The script is as:CUDA_VISIBLE_DEVICES=3 nohup mgen predict --config experiments/GB.Tissue/emb.xenium.yaml > logs/nohup/GB.Tissue.emb.xenium.log 2>&1 &output_dir like ./logs/emb.xenium/lightning_logs/pred_output. Each batch will be saved and a merged one will also be generated as predict_predictions.pt. The predict_predictions.pt file satcks all batches:1>>> import torch
2>>> file_all = 'predict_predictions.pt'
3>>> d_all = torch.load(file_all, map_location='cpu')
4>>> d_all.keys()
5dict_keys(['predictions', 'ids'])
6>>> len(d_all['predictions']) # this equal to #sample
7586
8>>> len(d_all['ids']) # ids are numeric index corresponding to .h5ad file
9586
10>>> d_all['predictions'].shape # (B, L, D), L is max sequence length of all samples
11torch.Size([586, 90, 128])1>>> d_all_maxpooling = [d_all['predictions'][i,:,:] for i in range(d_all['predictions'].shape[0])]
2>>> d_all_maxpooling = [i[~torch.any(i.isnan(), dim=1)] for i in d_all_maxpooling]
3>>> d_all_maxpooling = torch.cat([i.max(dim=0)[0].view(1,-1) for i in d_all_maxpooling])
4>>> d_all_maxpooling.shape
5torch.Size([586, 128])