API#

Import mTopic:

import mtopic

Core submodules#

Data reading (read)#

mtopic.read.h5mu(path)

Load a MuData object from an .h5mu file.

Preprocessing (pp)#

mtopic.pp.permute(mdata[, subset, seed, copy])

Randomly permute the count matrices in a MuData object.

mtopic.pp.tfidf(mdata, mod[, copy, ...])

Apply Term Frequency-Inverse Document Frequency (TF-IDF) transformation to a specific modality in a MuData object.

mtopic.pp.clr(mdata, mod[, copy, ...])

Perform Centered Log-Ratio (CLR) normalization on a modality in a MuData object.

mtopic.pp.scale_counts(mdata[, ...])

Scale count matrices to normalize the total sum of counts across modalities.

mtopic.pp.filter_var_knee(path, model[, ...])

Filter overrepresented features from a MuData object using a knee detection algorithm.

mtopic.pp.filter_var_list(path, var)

Retain a specific list of features in a MuData object.

mtopic.pp.feature_associations_data(mdata, ...)

Prepare feature signatures for training feature associations.

Tools (tl)#

mtopic.tl.MTM(mdata[, n_topics, seed, ...])

Multimodal Topic Model.

mtopic.tl.MTM_GPU(mdata[, n_topics, seed, ...])

GPU-accelerated Multimodal Topic Model.

mtopic.tl.sMTM(mdata[, n_topics, radius, ...])

Spatial Multimodal Topic Model.

mtopic.tl.sMTM_GPU(mdata[, n_topics, ...])

GPU-accelerated Spatial Multimodal Topic Model.

mtopic.tl.export_params(model, mdata[, ...])

Export topic-cell and feature-topic distributions to a MuData object and filter insignificant topics.

mtopic.tl.zscores(mdata, raw_data_path[, ...])

Compute z-scores for feature signatures.

mtopic.tl.umap(mdata[, x, umap, ...])

Perform UMAP dimensionality reduction on topic distributions.

mtopic.tl.feature_associations(A, A_var, B, ...)

Cross-modality feature associations.

mtopic.tl.select_n_topics(mdata[, Ks, ...])

K-fold cross-validation for MTM and sMTM via held-out log-likelihood to estimate the optimal number of topics.

Plotting (pl)#

mtopic.pl.select_n_topics(mdata, *[, ...])

Fit a rational function to the mean held-out log-likelihood curve and identify the optimal number of topics.

mtopic.pl.filter_var_knee(model, mod[, ...])

Detect and visualize overrepresented features using a knee detection algorithm.

mtopic.pl.filter_topics(model[, s, figsize, ...])

Visualize the significance of topics based on their maximum probability across cells.

mtopic.pl.topics(mdata, x[, topics, cmap, ...])

Visualize topic distributions on spatial coordinates or embedding.

mtopic.pl.scatter_pie(mdata[, topics, x, ...])

Create a scatter plot with pie charts representing topic distributions at each cell/spot coordinate.

mtopic.pl.dominant_topics(mdata, x[, ...])

Visualize the dominant topic for each cell/spot in a MuData object.

mtopic.pl.signatures(mdata, mod[, ...])

Visualize the feature signatures for each topic in a specified modality of a MuData object.

mtopic.pl.zscores(mdata, mod, x[, zscores, ...])

Visualize the spatial or embedding-based distribution of z-scores for topics in a specified modality.

mtopic.pl.corr_heatmap(arr1, arr2[, label1, ...])

Visualize the correlation matrix between two sets of features as a heatmap.

mtopic.pl.feature_activity(mdata, x, features)

Visualize the distribution of specified features in a MuData object.