Skip to contents

Convenience wrapper around get_chromosome_plot() for expression-based colouring (optional group mean, rowData columns, or assay columns).

Usage

get_expression_chromosome_plot(
  x,
  txdb,
  keytype = "GENEID",
  id_column = NULL,
  genes = NULL,
  value_column = NULL,
  value_from = c("rowdata", "assay"),
  value_assay = "norm_counts",
  facet_value_columns = FALSE,
  group_value = NULL,
  label_top_n = 20,
  display_id = NULL,
  line_length = 0.02,
  line_width = 0.6,
  filter_chrom = NULL,
  log_transform = TRUE,
  value_label = "log2(mean expr)"
)

Arguments

x

A VISTA object.

txdb

A TxDb object (e.g., from GenomicFeatures).

keytype

Key type in the TxDb matching id_column (default "GENEID").

id_column

Optional column in rowData(x) used to match to TxDb keys. When NULL, rownames(x) are used as keys.

genes

Optional character vector of gene IDs to label (alternative to label_top_n). When provided, all genes are plotted but only these are labeled. Defaults to NULL (no explicit label set).

value_column

Optional column in rowData(x) used for colouring.

value_from

Source for value_column data: "rowdata" (default) or "assay". When "assay", the selected assay column is copied into rowData temporarily for colouring.

value_assay

Assay name to pull values from when value_from = "assay". Default "norm_counts".

facet_value_columns

Ignored (kept for compatibility); multiple value_columns are always arranged in a chromosome-by-column grid.

group_value

Optional group label (from group_column); when supplied, uses mean expression for that group for colouring (assay norm_counts).

label_top_n

Integer; number of genes with largest |value| (or random if no value) to label. Ignored when genes is provided. Set to 0 to disable labels.

display_id

Optional column in rowData(x) to use for point labels (fallback to gene_id/rownames).

line_length

Horizontal half-length (in megabases) of the tick used to mark each gene position. Default 0.02. Increase for longer ticks.

line_width

Line width of the tick marks. Default 0.6.

filter_chrom

Optional character vector of chromosomes to keep (e.g., c("chr1","chr2")). When NULL, all chromosomes returned by the TxDb are shown.

log_transform

Logical; when group_value is used (and value_column is NULL), apply log2(x + 1) before coloring.

value_label

Optional legend title override for the colour scale.

Value

A ggplot2 object or a list of ggplot2 objects when multiple value_columns are provided and patchwork is unavailable.

Details

  • If multiple value_columns are supplied, one plot is produced per column with its own colour legend titled by that column. Chromosomes are laid out top-down in a single column: for each chromosome, plots for all value_columns appear sequentially. Legends for each column are shown on the first occurrence of that column. Requires patchwork; otherwise a list of plots is returned.

  • Labels are kept consistent across value_columns: if genes is provided it is used for all panels; otherwise the top label_top_n (by absolute value in the first value_column) are used for all panels.

  • When value_from = "assay", the specified assay column is copied into rowData on the fly so it can be used for colouring.

  • When group_value is provided (and no value_column), colouring is based on log2 mean expression for that group (assay norm_counts), using a data-driven colour scale. Ignored when value_column is supplied.