Class representing a Vitessce view config.
Public fields
config
The internal representation of the view config.
base_dir
The base directory for the config.
Methods
Method new()
Create a new config object.
Usage
VitessceConfig$new(schema_version, name = NA, description = NA, base_dir = NA)
Method add_dataset()
Add a dataset to the config.
Arguments
name
A name for the dataset.
uid
A unique ID for the dataset. Optional. Created automatically if not provided.
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.
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
.
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.
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 layout()
Define the layout of views.
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.
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.
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.
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.
Method widget()
Create an htmlwidget based on this config.
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.
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.
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, whatbase_url
value should be used for creation of the JSON config?...
Extra parameters to pass through to the export function.
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")
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")