spatialtis.GCNG#
- spatialtis.GCNG(data, known_pairs=None, predict_pairs=None, train_partition=0.9, gpus=None, max_epochs=10, lr=0.0001, batch_size=32, random_seed=42, load_model=False, **kwargs)[source]#
A pytorch reimplementation of GCNG
Use to identify directional gene-gene interactions. The trained model will be automatically save to anndata.
Note
To perform this analysis, you need pytorch, PyG and pytorch-lightning installed.
Warning
It’s suggested that you run this analysis with multiple GPU with high RAM if you want to run it on real dataset. I only tested this on a small dataset on a GTX2080Super, and it barely make it.
- Parameters
- dataAnnData
The AnnData to work with.
- known_pairspd.DataFrame
The input data for training, should be a dataframe with three columns, ligand, receptor, relationship; 0 means not interact, 1 means interact.
- predict_pairstuple of str
The pairs that you interested.
- train_partitionfloat, default: 0.9
The ratio to split the dataset for training.
- gpusint
Number of gpu to use, can be auto-detected.
- max_epochsint, default: 10
Number of epoch.
- lrfloat, default: 1e-4
Learning rate.
- batch_sizefloat, default: 32
The batch size.
- random_seedint
The random seed.
- load_modelbool, default: False
To load a pretrained model from anndata.
- **kwargs:
Config for the analysis, for details check
spatialtis.abc.AnalysisBase
.
- Returns
- Model
Trained model.
- Trainer
The lightning trainer.