VitessceConfig | R Documentation |
Class representing a Vitessce view config.
VitessceConfig
config
The internal representation of the view config.
base_dir
The base directory for the config.
new()
Create a new config object.
VitessceConfig$new(schema_version, name = NA, description = NA, base_dir = NA)
schema_version
The Vitessce config schema version to use.
name
A name for the config.
description
A description for the config.
A new VitessceConfig
object.
add_dataset()
Add a dataset to the config.
VitessceConfig$add_dataset(name, uid = NA)
name
A name for the dataset.
uid
A unique ID for the dataset. Optional. Created automatically if not provided.
A new VitessceConfigDataset
object.
vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config") ds <- vc$add_dataset("My dataset")
add_view()
Add a view to the config.
VitessceConfig$add_view( dataset, component, x = NA, y = NA, w = NA, h = NA, mapping = NA )
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
.
A new VitessceConfigView
object.
vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config") ds <- vc$add_dataset("My dataset") spatial <- vc$add_view(ds, "spatial")
add_coordination()
Add a coordination scope to the config, for one or more coordination types.
VitessceConfig$add_coordination(c_types)
c_types
The coordination types for which to create new coordination scopes.
A list of new VitessceConfigCoordinationScope
objects.
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)
add_meta_coordination()
VitessceConfig$add_meta_coordination()
add_coordination_by_dict()
VitessceConfig$add_coordination_by_dict(input_val)
link_views_by_dict()
VitessceConfig$link_views_by_dict(views, input_val, meta = TRUE)
layout()
Define the layout of views.
VitessceConfig$layout(view_concat)
view_concat
A concatenation of views.
Self, to allow chaining.
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")
link_views()
A convenience function for setting up new coordination scopes across a set of views.
VitessceConfig$link_views(views, c_types, c_values = NA, raw = FALSE)
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.
Self, to allow chaining.
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) )
to_list()
Convert the config to an R list. Helpful when converting the config to JSON.
VitessceConfig$to_list(base_url = NA)
base_url
An base URL to prepend to file paths.
A list
that can be serialized to JSON.
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")
get_routes()
Get a list of web server route objects corresponding to any local files which will need to be served.
VitessceConfig$get_routes()
A list
of VitessceConfigServerStaticRoute
.
widget()
Create an htmlwidget based on this config.
VitessceConfig$widget(...)
...
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.
The Vitessce htmlwidget.
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()
export()
Export the data associated with this configuration to a specified destination.
VitessceConfig$export(to = "files", with_config = FALSE, base_url = NA, ...)
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.
The Vitessce configuration as a list, with the base_url
filled in.
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")
clone()
The objects of this class are cloneable with this method.
VitessceConfig$clone(deep = FALSE)
deep
Whether to make a deep clone.
## ------------------------------------------------
## 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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.