View config API

The VitessceConfig class provides functionality for creating view configs using a pythonic syntax, with support for exporting to dict or JSON format.

vitessce.config

class vitessce.config.VitessceConfig(schema_version, name=None, description=None, base_dir=None)[source]

A class to represent a Vitessce view config.

Construct a Vitessce view config object.

Parameters
  • schema_version (str) – The view config schema version.

  • name (str) – A name for the view config. Optional.

  • description (str) – A description for the view config. Optional.

  • base_dir (str) – A local path to a directory to be served. If provided, local data objects will be configured relative to this directory. Optional.

from vitessce import VitessceConfig

vc = VitessceConfig(schema_version="1.0.15", name='My Config')
add_coordination(*c_types)[source]

Add scope(s) for new coordination type(s) to the config.

Parameters

*c_types (str or vitessce.constants.CoordinationType) – A variable number of coordination types.

Returns

The instances for the new scope objects corresponding to each coordination type. These can be linked to views via the VitessceConfigView.use_coordination() method.

Return type

list[VitessceConfigCoordinationScope]

from vitessce import VitessceConfig, ViewType as vt, CoordinationType as ct

vc = VitessceConfig(schema_version="1.0.15")
my_dataset = vc.add_dataset(name='My Dataset')
v1 = vc.add_view(vt.SPATIAL, dataset=my_dataset)
v2 = vc.add_view(vt.SPATIAL, dataset=my_dataset)
zoom_scope, x_scope, y_scope = vc.add_coordination(
    ct.SPATIAL_ZOOM,
    ct.SPATIAL_TARGET_X,
    ct.SPATIAL_TARGET_Y,
)
v1.use_coordination(zoom_scope, x_scope, y_scope)
v2.use_coordination(zoom_scope, x_scope, y_scope)
zoom_scope.set_value(2)
x_scope.set_value(0)
y_scope.set_value(0)
add_coordination_by_dict(input_val)[source]

Set up the initial values for multi-level coordination in the coordination space. Get a reference to these values to pass to the useCoordinationByObject method of either view or meta coordination scope instances.

Parameters

input_val (dict) – A (potentially nested) object with coordination types as keys and values being either the initial coordination value, a VitessceConfigCoordinationScope instance, or a CoordinationLevel instance. The CoordinationLevel constructor takes an array of objects as its argument to support nesting.

Returns

A (potentially nested) object with coordination types as keys and values being either { scope }, { scope, children }, or an array of these. Not intended to be manipulated before being passed to a useCoordinationByObject function.

Return type

dict

from vitessce import VitessceConfig, ViewType as vt, CoordinationType as ct

vc = VitessceConfig(schema_version="1.0.15")
my_dataset = vc.add_dataset(name='My Dataset')
spatial_view = vc.add_view(vt.SPATIAL, dataset=my_dataset)
lc_view = vc.add_view(vt.LAYER_CONTROLLER, dataset=my_dataset)
scopes = vc.add_coordination_by_dict({
    ct.SPATIAL_ZOOM: 2,
    ct.SPATIAL_TARGET_X: 0,
    ct.SPATIAL_TARGET_Y: 0,
})
add_dataset(name='', uid=None, files=None, objs=None)[source]

Add a dataset to the config.

Parameters
  • name (str) – A name for this dataset.

  • uid (str) – A unique identifier for this dataset. Optional. If None, one will be automatically generated.

  • files (list or None) – A list of VitessceConfigDatasetFile instances. optional.

  • objs (list or None) – A list of AbstractWrapper instances. Optional.

Returns

The instance for the new dataset.

Return type

VitessceConfigDataset

from vitessce import VitessceConfig, DataType as dt, FileType as ft

vc = VitessceConfig(schema_version="1.0.15", name='My Config')
my_dataset = (
    vc.add_dataset(name='My Dataset')
    .add_file(
        url="http://example.com/cells.json",
        file_type=ft.CELLS_JSON,
    )
)
add_meta_coordination()[source]

Initialize a new meta coordination scope in the coordination space, and get a reference to it in the form of a meta coordination scope instance.

Returns

A new meta coordination scope instance.

Return type

VitessceConfigMetaCoordinationScope

from vitessce import VitessceConfig, ViewType as vt, CoordinationType as ct

vc = VitessceConfig(schema_version="1.0.15")
my_dataset = vc.add_dataset(name='My Dataset')
spatial_view = vc.add_view(vt.SPATIAL, dataset=my_dataset)
lc_view = vc.add_view(vt.LAYER_CONTROLLER, dataset=my_dataset)
scopes = vc.add_coordination_by_dict({
    ct.SPATIAL_ZOOM: 2,
    ct.SPATIAL_TARGET_X: 0,
    ct.SPATIAL_TARGET_Y: 0,
})

meta_scopes = vc.add_meta_coordination()
meta_scopes.use_coordination_by_dict(scopes)

spatial_view.use_meta_coordination(meta_scopes)
lc_view.use_meta_coordination(meta_scopes)
add_view(view_type, dataset=None, dataset_uid=None, x=0, y=0, w=1, h=1, mapping=None, coordination_scopes=None, props=None)[source]

Add a view to the config.

Parameters
  • view_type (str or vitessce.constants.ViewType) – A component name, either as a string or using the ViewType enum values.

  • dataset (VitessceConfigDataset or None) – A dataset instance to be used for the data visualized in this view. Must provide dataset or dataset_uid, but not both.

  • dataset_uid (str or None) – A unique ID for a dataset to be used for the data visualized in this view. Must provide dataset or dataset_uid, but not both.

  • mapping (str) – An optional convenience parameter for setting the EMBEDDING_TYPE coordination scope value. This parameter is only applicable to the SCATTERPLOT component.

  • x (int) – The horizontal position of the view. Must be an integer between 0 and 11. Optional. This will be ignored if you call the layout method of this class using VitessceConfigViewHConcat and VitessceConfigViewVConcat objects.

  • y (int) – The vertical position of the view. Must be an integer between 0 and 11. Optional. This will be ignored if you call the layout method of this class using VitessceConfigViewHConcat and VitessceConfigViewVConcat objects.

  • w (int) – The width of the view. Must be an integer between 1 and 12. Optional. This will be ignored if you call the layout method of this class using VitessceConfigViewHConcat and VitessceConfigViewVConcat objects.

  • h (int) – The height of the view. Must be an integer between 1 and 12. Optional. This will be ignored if you call the layout method of this class using VitessceConfigViewHConcat and VitessceConfigViewVConcat objects.

  • coordination_scopes (dict or None) – A mapping from coordination types to coordination scope names for this view.

  • props (dict or None) – Props to set for the view using the VitessceConfigView.set_props method.

Returns

The instance for the new view.

Return type

VitessceConfigView

from vitessce import VitessceConfig, ViewType as vt

vc = VitessceConfig(schema_version="1.0.15")
my_dataset = vc.add_dataset(name='My Dataset')
v1 = vc.add_view(vt.SPATIAL, dataset=my_dataset)
v2 = vc.add_view(vt.SCATTERPLOT, dataset=my_dataset, mapping="X_umap")
display(**kwargs)[source]

As a fallback to widget, render Vitessce using functions from IPython.display. This method does not support bi-directional communication (i.e., user interactions in Vitessce cannot be sent back to Python).

Parameters
  • theme (str) – The theme name, either “light” or “dark”. By default, “auto”, which selects light or dark based on operating system preferences.

  • port (int) – The port to use when serving data objects on localhost. By default, 8000.

  • base_url (str or None) – If the web app is being accessed remotely (i.e. the data is being served from a remote machine), specify the base URL here. If serving and accessing the data on the same machine, keep as None to use a localhost URL.

  • host_name (str or None) – The host name where the Jupyter server is running, e.g. “http://localhost:8888”. By default, None.

  • proxy (bool) – Is this widget being served through a proxy, for example with a cloud notebook? If True, host_name should be provided.

from vitessce import VitessceConfig, ViewType as vt, CoordinationType as ct

vc = VitessceConfig(schema_version="1.0.15")
my_dataset = vc.add_dataset(name='My Dataset')
v1 = vc.add_view(vt.SPATIAL, dataset=my_dataset)
vc.layout(v1)
vc.display()
export(to, *args, **kwargs)[source]

Export this config’s data objects to the local file system or a cloud storage system and get the resulting view config.

Parameters
  • to (str) – The export destination. Valid values include “S3” and “files”.

  • **kwargs – Keyword arguments to pass to the export function.

Returns

The config as a dict, with URLs for the bucket filled in.

Return type

dict

from vitessce import VitessceConfig, ViewType as cvtm, CoordinationType as ct

vc = VitessceConfig(schema_version="1.0.15")
my_dataset = vc.add_dataset(name='My Dataset')
v1 = vc.add_view(vt.SPATIAL, dataset=my_dataset)
vc.layout(v1)

config_dict = vc.export(to="S3")
static from_dict(config)[source]

Helper function to construct a Vitessce view config object from an existing config.

Parameters

config (dict) – An existing Vitessce view config as a dict to allow manipulation through the VitessceConfig API.

Returns

The config instance.

Return type

VitessceConfig

from vitessce import VitessceConfig

vc = VitessceConfig.from_dict(my_existing_config)
static from_object(obj, schema_version, name=None, description=None)[source]

Helper function to automatically construct a Vitessce view config object from a single-cell dataset object. Particularly helpful when using the VitessceWidget Jupyter widget.

Parameters
  • obj (anndata.AnnData or loompy.LoomConnection or zarr.Store) – A single-cell dataset in the format of a commonly-used single-cell or imaging data analysis package.

  • schema_version (str) – The schema version to pass to the VitessceConfig constructor.

Returns

The config instance.

Return type

VitessceConfig

from vitessce import VitessceConfig

vc = VitessceConfig.from_object(my_scanpy_object, schema_version="1.0.15")
get_dataset_by_coordination_scope_name(query_scope_name)[source]

Get a dataset associated with this configuration based on a coordination scope.

Parameters

query_scope_name (str) – The unique identifier for the dataset coordination scope of interest.

Returns

The dataset object.

Return type

VitessceConfigDataset or None

get_dataset_by_uid(uid)[source]

Get a dataset associated with this configuration based on its uid.

Parameters

uid (str) – The unique identifier for the dataset of interest.

Returns

The dataset object.

Return type

VitessceConfigDataset or None

get_datasets()[source]

Get the datasets associated with this configuration.

Returns

The list of dataset objects.

Return type

list of VitessceConfigDataset

get_routes()[source]

Convert the routes for this view config from the datasets.

Returns

A list of server routes.

Return type

list[starlette.routing.Route]

get_stores(base_url=None)[source]

Convert the routes for this view config from the datasets.

Returns

A list of server routes.

Return type

list[starlette.routing.Route]

layout(view_concat)[source]

Create a multi-view layout based on (potentially recursive) view concatenations.

Parameters

view_concat (VitessceConfigViewHConcat or VitessceConfigViewVConcat or VitessceConfigView) – Views arranged by concatenating vertically or horizontally. Alternatively, a single view can be passed.

Returns

Self, to allow chaining.

Return type

VitessceConfig

from vitessce import VitessceConfig, ViewType as vt, hconcat, vconcat

vc = VitessceConfig(schema_version="1.0.15")
my_dataset = vc.add_dataset(name='My Dataset')
v1 = vc.add_view(vt.SPATIAL, dataset=my_dataset)
v2 = vc.add_view(vt.SPATIAL, dataset=my_dataset)
v3 = vc.add_view(vt.SPATIAL, dataset=my_dataset)
vc.layout(hconcat(v1, vconcat(v2, v3)))
from vitessce import VitessceConfig, ViewType as vt

vc = VitessceConfig(schema_version="1.0.15")
my_dataset = vc.add_dataset(name='My Dataset')
v1 = vc.add_view(vt.SPATIAL, dataset=my_dataset)
v2 = vc.add_view(vt.SPATIAL, dataset=my_dataset)
v3 = vc.add_view(vt.SPATIAL, dataset=my_dataset)
vc.layout(v1 | (v2 / v3)) # * magic * (alternative syntax)

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

Parameters
  • views (list of VitessceConfigView) – views An array of view objects to link together.

  • c_types (list of str or list of vitessce.constants.CoordinationType) – The coordination types on which to coordinate the views.

  • c_values (list) – Initial values corresponding to each coordination type. Should have the same length as the c_types array. Optional.

  • allow_multiple_scopes_per_type (bool) – Whether to allow multiple coordination scopes per coordination type. If true, multiple values for the same coordination type are treated as a list. If false, latest value for same coordination type is used. Defaults to False.

Returns

Self, to allow chaining.

Return type

VitessceConfig

A convenience function for setting up multi-level and meta-coordination scopes across a set of views.

Parameters
  • views (list[VitessceConfigView]) – An array of view objects to link together.

  • input_val (dict) – A (potentially nested) object with coordination types as keys and values being either the initial coordination value, a VitessceConfigCoordinationScope instance, or a CoordinationLevel instance. The CoordinationLevel constructor takes an array of objects as its argument to support nesting.

  • meta (bool) – Whether or not to use meta-coordination to link the views. Optional.

Returns

Self, to allow chaining.

Return type

VitessceConfig

from vitessce import VitessceConfig, ViewType as vt, CoordinationType as ct

vc = VitessceConfig(schema_version="1.0.15")
my_dataset = vc.add_dataset(name='My Dataset')
spatial_view = vc.add_view(vt.SPATIAL, dataset=my_dataset)
lc_view = vc.add_view(vt.LAYER_CONTROLLER, dataset=my_dataset)
scopes = vc.link_views_by_dict([spatial_view, lc_view], {
    ct.SPATIAL_ZOOM: 2,
    ct.SPATIAL_TARGET_X: 0,
    ct.SPATIAL_TARGET_Y: 0,
})
set_coordination_value(c_type, c_scope, c_value)[source]

Set the value for a coordination scope. If a coordination object for the coordination type does not yet exist in the coordination space, it will be created.

Parameters
  • c_type (str) – The coordination type for this coordination scope.

  • c_scope (str) – The coordination scope name.

  • c_value (any) – The value for the coordination scope. Optional.

Returns

The coordination scope instance.

Return type

VitessceConfigCoordinationScope

to_dict(base_url=None)[source]

Convert the view config instance to a dict object.

Parameters

base_url (str) – Optional parameter for non-remote data to specify the url from which the data will be served.

Returns

The view config as a dict. Useful for serializing to JSON.

Return type

dict

to_python()[source]

Convert the VitessceConfig instance to a one-line Python code snippet that can be used to generate it.

Returns

(A list of classes from the vitessce package used in the code block, The formatted code block)

Return type

(list[str], str)

web_app(**kwargs)[source]

Launch the http://vitessce.io web app using this config.

Parameters
  • theme (str) – The theme name, either “light” or “dark”. By default, “auto”, which selects light or dark based on operating system preferences.

  • port (int) – The port to use when serving data objects on localhost. By default, 8000.

  • base_url (str or None) – If the web app is being accessed remotely (i.e. the data is being served from a remote machine), specify the base URL here. If serving and accessing the data on the same machine, keep as None to use a localhost URL.

  • host_name (str or None) – The host name where the Jupyter server is running, e.g. “http://localhost:8888”. By default, None.

  • proxy (bool) – Is this widget being served through a proxy, for example with a cloud notebook? If True, host_name should be provided.

  • open (bool) – Should the browser be opened to the web app URL? By default, True.

Returns

The URL of the web app (containing the Vitessce configuration as URL-encoded JSON).

Return type

str

from vitessce import VitessceConfig, ViewType as vt, CoordinationType as ct

vc = VitessceConfig(schema_version="1.0.15")
my_dataset = vc.add_dataset(name='My Dataset')
v1 = vc.add_view(vt.SPATIAL, dataset=my_dataset)
vc.layout(v1)
vc.web_app()
widget(**kwargs)[source]

Instantiate a VitessceWidget object based on this config.

Parameters
  • theme (str) – The theme name, either “light” or “dark”. By default, “auto”, which selects light or dark based on operating system preferences.

  • height (int) – The height of the widget, in pixels. By default, 600.

  • port (int) – The port to use when serving data objects on localhost. By default, 8000.

  • proxy (bool) – Is this widget being served through a proxy, for example with a cloud notebook (e.g. Binder)?

Returns

The Jupyter widget.

Return type

VitessceWidget

from vitessce import VitessceConfig, ViewType as vt, CoordinationType as ct

vc = VitessceConfig(schema_version="1.0.15")
my_dataset = vc.add_dataset(name='My Dataset')
v1 = vc.add_view(vt.SPATIAL, dataset=my_dataset)
vc.layout(v1)
vw = vc.widget()
vw
class vitessce.config.VitessceChainableConfig(schema_version, **kwargs)[source]

A class to represent a Vitessce view config, where the methods add_dataset, add_view, and set_coordination_value return self (the config instance). This class inherits from VitessceConfig.

Construct a Vitessce view config object.

Parameters

**kwargs – Takes the same arguments as the constructor on the VitessceConfig class.

from vitessce import VitessceChainableConfig

vc = VitessceChainableConfig(schema_version='1.0.15', name='My Config')
add_dataset(copy=True, **kwargs)[source]

Add a dataset to this config.

Parameters

**kwargs – Takes the same arguments as the add_dataset method on the VitessceConfig class.

Returns

The config instance.

Return type

VitessceChainableConfig

add_view(component, copy=True, **kwargs)[source]

Add a view to this config.

Parameters
  • component – Takes the same arguments as the add_view method on the VitessceConfig class.

  • **kwargs – Takes the same arguments as the add_view method on the VitessceConfig class.

Returns

The config instance.

Return type

VitessceChainableConfig

set_coordination_value(c_type, c_scope, c_value, copy=True)[source]

Add a coordination value to this config.

Parameters
  • c_type – Takes the same arguments as the set_coordination_value method on the VitessceConfig class.

  • c_scope – Takes the same arguments as the set_coordination_value method on the VitessceConfig class.

  • c_value – Takes the same arguments as the set_coordination_value method on the VitessceConfig class.

Returns

The config instance.

Return type

VitessceChainableConfig

class vitessce.config.VitessceConfigDatasetFile(file_type, url=None, coordination_values=None, options=None, data_type=None)[source]

A class to represent a file (described by a URL, data type, and file type) in a Vitessce view config dataset.

Not meant to be instantiated directly, but instead created and returned by the VitessceConfigDataset.add_file() method.

Parameters
  • file_type (str) – A file type.

  • url (str or None) – A URL to this file. Can be a localhost URL or a remote URL.

  • coordination_values (dict or None) – Coordination values to pass to the file loader class.

  • options (dict or list or None) – Extra options to pass to the file loader class.

  • data_type – Deprecated / not used. Only included for backwards compatibility with the old API.

class vitessce.config.VitessceConfigDataset(uid, name, base_dir=None)[source]

A class to represent a dataset (i.e. list of files containing common biological entities) in the Vitessce view config.

Not meant to be instantiated directly, but instead created and returned by the VitessceConfig.add_dataset() method.

Parameters
  • uid (str) – A unique identifier for this dataset.

  • name (str) – A name for this dataset.

get_name()[source]

Get the name for this dataset.

Returns

The name.

Return type

str

get_uid()[source]

Get the uid value for this dataset.

Returns

The uid.

Return type

str

add_file(file_type, url=None, coordination_values=None, options=None, data_type=None)[source]

Add a new file definition to this dataset instance.

Parameters
  • file_type (str or vitessce.constants.FileType) – The file type. Must be compatible with the specified data type.

  • url (str or None) – The URL for the file, pointing to either a local or remote location.

  • coordination_values (dict or None) – Coordination values to pass to the file loader class. Optional.

  • options (dict or list or None) – Extra options to pass to the file loader class. Optional.

  • data_type – Deprecated / not used. Only included for backwards compatibility with the old API.

Returns

Self, to allow function chaining.

Return type

VitessceConfigDataset

from vitessce import VitessceConfig, DataType as dt, FileType as ft

vc = VitessceConfig(schema_version="1.0.15", name='My Config')
my_dataset = (
    vc.add_dataset(name='My Dataset')
    .add_file(
        url="http://example.com/cells.json",
        data_type=dt.CELLS,
        file_type=ft.CELLS_JSON,
    )
)
add_object(obj)[source]

Add a data object to this dataset instance.

Parameters

obj (vitessce.AbstractWrapper) – A data object that can be served locally or which points to a remote storage provider. Typically, a subclass of AbstractWrapper.

Returns

Self, to allow function chaining.

Return type

VitessceConfigDataset

class vitessce.config.VitessceConfigViewHConcat(views)[source]

A class to represent a horizontal concatenation of view instances.

Not meant to be instantiated directly, but instead created and returned by the hconcat helper function.

vitessce.config.hconcat(*views)[source]

A helper function to create a VitessceConfigViewHConcat instance.

Parameters

*views (VitessceConfigView or VitessceConfigViewVConcat or VitessceConfigViewHConcat) – A variable number of views to concatenate horizontally.

Returns

The concatenated view instance.

Return type

VitessceConfigViewHConcat

from vitessce import VitessceConfig, ViewType as vt, hconcat, vconcat

vc = VitessceConfig(schema_version="1.0.15")
my_dataset = vc.add_dataset(name='My Dataset')
v1 = vc.add_view(vt.SPATIAL, dataset=my_dataset)
v2 = vc.add_view(vt.SPATIAL, dataset=my_dataset)
v3 = vc.add_view(vt.SPATIAL, dataset=my_dataset)
vc.layout(hconcat(v1, vconcat(v2, v3)))
class vitessce.config.VitessceConfigViewVConcat(views)[source]

A class to represent a vertical concatenation of view instances.

Not meant to be instantiated directly, but instead created and returned by the vconcat helper function.

vitessce.config.vconcat(*views)[source]

A helper function to create a VitessceConfigViewVConcat instance.

Parameters

*views (VitessceConfigView or VitessceConfigViewVConcat or VitessceConfigViewHConcat) – A variable number of views to concatenate vertically.

Returns

The concatenated view instance.

Return type

VitessceConfigViewVConcat

from vitessce import VitessceConfig, ViewType as vt, hconcat, vconcat

vc = VitessceConfig(schema_version="1.0.15")
my_dataset = vc.add_dataset(name='My Dataset')
v1 = vc.add_view(vt.SPATIAL, dataset=my_dataset)
v2 = vc.add_view(vt.SPATIAL, dataset=my_dataset)
v3 = vc.add_view(vt.SPATIAL, dataset=my_dataset)
vc.layout(hconcat(v1, vconcat(v2, v3)))
class vitessce.config.VitessceConfigView(component, coordination_scopes, x, y, w, h)[source]

A class to represent a view (i.e. visualization component) in the Vitessce view config layout.

Not meant to be instantiated directly, but instead created and returned by the VitessceConfig.add_view() method.

Parameters
  • component (str) – The name of the component used for this view.

  • coordination_scopes (dict) – A mapping of coordination types to coordination scopes.

  • x (int) – An x-coordinate for this view in the grid.

  • y (int) – A y-coordinate for this view in the grid.

  • w (int) – A width for this view in the grid.

  • h (int) – A height for this view in the grid.

get_coordination_scope(c_type)[source]

Get the coordination scope name for a particular coordination type.

Parameters

c_type (str) – The coordination type of interest.

Returns

The coordination scope name.

Return type

str or None

use_coordination(*c_scopes, allow_multiple_scopes_per_type=False)[source]

Attach a coordination scope to this view instance. All views using the same coordination scope for a particular coordination type will effectively be linked together.

Parameters
  • *c_scopes (VitessceConfigCoordinationScope) – A variable number of coordination scope instances can be passed.

  • allow_multiple_scopes_per_type (bool) – Whether to allow multiple coordination scopes per coordination type. If true, multiple values for the same coordination type are treated as a list. If false, latest value for same coordination type is used. Defaults to False.

Returns

Self, to allow chaining.

Return type

VitessceConfigView

from vitessce import VitessceConfig, ViewType as vt, CoordinationType as ct

vc = VitessceConfig(schema_version="1.0.15")
my_dataset = vc.add_dataset(name='My Dataset')
v1 = vc.add_view(vt.SPATIAL, dataset=my_dataset)
v2 = vc.add_view(vt.SPATIAL, dataset=my_dataset)
zoom_scope, x_scope, y_scope = vc.add_coordination(
    ct.SPATIAL_ZOOM,
    ct.SPATIAL_TARGET_X,
    ct.SPATIAL_TARGET_Y,
)
v1.use_coordination(zoom_scope, x_scope, y_scope)
v2.use_coordination(zoom_scope, x_scope, y_scope)
zoom_scope.set_value(2)
x_scope.set_value(0)
y_scope.set_value(0)
use_coordination_by_dict(scopes)[source]

Attach potentially multi-level coordination scopes to this view.

Parameters

scopes (dict) – A value returned by VitessceConfig.add_coordination_by_dict. Not intended to be a manually-constructed object.

Returns

Self, to allow chaining.

Return type

VitessceConfigView

from vitessce import VitessceConfig, ViewType as vt, CoordinationType as ct

vc = VitessceConfig(schema_version="1.0.15")
my_dataset = vc.add_dataset(name='My Dataset')
spatial_view = vc.add_view(vt.SPATIAL, dataset=my_dataset)
scopes = vc.add_coordination_by_dict({
    ct.SPATIAL_ZOOM: 2,
    ct.SPATIAL_TARGET_X: 0,
    ct.SPATIAL_TARGET_Y: 0,
})
spatial_view.use_coordination_by_dict(scopes)
use_meta_coordination(meta_scope)[source]

Attach meta coordination scopes to this view. :param meta_scope: A meta coordination scope instance. :type meta_scope: VitessceConfigMetaCoordinationScope :returns: Self, to allow chaining. :rtype: VitessceConfigView

from vitessce import VitessceConfig, ViewType as vt, CoordinationType as ct

vc = VitessceConfig(schema_version="1.0.15")
my_dataset = vc.add_dataset(name='My Dataset')
spatial_view = vc.add_view(vt.SPATIAL, dataset=my_dataset)
lc_view = vc.add_view(vt.LAYER_CONTROLLER, dataset=my_dataset)
scopes = vc.add_coordination_by_dict({
    ct.SPATIAL_ZOOM: 2,
    ct.SPATIAL_TARGET_X: 0,
    ct.SPATIAL_TARGET_Y: 0,
})

meta_scopes = vc.add_meta_coordination()
meta_scopes.use_coordination_by_dict(scopes)

spatial_view.use_meta_coordination(meta_scopes)
lc_view.use_meta_coordination(meta_scopes)
set_xywh(x, y, w, h)[source]

Set the dimensions for this view.

Parameters
  • x (int) – The horizontal position.

  • y (int) – The vertical position.

  • w (int) – The width.

  • h (int) – The height.

Returns

Self, to allow chaining.

Return type

VitessceConfigView

set_props(**kwargs)[source]

Set the props for this view.

Parameters

**kwargs – A variable number of named props.

Returns

Self, to allow chaining.

Return type

VitessceConfigView

get_props()[source]

Get the props for this view.

Returns

The props.

Return type

dict or None

class vitessce.config.VitessceConfigCoordinationScope(c_type, c_scope, c_value=None)[source]

A class to represent a coordination scope in the Vitessce view config coordination space.

Not meant to be instantiated directly, but instead created and returned by the VitessceConfig.add_coordination() method.

Parameters
  • c_type (str) – The coordination type for this coordination scope.

  • c_scope (str) – The coordination scope name.

  • c_value – The value for the coordination scope. Optional.

set_value(c_value)[source]

Set the value of the coordination scope.

Parameters

c_value (any) – The coordination value to be set. Can be any value that is valid for the coordination type. Must be serializable to JSON.

Returns

Self, to allow chaining.

Return type

VitessceConfigCoordinationScope

from vitessce import VitessceConfig, ViewType as vt, CoordinationType as ct

vc = VitessceConfig(schema_version="1.0.15")
my_dataset = vc.add_dataset(name='My Dataset')
v1 = vc.add_view(vt.SPATIAL, dataset=my_dataset)
v2 = vc.add_view(vt.SPATIAL, dataset=my_dataset)
zoom_scope, x_scope, y_scope = vc.add_coordination(
    ct.SPATIAL_ZOOM,
    ct.SPATIAL_TARGET_X,
    ct.SPATIAL_TARGET_Y,
)
v1.use_coordination(zoom_scope, x_scope, y_scope)
v2.use_coordination(zoom_scope, x_scope, y_scope)
zoom_scope.set_value(2)
x_scope.set_value(0)
y_scope.set_value(0)
class vitessce.config.VitessceConfigMetaCoordinationScope(meta_scope, meta_by_scope)[source]

A class representing a pair of coordination scopes, for metaCoordinationScopes and metaCoordinationScopesBy, respectively, in the coordination space.

Not meant to be instantiated directly, but instead created and returned by the VitessceConfig.add_meta_coordination() method.

Parameters
  • meta_scope (str) – The name of the coordination scope for metaCoordinationScopes.

  • meta_by_scope (str) – The name of the coordination scope for metaCoordinationScopesBy.

use_coordination(*c_scopes)[source]

Attach coordination scopes to this meta scope.

Parameters

*c_scopes (VitessceConfigCoordinationScope) – A variable number of coordination scope instances.

Returns

Self, to allow chaining.

Return type

VitessceConfigMetaCoordinationScope

use_coordination_by_dict(scopes)[source]

Attach potentially multi-level coordination scopes to this meta-scopes instance.

Parameters

scopes (dict) – A value returned by VitessceConfig.add_coordination_by_dict. Not intended to be a manually-constructed object.

Returns

Self, to allow chaining.

Return type

VitessceConfigMetaCoordinationScope

from vitessce import VitessceConfig, ViewType as vt, CoordinationType as ct

vc = VitessceConfig(schema_version="1.0.15")
my_dataset = vc.add_dataset(name='My Dataset')
spatial_view = vc.add_view(vt.SPATIAL, dataset=my_dataset)
lc_view = vc.add_view(vt.LAYER_CONTROLLER, dataset=my_dataset)
scopes = vc.add_coordination_by_dict({
    ct.SPATIAL_ZOOM: 2,
    ct.SPATIAL_TARGET_X: 0,
    ct.SPATIAL_TARGET_Y: 0,
})

meta_scopes = vc.add_meta_coordination()
meta_scopes.use_coordination_by_dict(scopes)

spatial_view.use_meta_coordination(meta_scopes)
lc_view.use_meta_coordination(meta_scopes)

vitessce.constants

class vitessce.constants.CoordinationType(value)[source]

An enum type representing a coordination type in the Vitessce coordination model. The term coordination type refers to a parameter to be coordinated, and its programming-language-like type. For example, the SPATIAL_ZOOM coordination type represents a coordination of the zoom level of a spatial view, which can take a float value.

ADDITIONAL_CELL_SETS = 'additionalCellSets'[source]
ADDITIONAL_OBS_SETS = 'additionalObsSets'[source]
CELL_COLOR_ENCODING = 'cellColorEncoding'[source]
CELL_FILTER = 'cellFilter'[source]
CELL_HIGHLIGHT = 'cellHighlight'[source]
CELL_SET_COLOR = 'cellSetColor'[source]
CELL_SET_HIGHLIGHT = 'cellSetHighlight'[source]
CELL_SET_SELECTION = 'cellSetSelection'[source]
DATASET = 'dataset'[source]
EMBEDDING_CELL_OPACITY = 'embeddingCellOpacity'[source]
EMBEDDING_CELL_OPACITY_MODE = 'embeddingCellOpacityMode'[source]
EMBEDDING_CELL_RADIUS = 'embeddingCellRadius'[source]
EMBEDDING_CELL_RADIUS_MODE = 'embeddingCellRadiusMode'[source]
EMBEDDING_OBS_OPACITY = 'embeddingObsOpacity'[source]
EMBEDDING_OBS_OPACITY_MODE = 'embeddingObsOpacityMode'[source]
EMBEDDING_OBS_RADIUS = 'embeddingObsRadius'[source]
EMBEDDING_OBS_RADIUS_MODE = 'embeddingObsRadiusMode'[source]
EMBEDDING_OBS_SET_LABELS_VISIBLE = 'embeddingObsSetLabelsVisible'[source]
EMBEDDING_OBS_SET_LABEL_SIZE = 'embeddingObsSetLabelSize'[source]
EMBEDDING_OBS_SET_POLYGONS_VISIBLE = 'embeddingObsSetPolygonsVisible'[source]
EMBEDDING_ROTATION = 'embeddingRotation'[source]
EMBEDDING_TARGET_X = 'embeddingTargetX'[source]
EMBEDDING_TARGET_Y = 'embeddingTargetY'[source]
EMBEDDING_TARGET_Z = 'embeddingTargetZ'[source]
EMBEDDING_TYPE = 'embeddingType'[source]
EMBEDDING_ZOOM = 'embeddingZoom'[source]
FEATURE_FILTER = 'featureFilter'[source]
FEATURE_HIGHLIGHT = 'featureHighlight'[source]
FEATURE_SELECTION = 'featureSelection'[source]
FEATURE_TYPE = 'featureType'[source]
FEATURE_VALUE_COLORMAP = 'featureValueColormap'[source]
FEATURE_VALUE_COLORMAP_RANGE = 'featureValueColormapRange'[source]
FEATURE_VALUE_TRANSFORM = 'featureValueTransform'[source]
FEATURE_VALUE_TRANSFORM_COEFFICIENT = 'featureValueTransformCoefficient'[source]
FEATURE_VALUE_TYPE = 'featureValueType'[source]
GATING_FEATURE_SELECTION_X = 'gatingFeatureSelectionX'[source]
GATING_FEATURE_SELECTION_Y = 'gatingFeatureSelectionY'[source]
GENE_EXPRESSION_COLORMAP = 'geneExpressionColormap'[source]
GENE_EXPRESSION_COLORMAP_RANGE = 'geneExpressionColormapRange'[source]
GENE_FILTER = 'geneFilter'[source]
GENE_HIGHLIGHT = 'geneHighlight'[source]
GENE_SELECTION = 'geneSelection'[source]
GENOMIC_TARGET_X = 'genomicTargetX'[source]
GENOMIC_TARGET_Y = 'genomicTargetY'[source]
GENOMIC_ZOOM_X = 'genomicZoomX'[source]
GENOMIC_ZOOM_Y = 'genomicZoomY'[source]
HEATMAP_TARGET_X = 'heatmapTargetX'[source]
HEATMAP_TARGET_Y = 'heatmapTargetY'[source]
HEATMAP_ZOOM_X = 'heatmapZoomX'[source]
HEATMAP_ZOOM_Y = 'heatmapZoomY'[source]
META_COORDINATION_SCOPES = 'metaCoordinationScopes'[source]
META_COORDINATION_SCOPES_BY = 'metaCoordinationScopesBy'[source]
MOLECULE_HIGHLIGHT = 'moleculeHighlight'[source]
OBS_COLOR_ENCODING = 'obsColorEncoding'[source]
OBS_FILTER = 'obsFilter'[source]
OBS_HIGHLIGHT = 'obsHighlight'[source]
OBS_LABELS_TYPE = 'obsLabelsType'[source]
OBS_SET_COLOR = 'obsSetColor'[source]
OBS_SET_HIGHLIGHT = 'obsSetHighlight'[source]
OBS_SET_SELECTION = 'obsSetSelection'[source]
OBS_TYPE = 'obsType'[source]
SPATIAL_AXIS_FIXED = 'spatialAxisFixed'[source]
SPATIAL_CELLS_LAYER = 'spatialCellsLayer'[source]
SPATIAL_IMAGE_LAYER = 'spatialImageLayer'[source]
SPATIAL_MOLECULES_LAYER = 'spatialMoleculesLayer'[source]
SPATIAL_NEIGHBORHOODS_LAYER = 'spatialNeighborhoodsLayer'[source]
SPATIAL_NEIGHBORHOOD_LAYER = 'spatialNeighborhoodLayer'[source]
SPATIAL_ORBIT_AXIS = 'spatialOrbitAxis'[source]
SPATIAL_POINT_LAYER = 'spatialPointLayer'[source]
SPATIAL_RASTER_LAYERS = 'spatialRasterLayers'[source]
SPATIAL_ROTATION_ORBIT = 'spatialRotationOrbit'[source]
SPATIAL_ROTATION_X = 'spatialRotationX'[source]
SPATIAL_ROTATION_Y = 'spatialRotationY'[source]
SPATIAL_ROTATION_Z = 'spatialRotationZ'[source]
SPATIAL_SEGMENTATION_LAYER = 'spatialSegmentationLayer'[source]
SPATIAL_TARGET_X = 'spatialTargetX'[source]
SPATIAL_TARGET_Y = 'spatialTargetY'[source]
SPATIAL_TARGET_Z = 'spatialTargetZ'[source]
SPATIAL_ZOOM = 'spatialZoom'[source]
TOOLTIPS_VISIBLE = 'tooltipsVisible'[source]
class vitessce.constants.DataType(value)[source]

An enum type representing the type of data contained in a file.

CELLS = 'cells'[source]
CELL_SETS = 'cell-sets'[source]
EXPRESSION_MATRIX = 'expression-matrix'[source]
FEATURE_LABELS = 'featureLabels'[source]
GENOMIC_PROFILES = 'genomic-profiles'[source]
IMAGE = 'image'[source]
MOLECULES = 'molecules'[source]
NEIGHBORHOODS = 'neighborhoods'[source]
OBS_EMBEDDING = 'obsEmbedding'[source]
OBS_FEATURE_MATRIX = 'obsFeatureMatrix'[source]
OBS_LABELS = 'obsLabels'[source]
OBS_LOCATIONS = 'obsLocations'[source]
OBS_SEGMENTATIONS = 'obsSegmentations'[source]
OBS_SETS = 'obsSets'[source]
RASTER = 'raster'[source]
class vitessce.constants.FileType(value)[source]

An enum type representing the file format or schema to which a file conforms.

ANNDATA_CELLS_ZARR = 'anndata-cells.zarr'[source]
ANNDATA_CELL_SETS_ZARR = 'anndata-cell-sets.zarr'[source]
ANNDATA_EXPRESSION_MATRIX_ZARR = 'anndata-expression-matrix.zarr'[source]
ANNDATA_ZARR = 'anndata.zarr'[source]
CELLS_JSON = 'cells.json'[source]
CELL_SETS_JSON = 'cell-sets.json'[source]
CLUSTERS_JSON = 'clusters.json'[source]
EXPRESSION_MATRIX_ZARR = 'expression-matrix.zarr'[source]
FEATURE_LABELS_ANNDATA_ZARR = 'featureLabels.anndata.zarr'[source]
FEATURE_LABELS_CSV = 'featureLabels.csv'[source]
GENES_JSON = 'genes.json'[source]
GENOMIC_PROFILES_ZARR = 'genomic-profiles.zarr'[source]
IMAGE_OME_ZARR = 'image.ome-zarr'[source]
MOLECULES_JSON = 'molecules.json'[source]
NEIGHBORHOODS_JSON = 'neighborhoods.json'[source]
OBS_EMBEDDING_ANNDATA_ZARR = 'obsEmbedding.anndata.zarr'[source]
OBS_EMBEDDING_CELLS_JSON = 'obsEmbedding.cells.json'[source]
OBS_EMBEDDING_CSV = 'obsEmbedding.csv'[source]
OBS_FEATURE_MATRIX_ANNDATA_ZARR = 'obsFeatureMatrix.anndata.zarr'[source]
OBS_FEATURE_MATRIX_CSV = 'obsFeatureMatrix.csv'[source]
OBS_LABELS_ANNDATA_ZARR = 'obsLabels.anndata.zarr'[source]
OBS_LABELS_CSV = 'obsLabels.csv'[source]
OBS_LOCATIONS_ANNDATA_ZARR = 'obsLocations.anndata.zarr'[source]
OBS_LOCATIONS_CELLS_JSON = 'obsLocations.cells.json'[source]
OBS_LOCATIONS_CSV = 'obsLocations.csv'[source]
OBS_SEGMENTATIONS_ANNDATA_ZARR = 'obsSegmentations.anndata.zarr'[source]
OBS_SEGMENTATIONS_CELLS_JSON = 'obsSegmentations.cells.json'[source]
OBS_SEGMENTATIONS_JSON = 'obsSegmentations.json'[source]
OBS_SETS_ANNDATA_ZARR = 'obsSets.anndata.zarr'[source]
OBS_SETS_CELL_SETS_JSON = 'obsSets.cell-sets.json'[source]
OBS_SETS_CSV = 'obsSets.csv'[source]
OBS_SETS_JSON = 'obsSets.json'[source]
RASTER_JSON = 'raster.json'[source]
class vitessce.constants.ViewType(value)[source]

An enum type representing a view type in the visualization layout.

CELL_SETS = 'cellSets'[source]
CELL_SET_EXPRESSION = 'cellSetExpression'[source]
CELL_SET_SIZES = 'cellSetSizes'[source]
DESCRIPTION = 'description'[source]
FEATURE_LIST = 'featureList'[source]
FEATURE_VALUE_HISTOGRAM = 'featureValueHistogram'[source]
GATING = 'gating'[source]
GENES = 'genes'[source]
GENOMIC_PROFILES = 'genomicProfiles'[source]
HEATMAP = 'heatmap'[source]
LAYER_CONTROLLER = 'layerController'[source]
OBS_SETS = 'obsSets'[source]
OBS_SET_FEATURE_VALUE_DISTRIBUTION = 'obsSetFeatureValueDistribution'[source]
OBS_SET_SIZES = 'obsSetSizes'[source]
SCATTERPLOT = 'scatterplot'[source]
SPATIAL = 'spatial'[source]
STATUS = 'status'[source]