
Chromosome plot for expression
get_expression_chromosome_plot.RdConvenience 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,
sample_group = NULL,
group_column = NULL,
value_column = NULL,
value_from = c("rowdata", "assay"),
value_assay = "norm_counts",
facet_value_columns = FALSE,
side_by_side_groups = FALSE,
paginate = TRUE,
panels_per_page = 24,
summarise_replicates = FALSE,
summarise_method = c("mean", "median"),
group_value = NULL,
label_n = 20,
label_genes = c("top", "all", "none"),
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
VISTAobject.- 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. WhenNULL, 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 toNULL(no explicit label set).- sample_group
Optional character vector of groups (from
group_column) used to subset assay columns whenvalue_from = "assay".- group_column
Optional column name in
sample_infoused forsample_groupselection and replicate summarisation.- value_column
Optional column in
rowData(x)used for colouring.- value_from
Source for
value_columndata:"rowdata"(default) or"assay". When"assay", the selected assay column is copied intorowDatatemporarily 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.- side_by_side_groups
Logical; when plotting multiple
value_columns, arrange one row per chromosome with one panel per selected sample/group. This is useful for direct side-by-side group comparison.- paginate
Logical; when
TRUE, split large multi-panel chromosome plots into pages to avoid patchwork viewport-size errors.- panels_per_page
Maximum number of panels per page when
paginate = TRUE. Set toNULLto disable automatic paging.- summarise_replicates
Logical; when
TRUEandvalue_from = "assay", aggregate replicates bygroup_columnbefore plotting.- summarise_method
"mean"or"median"summarisation used whensummarise_replicates = TRUE.- group_value
Optional group label (from
group_column); when supplied, uses mean expression for that group for colouring (assaynorm_counts).- label_n
Integer; number of genes with the largest absolute values to label when
genesis not supplied. Set to 0 to disable automatic labels.- label_genes
One of
"top"(default),"all", or"none"controlling chromosome text labels whengenesis not supplied.- 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")). WhenNULL, all chromosomes returned by the TxDb are shown.- log_transform
Logical; when
group_valueis used (andvalue_columnisNULL) or whenvalue_from = "assay", 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 allvalue_columns appear sequentially. Legends for each column are shown only on the first occurrence (at the bottom) to avoid overlap. Requires patchwork; otherwise a list of plots is returned.Set
side_by_side_groups = TRUEto place selected groups/samples in separate columns for each chromosome (same-row comparison).paginate = TRUEautomatically splits large panel collections into a list of patchwork pages, which prevents "viewport too small" rendering errors in IDE plot panes.For
value_from = "assay", colours follow the VISTA ecosystem: group colours are used whensummarise_replicates = TRUE, while sample colours are derived from group colours when plotting individual replicates.For
value_from = "assay"withvalue_column = NULL, all selected assay columns are used (samples aftersample_groupfiltering, or groups after replicate summarisation).Labels are kept consistent across
value_columns: ifgenesis provided it is used for all panels; otherwise the toplabel_n(by absolute value in the firstvalue_column) are used for all panels.When
value_from = "assay", the specified assay column is copied intorowDataon the fly so it can be used for colouring.When
group_valueis provided (and novalue_column), colouring is based on log2 mean expression for that group (assaynorm_counts), using a data-driven colour scale. Ignored whenvalue_columnis supplied.
Examples
v <- example_vista()
p <- try(get_expression_chromosome_plot(v), silent = TRUE)
if (!inherits(p, 'try-error')) print(p)