Skip to contents

Generate an interactive word cloud showing the relative frequencies of V, D, or J genes in a single repertoire. Gene names are sized proportionally to their frequency, making it easy to identify dominant gene usage patterns.

Usage

geneWordCloud(
  gene_freq_table,
  repertoire_id,
  colors = NULL,
  shape = "circle",
  size = 1
)

Arguments

gene_freq_table

A tibble from geneFreq() containing gene frequency data

repertoire_id

Character string specifying which repertoire to visualize. Must match a repertoire_id in the gene_freq_table.

colors

Character vector of colors for the word cloud. Default uses a blue-red gradient. Can specify any valid R colors or use RColorBrewer palettes.

shape

Shape of the word cloud. Options: "circle" (default), "cardioid", "diamond", "triangle", "pentagon", "star". See wordcloud2 documentation for details.

size

Scaling factor for word sizes. Default is 1. Increase for larger words, decrease for smaller words.

Value

A wordcloud2 htmlwidget object showing gene frequencies. The size of each gene name corresponds to its frequency in the repertoire.

Details

This function creates an interactive word cloud where:

  • Gene name size reflects frequency (larger = more frequent)

  • Hover over genes to see exact frequencies

  • Color gradient helps distinguish different genes

Word clouds are useful for:

  • Quick visual assessment of dominant gene usage

  • Identifying gene family bias in a repertoire

  • Comparing gene usage across samples (create multiple clouds)

Note: The wordcloud2 package must be installed to use this function.

Examples

if (FALSE) { # \dontrun{
file_path <- system.file("extdata", "TCRB_sequencing",
 package = "LymphoSeq2")
study_table <- LymphoSeq2::readImmunoSeq(path = file_path, threads = 1)
study_table <- LymphoSeq2::topSeqs(study_table, top = 100)
nucleotide_table <- LymphoSeq2::productiveSeq(
  study_table = study_table,
  aggregate = "junction"
)

# Generate V gene frequencies
v_genes <- LymphoSeq2::geneFreq(nucleotide_table, locus = "V", family = TRUE)

# Create word cloud for one sample
LymphoSeq2::geneWordCloud(v_genes, repertoire_id = "TRB_Unsorted_83")

# Customize colors
LymphoSeq2::geneWordCloud(v_genes,
  repertoire_id = "TRB_Unsorted_83",
  colors = c("darkgreen", "gold", "darkred"))
} # }