scgen.SCGEN.reg_mean_plot¶
- SCGEN.reg_mean_plot(adata, axis_keys, labels, path_to_save='./reg_mean.pdf', save=True, gene_list=None, show=False, top_100_genes=None, verbose=False, legend=True, title=None, x_coeff=0.3, y_coeff=0.8, fontsize=14, **kwargs)[source]¶
Plots mean matching figure for a set of specific genes.
- 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.
- axis_keys : dict
- Dictionary of adata.obs keys that are used by the axes of the plot. Has to be in the following form:
{“x”: “Key for x-axis”, “y”: “Key for y-axis”}.
- labels : dict
Dictionary of axes labels of the form {“x”: “x-axis-name”, “y”: “y-axis name”}.
- path_to_save : basestring
path to save the plot.
- save : boolean
Specify if the plot should be saved or not.
- gene_list : list
list of gene names to be plotted.
- show : bool
if True: will show to the plot after saving it.
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" >>>) >>> pred_adata = anndata.AnnData( >>> pred, >>> obs={"condition": ["pred"] * len(pred)}, >>> var={"var_names": train.var_names}, >>>) >>> CD4T = train[train.obs["cell_type"] == "CD4T"] >>> all_adata = CD4T.concatenate(pred_adata) >>> network.reg_mean_plot( >>> all_adata, >>> axis_keys={"x": "control", "y": "pred", "y1": "stimulated"}, >>> gene_list=["ISG15", "CD3D"], >>> path_to_save="tests/reg_mean.pdf", >>> show=False >>> )