Skip to contents

A config-driven genome-visualization widget powered by Gosling.js, the grammar of scalable, linked, interactive nucleotide graphics. Rendering is fully declarative: you pass a Gosling specification (an R list serialized to JSON) and data flows through the spec's own data blocks (tileset URLs, indexed BAM/BED/VCF/BigWig, or CSV/JSON URLs and inline values). Gosling streams and tiles large genomic datasets on the GPU via HiGlass, so no separate data argument is needed.

Usage

gosling(
  spec,
  padding = NULL,
  theme = NULL,
  width = NULL,
  height = NULL,
  element_id = NULL
)

Arguments

spec

A Gosling specification as a (nested) named list. It is passed through verbatim to Gosling.js after JSON serialization, so option keys use Gosling's own camelCase names (e.g. tracks, xDomain, alignment). Must contain at least one of tracks, views, arrangement, alignment or template.

padding

Optional outer padding (pixels) forwarded to Gosling's embed options.

theme

Optional Gosling theme: a built-in name (e.g. "dark") or a theme list.

width, height

Widget dimensions (any valid CSS size).

element_id

Optional explicit DOM id.

Value

An htmlwidget object.

Examples

spec <- list(
  title = "Example track",
  tracks = list(list(
    data = list(
      url = paste0(
        "https://server.gosling-lang.org/api/v1/tileset_info/",
        "?d=cistrome-multivec"
      ),
      type = "multivec",
      row = "sample",
      column = "position",
      value = "peak",
      categories = list("sample 1")
    ),
    mark = "bar",
    x = list(field = "start", type = "genomic"),
    xe = list(field = "end", type = "genomic"),
    y = list(field = "peak", type = "quantitative"),
    width = 700, height = 200
  ))
)
gosling(spec)