VitessceConfig: VitessceConfig Class

VitessceConfigR Documentation

VitessceConfig Class

Description

Class representing a Vitessce view config.

Details

VitessceConfig

Public fields

config

The internal representation of the view config.

base_dir

The base directory for the config.

Methods

Public methods


Method new()

Create a new config object.

Usage
VitessceConfig$new(schema_version, name = NA, description = NA, base_dir = NA)
Arguments
schema_version

The Vitessce config schema version to use.

name

A name for the config.

description

A description for the config.

Returns

A new VitessceConfig object.


Method add_dataset()

Add a dataset to the config.

Usage
VitessceConfig$add_dataset(name, uid = NA)
Arguments
name

A name for the dataset.

uid

A unique ID for the dataset. Optional. Created automatically if not provided.

Returns

A new VitessceConfigDataset object.

Examples
vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
ds <- vc$add_dataset("My dataset")

Method add_view()

Add a view to the config.

Usage
VitessceConfig$add_view(
  dataset,
  component,
  x = NA,
  y = NA,
  w = NA,
  h = NA,
  mapping = NA
)
Arguments
dataset

The dataset object to associate with this view.

component

The name of a component to render in this view.

x

The x-coordinate of the view in the layout.

y

The y-coordinate of the view in the layout.

w

The width of the view in the layout.

h

The height of the view in the layout.

mapping

An optional convenience parameter for setting the CoordinationType$EMBEDDING_TYPE coordination value if the component isComponent$SCATTERPLOT.

Returns

A new VitessceConfigView object.

Examples
vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
ds <- vc$add_dataset("My dataset")
spatial <- vc$add_view(ds, "spatial")

Method add_coordination()

Add a coordination scope to the config, for one or more coordination types.

Usage
VitessceConfig$add_coordination(c_types)
Arguments
c_types

The coordination types for which to create new coordination scopes.

Returns

A list of new VitessceConfigCoordinationScope objects.

Examples
vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
ds <- vc$add_dataset("My dataset")
spatial <- vc$add_view(ds, "spatial")
c_scopes <- vc$add_coordination(c("spatialZoom", "spatialTargetX"))
spatial$use_coordination(c_scopes)

Method add_meta_coordination()

Usage
VitessceConfig$add_meta_coordination()

Method add_coordination_by_dict()

Usage
VitessceConfig$add_coordination_by_dict(input_val)

Method link_views_by_dict()

Usage
VitessceConfig$link_views_by_dict(views, input_val, meta = TRUE)

Method layout()

Define the layout of views.

Usage
VitessceConfig$layout(view_concat)
Arguments
view_concat

A concatenation of views.

Returns

Self, to allow chaining.

Examples
vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
ds <- vc$add_dataset("My dataset")
spatial <- vc$add_view(ds, "spatial")
scatterplot <- vc$add_view(ds, "scatterplot")

Method link_views()

A convenience function for setting up new coordination scopes across a set of views.

Usage
VitessceConfig$link_views(views, c_types, c_values = NA, raw = FALSE)
Arguments
views

An array of view objects to link together.

c_types

The coordination types on which to coordinate the views.

c_values

Initial values corresponding to each coordination type. Should have the same length as the c_types array. Optional.

raw

Should the coordination values be set using VitessceConfigCoordinationScope$set_value() or VitessceConfigCoordinationScope$set_value_raw()? Use when setting lists or similar more complex values.

Returns

Self, to allow chaining.

Examples
vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
ref_dataset <- vc$add_dataset("Reference")
qry_dataset <- vc$add_dataset("Query")
ref_plot <- vc$add_view(ref_dataset, Component$SCATTERPLOT, mapping = "umap")
qry_plot <- vc$add_view(qry_dataset, Component$SCATTERPLOT, mapping = "proj.umap")
vc$link_views(
  c(ref_plot, qry_plot),
  c(CoordinationType$EMBEDDING_TARGET_X, CoordinationType$EMBEDDING_TARGET_Y),
  c_values = c(0, 0)
)

Method to_list()

Convert the config to an R list. Helpful when converting the config to JSON.

Usage
VitessceConfig$to_list(base_url = NA)
Arguments
base_url

An base URL to prepend to file paths.

Returns

A list that can be serialized to JSON.

Examples
vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
ds <- vc$add_dataset("My dataset")
vc_list <- vc$to_list(base_url = "http://localhost:8000")

Method get_routes()

Get a list of web server route objects corresponding to any local files which will need to be served.

Usage
VitessceConfig$get_routes()
Returns

A list of VitessceConfigServerStaticRoute.


Method widget()

Create an htmlwidget based on this config.

Usage
VitessceConfig$widget(...)
Arguments
...

Passes extra keyword arguments to the vitessce_widget function.

theme

The theme of the widget, either "dark" or "light". Optional. By default, "dark".

width

The width of the widget as a number or CSS string. Optional.

height

The height of the widget as a number or CSS string. Optional.

port

The port for the local web server (which serves local dataset objects to the widget). Optional. By default, uses open port between 8000 and 9000.

base_url

The base URL for the web server. Optional. By default, creates a localhost URL which includes the port.

serve

Should local data be served by running a local web server with R plumber? By default, TRUE.

element_id

An element ID. Optional.

Returns

The Vitessce htmlwidget.

Examples
vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
dataset <- vc$add_dataset("My dataset")
description <- vc$add_view(dataset, Component$DESCRIPTION)
vc$layout(description)
vc$widget()

Method export()

Export the data associated with this configuration to a specified destination.

Usage
VitessceConfig$export(to = "files", with_config = FALSE, base_url = NA, ...)
Arguments
to

Where should the files be exported to? Values currently supported: "files"

with_config

Should the Vitessce configuration be saved in the output directory as a JSON file?

base_url

If with_config is TRUE, what base_url value should be used for creation of the JSON config?

...

Extra parameters to pass through to the export function.

Returns

The Vitessce configuration as a list, with the base_url filled in.

Examples
vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
dataset <- vc$add_dataset("My dataset")
description <- vc$add_view(dataset, Component$DESCRIPTION)
vc$layout(description)
vc$export(with_config = TRUE, base_url = "http://localhost:3000", out_dir = "./data")

Method clone()

The objects of this class are cloneable with this method.

Usage
VitessceConfig$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples


## ------------------------------------------------
## Method `VitessceConfig$add_dataset`
## ------------------------------------------------

vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
ds <- vc$add_dataset("My dataset")

## ------------------------------------------------
## Method `VitessceConfig$add_view`
## ------------------------------------------------

vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
ds <- vc$add_dataset("My dataset")
spatial <- vc$add_view(ds, "spatial")

## ------------------------------------------------
## Method `VitessceConfig$add_coordination`
## ------------------------------------------------

vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
ds <- vc$add_dataset("My dataset")
spatial <- vc$add_view(ds, "spatial")
c_scopes <- vc$add_coordination(c("spatialZoom", "spatialTargetX"))
spatial$use_coordination(c_scopes)

## ------------------------------------------------
## Method `VitessceConfig$layout`
## ------------------------------------------------

vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
ds <- vc$add_dataset("My dataset")
spatial <- vc$add_view(ds, "spatial")
scatterplot <- vc$add_view(ds, "scatterplot")

## ------------------------------------------------
## Method `VitessceConfig$link_views`
## ------------------------------------------------

vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
ref_dataset <- vc$add_dataset("Reference")
qry_dataset <- vc$add_dataset("Query")
ref_plot <- vc$add_view(ref_dataset, Component$SCATTERPLOT, mapping = "umap")
qry_plot <- vc$add_view(qry_dataset, Component$SCATTERPLOT, mapping = "proj.umap")
vc$link_views(
  c(ref_plot, qry_plot),
  c(CoordinationType$EMBEDDING_TARGET_X, CoordinationType$EMBEDDING_TARGET_Y),
  c_values = c(0, 0)
)

## ------------------------------------------------
## Method `VitessceConfig$to_list`
## ------------------------------------------------

vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
ds <- vc$add_dataset("My dataset")
vc_list <- vc$to_list(base_url = "http://localhost:8000")

## ------------------------------------------------
## Method `VitessceConfig$widget`
## ------------------------------------------------

vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
dataset <- vc$add_dataset("My dataset")
description <- vc$add_view(dataset, Component$DESCRIPTION)
vc$layout(description)
vc$widget()

## ------------------------------------------------
## Method `VitessceConfig$export`
## ------------------------------------------------

vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
dataset <- vc$add_dataset("My dataset")
description <- vc$add_view(dataset, Component$DESCRIPTION)
vc$layout(description)
vc$export(with_config = TRUE, base_url = "http://localhost:3000", out_dir = "./data")

vitessce/vitessceR documentation built on Oct. 12, 2024, 12:24 a.m.