annotation_heatmap: Annotation Heatmap

annotation_heatmapR Documentation

Annotation Heatmap

Description

This is a generic plotting utility (not specific to topic the model) for comparing “effects” across multiple dimensions (e.g., topics). The function has several options for selecting the features to compare.

Usage

annotation_heatmap(
  effects_matrix,
  select_features = c("largest", "distinctive", "both", "all"),
  feature_sign = c("both", "positive", "negative"),
  dims = colnames(effects_matrix),
  compare_dims = colnames(effects_matrix),
  n = 2,
  show_dims = colnames(effects_matrix),
  zero_value = 0.01,
  font_size = 10,
  verbose = TRUE
)

Arguments

effects_matrix

n x d numeric matrix, where n is the number of features and d is the number of dimensions. This could be for example the word frequencies matrix F from a multinomial topic model fitted using fit_topic_model. The row and columns of this matrix must be named, otherwise this function will throw and error.

select_features

This may be a character vector specifying the features to plot (rows of the effects matrix). Or it may be one of the following: "largest", which automatically selects the largest effects for each chosen dimension; "distinctive", which automatically selects the “most distinctive” effects for each chosen dimension; or "both", which uses both criteria to select features. Distinctive features are defined as rows of the effects matrix that are much larger in magnitude than the effects in the other dimensions that also share the same sign.

feature_sign

For automated selection of features, this option determines whether to consider positive effects only ("positive"), negative effects only ("negative"), or both ("both").

dims

The dimensions (columns of the effect matrix) to consider for automatic feature selection. This should be dimension names (not numbers).

compare_dims

This should be dimension names (not numbers).

n

For automated feature selection, the number of features to select of each type and for each dimension. (see arguments select_features and feature_sign).

show_dims

The dimensions (columns) to include in the plot. This should be dimension names (not numbers).

zero_value

Numbers smaller than zero_value (in magnitude) are not shown in the plot.

font_size

Specifies the font size for the plot.

verbose

When verbose = TRUE, the list of selected features (rows) is printed.

Value

A ggplot object.

Examples

data(newsgroups)
p1 <- annotation_heatmap(newsgroups$F,feature_sign = "positive")


stephenslab/fastTopics documentation built on March 29, 2025, 3:24 p.m.