deconvatac.tl.cell2location
===========================

.. py:module:: deconvatac.tl.cell2location


Functions
---------

.. autoapisummary::

   deconvatac.tl.cell2location.cell2location


Module Contents
---------------

.. py:function:: cell2location(adata_spatial, adata_ref, N_cells_per_location, detection_alpha, labels_key=None, layer_spatial=None, layer_ref=None, use_gpu=True, max_epochs_spatial=30000, max_epochs_ref=None, return_adatas=False, plots=True, results_path='./cell2location_results', setup_ref_kwargs={}, train_ref_kwargs={}, setup_spatial_kwargs={}, train_spatial_kwargs={})

   Run Cell2Location

   Parameters
   -----------

   adata_spatial : AnnData
       AnnData of the spatial data, filtered by highly variable features. Feature space needs to be the same as the one of adata_ref.
   adata_ref : AnnData
       AnnData of the reference data, filtered by highly variable features. Feature space needs to be the same as the one of adata_spatial.
   N_cells_per_location : float
       Expected cell number per location.
   detection_alpha : float
       Regularisation of per-location normalisation.
   labels_key : str
       Cell type key in adata_ref.obs for label information
   layer_spatial : str
       Layer of adata_spatial to use for deconvolution. If None, uses adata_spatial.X.
   layer_ref : str
       Layer of adata_ref to use for deconvolution. If None, uses adata_ref.X.
   use_gpu : bool
       Whether to use the GPU.
   max_epochs_spatial: int
       Number of epochs for the spatial mapping model. If None, defaults to np.min([round((20000 / n_cells) * 400), 400]).
   max_epochs_ref: int
       Number of epochs for the reference model. If None, defaults to np.min([round((20000 / n_cells) * 400), 400]).
   return_adatas: bool
       Whether to return AnnDatas with deconvolution results. Returns tupel: (adata_spatial, adata_ref).
   plots: bool
       Whether to plot QC and ELBO plots.
   results_path: str
       Path to save estimated cell type abundances to.
   setup_ref_kwargs: dict
       Parameters for cell2location.models.RegressionModel.setup_anndata()
   train_ref_kwargs: dict
       Parameters for cell2location.models.RegressionModel.train()
   setup_spatial_kwargs: dict
       Parameters for cell2location.models.Cell2location.setup_anndata()
   train_spatial_kwargs: dict
       Parameters for cell2location.models.Cell2location.train()


   Returns
   --------

   - Saves 'q05_cell_abundance_w_sf' and 'means_cell_abundance_w_sf' as csv-files to results_path.
   - If return_adatas=True, returns tupel (adata_spatial, adata_ref) with saved deconvolution results.


