Visualization of 3k PBMC reference from Remote Zarr Store

1. Import dependencies

We need to import the classes and functions that we will be using from the corresponding packages.

[ ]:
import os
from os.path import join
from urllib.request import urlretrieve
from anndata import read_h5ad
import scanpy as sc

from vitessce import (
    VitessceConfig,
    Component as cm,
    CoordinationType as ct,
    AnnDataWrapper,
)

2. Set the URL for the Remote Dataset

For this example, we already have uploaded the pbmc3k dataset as a zarr store from the scanpy docs to the cloud.

[ ]:
url = 'https://storage.googleapis.com/vitessce-demo-data/anndata-test/pbmc3k_processed.zarr/'

3. Create a Vitessce view config

Define the data and views you would like to include in the widget.

[ ]:
vc = VitessceConfig(name='PBMC Reference')
dataset = vc.add_dataset(name='PBMC 3k').add_object(AnnDataWrapper(adata_url=url, cell_set_obs=["louvain"], cell_set_obs_names=["Louvain"], mappings_obsm=["X_umap", "X_pca"], mappings_obsm_names=["UMAP", "PCA"], expression_matrix="X"))

umap = vc.add_view(cm.SCATTERPLOT, dataset=dataset, mapping="UMAP")
pca = vc.add_view(cm.SCATTERPLOT, dataset=dataset, mapping="PCA")
cell_sets = vc.add_view(cm.CELL_SETS, dataset=dataset)
genes = vc.add_view(cm.GENES, dataset=dataset)
heatmap = vc.add_view(cm.HEATMAP, dataset=dataset)

vc.layout((umap / pca) | ((cell_sets | genes) / heatmap));

4. Create the Vitessce widget

A widget can be created with the .widget() method on the config instance. Here, the proxy=True parameter allows this widget to be used in a cloud notebook environment, such as Binder.

[ ]:
vw = vc.widget()
vw