Skip to contents

Renders an A3 object (from rtemis.a3) as an interactive ECharts amino-acid sequence diagram. The sequence is wrapped into rows in a meander/serpentine path, with optional site, region, PTM, processing, and variant annotations overlaid as distinct series and collected in a vertical legend.

Usage

draw_a3(
  x,
  n_per_row = 21L,
  residue_spacing = 0.3,
  marker_size = 28,
  font_size = 18,
  line_width = 2,
  show_markers = TRUE,
  show_labels = TRUE,
  position_every = 10L,
  region_opacity = 0.35,
  ptm_placement = "radial",
  residue_fill = "#E7E5E4",
  residue_stroke = "#44403C",
  label_color = "#1C1917",
  pos_label_color = "#78716C",
  variant_color = "#FA6E1E",
  disease_variant_color = "#E266AE",
  enable_zoom = TRUE,
  title = NULL,
  grid = NULL,
  theme = NULL,
  width = NULL,
  height = NULL,
  filename = NULL
)

Arguments

x

A3 object from rtemis.a3::create_A3() or rtemis.a3::read_A3json().

n_per_row

Integer [2, Inf): Number of residues per wrapped row.

residue_spacing

Numeric (0, Inf): Horizontal spacing multiplier. Values below 1 compress the layout; 1 gives natural hex spacing.

marker_size

Numeric (0, Inf): Residue circle diameter in pixels.

font_size

Numeric (0, Inf): Base font size in pixels for residue and position labels.

line_width

Numeric (0, Inf): Backbone line width in pixels.

show_markers

Logical: Whether to render the backbone line and residue circles.

show_labels

Logical: Whether to render single-letter residue labels.

position_every

Optional Integer [1, Inf): Show a numeric position label every N residues. NULL disables position labels.

region_opacity

Numeric [0, 1]: Opacity of region band overlays.

ptm_placement

Character {"radial", "innerRadial", "outerRadial"}: Placement of PTM symbols relative to the residue circle. "radial" centres on the circle edge; "innerRadial" places inside; "outerRadial" places outside.

residue_fill

Character: Residue circle fill color.

residue_stroke

Character: Residue circle stroke and backbone line color.

label_color

Character: Default residue label text color.

pos_label_color

Character: Position label text color.

variant_color

Character: Label color for variant residues.

disease_variant_color

Character: Label color for disease-associated variant residues (takes precedence over variant_color).

enable_zoom

Logical: Whether to enable Shift+scroll zoom.

title

Optional Character: Chart title.

grid

Optional Grid: Override any plot-area margin. The defaults (left = 24, top auto, right driven by legend width, bottom = 24) are merged with the properties of the supplied Grid object, so only the fields you set are changed — e.g. Grid(left = 8, top = 8). legend_top is re-derived from the final grid top automatically.

theme

Optional Theme: Theme override. NULL auto-detects light/dark mode; NA uses raw ECharts defaults.

width

Optional Numeric or Character: Widget width.

height

Optional Numeric or Character: Widget height. Auto-computed from layout bounds and marker_size when NULL.

filename

Optional Character: If provided, save the widget to this file via save_drawing().

Value

htmlwidget: Widget object.

Details

Corresponds to createA3EChartsOption() in src/lib/a3/visualization/echarts.ts.

Examples

if (requireNamespace("rtemis.a3", quietly = TRUE)) {
  a <- rtemis.a3::create_A3(
    "MAEPRQEFEVMEDHAGTYGLGDRK",
    site = list(
      Active_site = rtemis.a3::annotation_position(c(5L, 17L))
    ),
    region = list(
      Domain = rtemis.a3::annotation_range(
        matrix(c(3L, 10L, 15L, 22L), ncol = 2, byrow = TRUE)
      )
    )
  )
  draw_a3(a)
}