- class locat.locat_condensed.LOCAT(adata: AnnData, cell_embedding: ndarray, k: int, n_bootstrap_inits: int, show_progress=False, wgmm_dtype: str = 'same', knn=None, knn_k: int | None = None, knn_mode: str = 'binary')[source]#
Bases:
objectThe main LOCAT class
- Attributes:
- X
- cell_dist
- min_dist
Methods
background_n_components_init([...])bic_score(gmm1, gene_prior)calc_lratio(f1, ix, log_bkg_pdf, sample_size)Per-cell LRT contribution on expressing cells:
estimate_null_parameters([fractions, n_reps])Estimate LTST null mean/std as a function of expression fraction p using random pseudo-genes: - pick random expressing cells at frequency p - fit signal GMM with the same pipeline as real genes - compute LTST exactly as in gmm_scan_new
get_genes_indices(genes)knn()Return a KNN adjacency/connectivity matrix.
localization_pval_dep_scan(gmm1, gene_prior, *)set_knn(knn)Store a precomputed KNN graph.
auto_bkg_components
auto_n_components
background_pdf
fit_wgmm
get_gene_prior
gmm_local_pvalue
gmm_local_scan
gmm_loglikelihoodtest
gmm_scan_new
random_pdf
reg_covar
show_progress
signal_gmm
signal_pdf
- background_pdf(n_comp=None, reps=10, total_counts_weight=True, weights_transform=None, force_refresh=False)[source]#
- static calc_lratio(f1, ix, log_bkg_pdf, sample_size, eps=1e-300)[source]#
- Per-cell LRT contribution on expressing cells:
-2 * sum_{i in ix} ( log f0(i) - log f1(i) ) / sample_size
- estimate_null_parameters(fractions=None, n_reps=50)[source]#
Estimate LTST null mean/std as a function of expression fraction p using random pseudo-genes:
pick random expressing cells at frequency p
fit signal GMM with the same pipeline as real genes
compute LTST exactly as in gmm_scan_new
- gmm_local_pvalue(genes=None, n_comp=None, weights_transform=None, alpha=0.05, n_inits=100, normalize_knn=True, eps=1e-12)[source]#
- gmm_scan_new(genes=None, weights_transform=None, zscore_thresh=None, max_freq=0.5, verbose=False, n_bootstrap_inits=None, rc_c_values=None, rc_min_p0_abs=0.1, rc_min_expected=30, rc_min_abs_deficit=0.02, rc_n_trials_cap=500, rc_soft_bound=1.0, rc_n_eff_scale=0.5, rc_p_floor=1e-12, rc_rho_bb=0.02, rc_weight_mode='amount', rc_eps_rel=0.01)[source]#
- knn()[source]#
Return a KNN adjacency/connectivity matrix.
If a KNN was provided at init (or via set_knn), returns it. Otherwise computes one from the embedding.
- localization_pval_dep_scan(gmm1, gene_prior, *, c_values=None, soft_bound=None, min_p0_abs=0.1, min_expected=30, min_abs_deficit=0.02, n_trials_cap=500, weight_mode='amount', p_floor=1e-12, n_eff_scale=1.0, rho_bb=0.2, eps_rel=0.01, debug=False, debug_store_masks=False, debug_max_cells=5000)[source]#
- class locat.locat_condensed.LOCATNullDistribution(mean_func, std_func)[source]#
Bases:
object- Attributes:
- mean
- std
Methods
from_estimates
to_zscore
- locat.locat_condensed.cauchy_combine(pvals, weights=None)[source]#
Robust p-value combiner for dependent tests (Cauchy combination). Liu & Xie (2020).
- locat.locat_condensed.localization_pvalue_nn_func(x1, f1, f0, nn)[source]#
Sparse-safe rewrite of the original localization_pvalue_nn_func.
- Preserves:
i1/obs1/obs2 definitions
n and o as neighborhood (weighted) counts / signed balance
f2 weighting for global mu_hat, p1, p0
effective_n, sd_hat
per-cell p via normal_sf(o[i], mu_hat, sd_hat[i])
- Works for:
nn sparse CSR/CSC/COO
nn dense numpy array