mira.topics.gradient_tune#

mira.topics.gradient_tune(model, data, max_attempts=3, max_topics=None)#

Tune number of topcis using a gradient-based estimator based on the Dirichlet Process model. This tuner is very fast, though less comprehensive than the BayesianTuner. We recommend using this tuner for large datasets (>40K cells).

Parameters
modelmira.topics.TopicModel

Topic model to tune. The provided model should have columns specified to retrieve endogenous and exogenous features, and should have the learning rate configued by get_learning_rate_bounds.

dataanndata.AnnData

Anndata of expression or accessibility data.

max_topicsint > 0 or None

If none, MIRA automatically chooses an upper limit on the number of topics to model based on a generous hueristic calculated from the number of cells in the provided dataset. If a value is provided, that upper limit is used instead.

Returns
num_topicsint

Estimated number of topics in dataset

max_topic_contributionsnp.ndarray[float] of shape (n_topics,)

For each topic attempted to learn from the data, its maximum contribution to any cell.