plot_motifs: Plot CDR3 sequence motifs

View source: R/cluster-seqs.R

plot_motifsR Documentation

Plot CDR3 sequence motifs

Description

Plot CDR3 sequence motifs

Usage

plot_motifs(
  input,
  data_col = global$cdr3_col,
  cluster_col = NULL,
  chain,
  chain_col = global$chain_col,
  width = 0.75,
  align_end = "5",
  quiet = FALSE,
  sep = global$sep,
  plot_colors = NULL,
  plot_lvls = names(plot_colors),
  panel_nrow = NULL,
  panel_scales = "free",
  n_label = "corner",
  label_params = list(),
  ...
)

Arguments

input

Single cell object or data.frame containing V(D)J data. If a data.frame is provided, the cell barcodes should be stored as row names.

data_col

meta.data column containing sequences to use for plotting.

cluster_col

meta.data column containing cluster IDs to use for grouping cells.

chain

Chain to use for plotting sequences. Cells with more than one of the provided chain will be excluded from the analysis.

chain_col

meta.data column containing chains for each cell.

width

Integer specifying how many residues to include, sequences longer than width will be get trimmed based on the align_end argument, sequences shorter than width will get removed. If a fraction is provided, the width cutoff is set based on percent rank, i.e. a value of 0.75 would select a width where at least 75% of sequences are longer than the cutoff.

align_end

End to use for aligning sequences, specify '5' or '3' to align sequences at the 5' or 3' end when plotting.

quiet

If TRUE messages will not be displayed

sep

Separator used for storing per cell V(D)J data

plot_colors

Character vector containing colors for plotting

plot_lvls

Character vector containing levels for ordering

panel_nrow

The number of rows to use for arranging plot panels

panel_scales

Should scales for plot panels be fixed or free. This passes a scales specification to ggplot2::facet_wrap(), can be 'fixed', 'free', 'free_x', or 'free_y'. 'fixed' will cause panels to share the same scales. Use this when separate bar graphs are created for each cell cluster.

n_label

Location on plot where n label should be added, this can be one of the following:

  • 'corner', display the total number of cells plotted in the top right corner, the position of the label can be modified by passing x and y specifications with the label_params argument

  • 'none', do not display the number of cells plotted

label_params

Named list providing additional parameters to modify n label aesthetics, e.g. list(size = 4, color = "red")

...

Additional parameters to pass to ggseqlogo::geom_logo()

Value

ggplot object

See Also

cluster_sequences()

Examples

# Cluster cells based on CDR3 amino acid sequences and plot sequence motifs
res <- cluster_sequences(
  vdj_sce,
  data_col = "cdr3"
)

plot_motifs(
  res,
  data_col    = "cdr3",
  cluster_col = "cdr3_cluster_0.5",
  chain       = "IGK"
)


rnabioco/djvdj documentation built on Oct. 24, 2023, 7:33 p.m.