DebarcodingĀ¶
Runtime: about 20s.
InĀ [1]:
Copied!
import scyan
import scyan
Global seed set to 0
Model initialization and fittingĀ¶
InĀ [2]:
Copied!
adata, table = scyan.data.load("debarcoding")
model = scyan.Scyan(adata, table)
adata, table = scyan.data.load("debarcoding")
model = scyan.Scyan(adata, table)
[INFO] (scyan.model) Initialized Scyan model with N=100000 cells, P=22 populations and M=6 markers.
āāā No covariate provided
āāā No continuum-marker provided
āāā Batch correction mode: False
The table
contains the barcodes of each patient (or sample):
InĀ [5]:
Copied!
table.head()
table.head()
Out[5]:
BC1 | BC2 | BC3 | BC4 | BC5 | BC6 | |
---|---|---|---|---|---|---|
Sample ID | ||||||
Pos | 1 | 1 | 1 | 1 | 1 | 1 |
A1 | 1 | 1 | 1 | -1 | -1 | -1 |
A2 | 1 | 1 | -1 | 1 | -1 | -1 |
A3 | 1 | 1 | -1 | -1 | 1 | -1 |
A4 | 1 | 1 | -1 | -1 | -1 | 1 |
InĀ [3]:
Copied!
model.fit()
model.fit()
INFO:scyan.model:Training scyan with the following hyperparameters: "batch_key": None "batch_size": 16384 "hidden_size": 16 "lr": 0.001 "max_samples": 200000 "modulo_temp": 2 "n_hidden_layers": 7 "n_layers": 7 "prior_std": 0.25 "temperature": 0.5 GPU available: True (mps), used: False TPU available: False, using: 0 TPU cores IPU available: False, using: 0 IPUs HPU available: False, using: 0 HPUs /Users/quentinblampey/Library/Caches/pypoetry/virtualenvs/scyan-5lsXrWE1-py3.9/lib/python3.9/site-packages/pytorch_lightning/trainer/setup.py:200: UserWarning: MPS available but not used. Set `accelerator` and `devices` using `Trainer(accelerator='mps', devices=1)`. rank_zero_warn( | Name | Type | Params --------------------------------------- 0 | module | ScyanModule | 29.7 K --------------------------------------- 29.7 K Trainable params 0 Non-trainable params 29.7 K Total params 0.119 Total estimated model params size (MB) /Users/quentinblampey/Library/Caches/pypoetry/virtualenvs/scyan-5lsXrWE1-py3.9/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py:1595: PossibleUserWarning: The number of training batches (6) is smaller than the logging interval Trainer(log_every_n_steps=10). Set a lower value for log_every_n_steps if you want to see logs for the training epoch. rank_zero_warn(
Training: 0it [00:00, ?it/s]
INFO:scyan.model:Successfully ended traning.
Out[3]:
Scyan model with N=100000 cells, P=22 populations and M=6 markers. āāā No covariate provided. āāā Batch correction mode: False
InĀ [4]:
Copied!
model.predict(log_prob_th=-10); # Predictions are saved in adata.obs.scyan_pop by default
model.predict(log_prob_th=-10); # Predictions are saved in adata.obs.scyan_pop by default
DataLoader: 0%| | 0/7 [00:00<?, ?it/s]
Results visualization and interpretabilityĀ¶
InĀ [5]:
Copied!
scyan.plot.umap(adata, color="scyan_pop")
scyan.plot.umap(adata, color="scyan_pop")
InĀ [6]:
Copied!
scyan.plot.scatter(adata, ["A1", "A2", "B2", "C4", "D5"], markers=["BC1", "BC2", "BC3", "BC4"])
scyan.plot.scatter(adata, ["A1", "A2", "B2", "C4", "D5"], markers=["BC1", "BC2", "BC3", "BC4"])
The latent space corresponds to the barcodes!
InĀ [7]:
Copied!
scyan.plot.pops_expressions(model)
scyan.plot.pops_expressions(model)
DataLoader: 0%| | 0/5 [00:00<?, ?it/s]
One sample latent expression is its barcode.
InĀ [8]:
Copied!
scyan.plot.pop_expressions(model, "D4")
scyan.plot.pop_expressions(model, "D4")
DataLoader: 0%| | 0/1 [00:00<?, ?it/s]