def buildVitessceConfig(adata, area_name): vc = VitessceConfig("Developing human neocortex: gestational week 20") dataset = vc.add_dataset(area_name).add_object( # The`add_object()` function converts the AnnData data structure into a [Zarr] # (https://zarr.readthedocs.io/en/stable/) store that is compatible with Vitessce. AnnDataWrapper(adata, mappings_obsm=["X_tsne"], mappings_obsm_names=["t-SNE"], expression_matrix="X", spatial_centroid_obsm="X_spatial")) spatial_plot = vc.add_view(dataset, cm.SPATIAL) tsne_plot = vc.add_view(dataset, cm.SCATTERPLOT, mapping="t-SNE") heatmap = vc.add_view(dataset, cm.HEATMAP) genes_list = vc.add_view(dataset, cm.GENES) vc.layout((spatial_plot | tsne_plot) / (heatmap | genes_list)) return vc
def test_config_set_layout_single_view(self): vc = VitessceConfig() my_dataset = vc.add_dataset(name='My Dataset') my_view = vc.add_view(cm.SPATIAL, dataset=my_dataset) vc.layout(my_view) vc_dict = vc.to_dict() vc_json = json.dumps(vc_dict) self.assertEqual( vc_dict, { "version": "1.0.4", "name": "", "description": "", "datasets": [{ 'uid': 'A', 'name': 'My Dataset', 'files': [] }], 'coordinationSpace': { 'dataset': { 'A': 'A' }, }, "layout": [{ 'component': 'spatial', 'coordinationScopes': { 'dataset': 'A', }, 'x': 0, 'y': 0, 'h': 12, 'w': 12, }], "initStrategy": "auto" })