Skip to contents

Builds a Trelliscope display from a panel tibble, writing the application to path and returning the htmlwidget. The trelliscopejs package is in Suggests, and a call without it installed is an error.

Usage

precise_trellis(
  data,
  path = NULL,
  panel_col = "panel",
  key_col = NULL,
  name = "PreciseViz panels",
  group = "common",
  desc = "",
  height = 500,
  width = 500
)

Arguments

data

A tibble with a list-column of panels, normally the output of precise_viz().

path

The directory to write the Trelliscope application into. NULL lets the backend choose a temporary directory.

panel_col

The name of the panel list-column. The default is "panel", which is what precise_viz() produces.

key_col

NULL for automatic selection, or one column name to use as the panel key. See Details.

name

Display name.

group

Display group.

desc

Display description.

height, width

Panel height and width in pixels.

Value

The Trelliscope htmlwidget. Printing it opens the display, and returning it from a knitr chunk embeds it.

Cognostics

Every non-list column becomes a cognostic, which is Trelliscope's per-panel summary value used for sorting and filtering. For a precise_viz() result this includes panel_id, input, view, input_type, panel_class, and time_taken_seconds, any provenance columns such as metric or graph_method, any columns attached through the diagnostics= argument of precise_viz(), and any column added to the tibble beforehand.

Numeric, integer, character, factor, Date, and POSIXct columns keep their type, so numeric cognostics remain numerically sortable and filterable. Two cases are written as text: the key column, which must stay stable, and logical columns, written as "TRUE" and "FALSE" because the backend has no logical cognostic type and would otherwise drop the column. Any other scalar class is also written as text.

Key column

The key column identifies rows in the display and must be a scalar column with one non-missing, unique value per row. key_col = NULL selects the first column satisfying that among "input", "panel_id", and "descriptor", and errors when none qualifies. An explicitly supplied key_col that is missing or not unique is an error.

Panel sizing

height and width are passed to the backend unchanged. The returned widget uses 100 percent width and a height of max(700, height + 240) pixels.

Author

Brian Muchmore

Examples

if (requireNamespace("trelliscopejs", quietly = TRUE)) {
  data(data_cell_cycle, package = "PreciseViz")

  cells <- c(1:4, 60:63, 118:121)
  cell_cycle <- as.matrix(data_cell_cycle[cells, 2:41])
  rownames(cell_cycle) <- paste0(data_cell_cycle$Cell_cycle[cells], "_", cells)

  typed <- tibble::tibble(
    distance = c("euclidean", "manhattan"),
    matrix = list(
      as.matrix(stats::dist(cell_cycle)),
      as.matrix(stats::dist(cell_cycle, method = "manhattan"))
    ),
    type = "distance"
  )

  panels <- precise_viz(typed, views = "heatmap", verbose = FALSE)

  app <- tempfile("precise_trellis_")
  widget <- precise_trellis(panels, path = app, name = "cell_cycle_heatmaps")
  class(widget)
  DONTSHOW({unlink(app, recursive = TRUE)})
}