scgen.SCGEN.binary_classifier

SCGEN.binary_classifier(adata, delta, ctrl_key, stim_key, path_to_save, save=True, fontsize=14)[source]

Latent space classifier.

Builds a linear classifier based on the dot product between the difference vector and the latent representation of each cell and plots the dot product results between delta and latent representation.

Parameters
adata : ~anndata.AnnData

AnnData object with equivalent structure to initial AnnData. If None, defaults to the AnnData object used to initialize the model. Must have been setup with batch_key and labels_key, corresponding to batch and cell type metadata, respectively.

delta : float

Difference between stimulated and control cells in latent space

ctrl_key : basestring

key for control part of the data found in condition_key.

stim_key : basestring

key for stimulated part of the data found in condition_key.

path_to_save : basestring

path to save the plot.

save : boolean

Specify if the plot should be saved or not.

fontsize : integer

Set the font size of the plot.

Examples

>>> import anndata
>>> import scgen
>>> import scanpy as sc
>>> train = sc.read("./tests/data/train.h5ad", backup_url="https://goo.gl/33HtVh")
>>> scgen.SCGEN.setup_anndata(train)
>>> network = scgen.SCGEN(train)
>>> network.train()
>>> unperturbed_data = train[((train.obs["cell_type"] == "CD4T") & (train.obs["condition"] == "control"))]
>>> pred, delta = network.predict(
>>>     adata=train,
>>>     adata_to_predict=unperturbed_data,
>>>     ctrl_key="control",
>>>     stim_key="stimulated"
>>>)
>>> network.binary_classifier(
>>>     network,
>>>     train,
>>>     delta,
>>>     ctrl_key="control",
>>>     stim_key="stimulated",
>>>     path_to_save="tests/binary_classifier.pdf"
>>>     )