Visualization of genomic profiles

1. Import dependencies

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

[ ]:
from vitessce import (
    Component as cm,
    CoordinationType as ct,
from os.path import join
from import mmread
import pandas as pd
import numpy as np

2. Load the data

In this step, we load the raw data that has been downloaded from the HuBMAP portal

[ ]:
mtx = mmread(join('data', 'snapatac', 'filtered_cell_by_bin.mtx'))
barcodes_df = pd.read_csv(join('data', 'snapatac', 'barcodes.txt'), header=None)
bins_df = pd.read_csv(join('data', 'snapatac', 'bins.txt'), header=None)
clusters_df = pd.read_csv(join('data', 'snapatac', 'umap_coords_clusters.csv'), index_col=0)

3. Wrap the data into a Vitessce-compatible wrapper object

These wrapper objects contain methods for data conversion, which the widget will use internally to obtain data for visualization. The vitessce package contains wrapper classes for many common single-cell data types, as well as an abstract class AbstractWrapper, which can be used as a parent class for custom wrapper class implementations.

Here, we want to use the SnapWrapper class because our data has been processed by the SnapATAC pipeline.

[ ]:
w = SnapWrapper(mtx, barcodes_df, bins_df, clusters_df)

4. Make a Vitessce configuration

We need to tell Vitessce about the data that we want to load and the visualization components that we want to include in the widget. For this dataset, we want to add the GENOMIC_PROFILES component, which renders genome browser tracks with HiGlass.

[ ]:
vc = VitessceConfig(name='HuBMAP snATAC-seq')
dataset = vc.add_dataset(name='HBM485.TBWH.322').add_object(w)
genomic_profiles = vc.add_view(dataset, cm.GENOMIC_PROFILES)
scatter = vc.add_view(dataset, cm.SCATTERPLOT, mapping = "UMAP")
cell_sets = vc.add_view(dataset, cm.CELL_SETS)

vc.layout(genomic_profiles / (scatter | cell_sets));

5. Create the widget

[ ]:
vw = vc.widget(height=800)