mtopic.pl.filter_topics

Contents

mtopic.pl.filter_topics#

mtopic.pl.filter_topics(model, s=50, figsize=(8, 6), fontsize=10, transparent=False, save=None)#

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

This function generates a scatter plot to show the maximum probability of each topic across all cells. Topics with higher maximum probabilities represent significant patterns in the dataset, while topics with low maximum probabilities might be less informative or represent noise. The plot includes a suggested threshold line (default at y=0.01) to help identify insignificant topics for filtering in downstream analysis.

Parameters:
  • model (mtopic.tl.MTM or mtopic.tl.sMTM) – An instance of the topic model (e.g., mtopic.tl.MTM or mtopic.tl.sMTM) containing the topic distributions (gamma) to analyze.

  • s (int, optional) – Marker size for the scatter plot. Default is 50.

  • figsize (tuple, optional) – Tuple specifying the size of the figure (width, height) in inches. Default is (8, 6).

  • fontsize (int, optional) – Font size for plot labels and annotations. Default is 10.

  • transparent (bool, optional) – Whether to save the figure with a transparent background. Default is False.

  • save (str, optional) – Path to save the figure. If None, the figure is displayed but not saved. Default is None.

Returns:

None

Example:
import mtopic

# Assuming `model` is an instance of mtopic.tl.MTM or mtopic.tl.sMTM
mtopic.pl.filter_topics(model, s=50, figsize=(8, 6), fontsize=10, save='filter_topics.png')