scvi_criticism.PPC#

class scvi_criticism.PPC(n_samples=1, raw_counts=None)#

Posterior predictive checks for comparing single-cell generative models

Parameters
  • n_samples (int (default: 1)) – Number of posterior predictive samples to generate

  • raw_counts (Union[ndarray, csr_matrix, coo_matrix, None] (default: None)) – Raw counts matrix (cells x genes) as a numpy array, scipy coo_matrix, or scipy csr_matrix

Methods table#

coefficient_of_variation([cell_wise])

Calculate the coefficient of variation (CV) for each model and the raw counts.

diff_exp(adata_obs_raw, adata_var_raw, ...)

Compute differential expression (DE) metrics.

mann_whitney_u()

Calculate the Mann-Whitney U test between each model and the raw counts.

store_posterior_predictive_samples(models_dict)

Store posterior predictive samples for each model.

Methods#

coefficient_of_variation#

PPC.coefficient_of_variation(cell_wise=True)#

Calculate the coefficient of variation (CV) for each model and the raw counts.

Parameters

cell_wise (bool (default: True)) – Whether to calculate the CV cell-wise or gene-wise.

diff_exp#

PPC.diff_exp(adata_obs_raw, adata_var_raw, de_groupby, de_method='t-test', var_gene_names_col=None, n_top_genes=None, n_top_genes_overlap=None)#

Compute differential expression (DE) metrics.

Parameters
  • adata_obs_raw (DataFrame) – The obs dataframe from the raw AnnData object.

  • adata_var_raw (DataFrame) – The var dataframe from the raw AnnData object.

  • de_groupby (str) – The column name in adata_obs_raw that contains the groupby information.

  • de_method (str (default: 't-test')) – The DE method to use. See rank_genes_groups() for more details.

  • var_gene_names_col (Optional[str] (default: None)) – The column name in adata_var_raw that contains the gene names. If None, then adata_var_raw.index is used.

  • n_top_genes (Optional[int] (default: None)) – The number of top genes to use for the DE analysis. If None, then the default value DEFAULT_DE_N_TOP_GENES is used.

  • n_top_genes_overlap (Optional[int] (default: None)) – The number of top genes to use for the DE analysis when computing the gene overlap metrics. If None, then the default value DEFAULT_DE_N_TOP_GENES_OVERLAP is used.

mann_whitney_u#

PPC.mann_whitney_u()#

Calculate the Mann-Whitney U test between each model and the raw counts.

store_posterior_predictive_samples#

PPC.store_posterior_predictive_samples(models_dict, batch_size=32, indices=None)#

Store posterior predictive samples for each model.

Parameters
  • models_dict – Dictionary of models to store posterior predictive samples for.

  • batch_size – Batch size for generating posterior predictive samples.

  • indices – Indices to generate posterior predictive samples for.