sispca.hcv_vi ============= .. py:module:: sispca.hcv_vi Classes ------- .. autoapisummary:: sispca.hcv_vi.SupervisionAnnData sispca.hcv_vi.HCV sispca.hcv_vi.HCVI Module Contents --------------- .. py:class:: SupervisionAnnData(target_key, field_type, target_type, target_n_dim=1) Custom data class for supervision from an AnnData object. :param target_key: key name of the target variable. :type target_key: str :param field_type: field type of the AnnData object where the target variable is stored. :type field_type: str :param target_type: 'continuous' or 'categorical'. The type of the target variable. :type target_type: str :param target_n_dim: The number of dimensions of the target variable. - If target_type == 'categorical', number of labels to predict. - If target_type == 'continuous', number of output dimensions in a regression model. :type target_n_dim: int .. py:attribute:: target_key .. py:attribute:: field_type .. py:attribute:: target_type .. py:attribute:: target_n_dim :value: 1 .. py:method:: _sanity_check() .. py:class:: HCV(n_input: int, n_layers: int = 1, dropout_rate: float = 0.1, n_hidden: int = 128, gene_likelihood: Literal['zinb', 'nb', 'poisson', 'normal'] = 'normal', hsic_scale: float = 1.0, n_latent_sub=[10, 10], predict_target_from_latent_sub: bool = False, target_supervision_list: list[SupervisionAnnData] | None = None, **model_kwargs) Bases: :py:obj:`scvi.module.VAE` Add HSIC loss to the latent representation in the VAE model. :param hsic_scale: Scalar multiplier of the HSIC penalty. :type hsic_scale: float :param n_latent_sub: Number of latent dimensions for each subspace. :type n_latent_sub: list of int :param predict_target_from_latent_sub: Whether to predict target variables from the latent space. :type predict_target_from_latent_sub: bool :param target_supervision_list: List of SupervisionAnnData objects if predict_target_from_latent_sub is True. :type target_supervision_list: list of SupervisionAnnData .. py:attribute:: gene_likelihood :value: 'normal' .. py:attribute:: hsic_scale :value: 1.0 .. py:attribute:: n_latent_sub :value: [10, 10] .. py:attribute:: n_subspace .. py:attribute:: predict_target_from_latent_sub :value: False .. py:attribute:: target_supervision_list :value: None .. py:method:: predict(x, use_posterior_mean=False) Forward passing through the encoder and run prediction. :param x: input tensor :type x: tensor :param use_posterior_mean: whether to use the posterior mean of the latent distribution for prediction :type use_posterior_mean: bool .. py:method:: prediction_loss(labelled_dataset: dict[str, torch.Tensor]) Calculate the mean squared error loss for the QC signal prediction. .. py:method:: generative(z, library, batch_index, cont_covs=None, cat_covs=None, size_factor=None, y=None, transform_batch=None) Run the generative process. .. py:method:: loss(tensors, inference_outputs, generative_outputs, kl_weight: float = 1.0, labelled_tensors: dict[str, torch.Tensor] | None = None) .. py:class:: HCVI(adata: anndata.AnnData, n_hidden: int = 128, n_layers: int = 1, dropout_rate: float = 0.1, gene_likelihood: Literal['zinb', 'nb', 'poisson', 'normal'] = 'normal', hsic_scale: float = 1.0, n_latent_sub=[10, 10], predict_target_from_latent_sub: bool = False, target_supervision_list: list[SupervisionAnnData] | None = None, **model_kwargs) Bases: :py:obj:`scvi.model.SCVI` Training a HSIC-regulated VAE model with scvi-tools. :param hsic_scale: Scalar multiplier of the HSIC penalty. :type hsic_scale: float :param n_latent_sub: Number of latent dimensions for each subspace. :type n_latent_sub: list of int :param predict_target_from_latent_sub: Whether to predict target variables from the latent space. :type predict_target_from_latent_sub: bool :param target_supervision_list: List of SupervisionAnnData objects if predict_target_from_latent_sub is True. :type target_supervision_list: list of SupervisionAnnData .. py:attribute:: _module_cls .. py:attribute:: predict_target_from_latent_sub :value: False .. py:attribute:: n_latent_sub :value: [10, 10] .. py:attribute:: n_subspace .. py:attribute:: target_key_and_type :value: None .. py:attribute:: n_target .. py:attribute:: module .. py:attribute:: unsupervised_history_ :value: None .. py:attribute:: semisupervised_history_ :value: None .. py:attribute:: _model_summary_string :value: Multiline-String .. raw:: html
Show Value .. code-block:: python """HCVI model with the following parameters: ------------------------------------------ *(architecture): n_layers = 1, dropout_rate = 0.1, gene_likelihood = normal *(subspace) n_subspace = Uninferable, n_latent_sub = List.list(ctx=, elts=[ , ]), hsic_scale = 1.0 *(supervision) predict_target = False, n_target = Uninferable""" .. raw:: html
.. py:attribute:: init_params_ .. py:attribute:: was_pretrained :value: False .. py:method:: train(max_epochs: int | None = None, n_samples_per_label: float | None = None, check_val_every_n_epoch: int | None = None, train_size: float = 0.9, validation_size: float | None = None, shuffle_set_split: bool = True, batch_size: int = 128, accelerator: str = 'auto', devices: int | list[int] | str = 'auto', datasplitter_kwargs: dict | None = None, plan_kwargs: dict | None = None, **trainer_kwargs) Trains the model using SCVI. .. py:method:: setup_anndata(adata: anndata.AnnData, layer: str | None = None, target_supervision_list: list[SupervisionAnnData] | None = None, batch_key: str | None = None, labels_key: str | None = None, size_factor_key: str | None = None, categorical_covariate_keys: list[str] | None = None, continuous_covariate_keys: list[str] | None = None, **kwargs) :classmethod: %(summary)s. :param %(param_adata)s: :param %(param_layer)s: :param %(param_batch_key)s: :param %(param_labels_key)s: :param %(param_size_factor_key)s: :param %(param_cat_cov_keys)s: :param %(param_cont_cov_keys)s: