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(schema_version="1.0.15", name='PBMC Reference')
dataset = vc.add_dataset(name='PBMC 3k').add_object(AnnDataWrapper(adata_url=url, obs_set_paths=["obs/louvain"], obs_set_names=["Louvain"], obs_embedding_paths=["obsm/X_umap", "obsm/X_pca"], obs_embedding_names=["UMAP", "PCA"], obs_feature_matrix_path="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.OBS_SETS, dataset=dataset)
genes = vc.add_view(cm.FEATURE_LIST, 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