heatmap matrix #1737
-
I am trying to create a heatmap of cluster matrices and their intensity. The data has already been calculated by me. I found in the documentation the possibility of such an approach, but I did not find examples of use to see what the structure of the Zarr archive should be in order to see a similar matrix. i have this matrix adata.uns['global_clq'] |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
@zverozabr Mark would know better than I the status of the custom heatmap format, but I don't believe there is any issue except providing a dense zarr matrix, except that its dimensions should match those with which it is coordinated (i.e., points on a UMAP and the {
"fileType": "obsFeatureMatrix.anndata.zarr",
"url": "https://example.com/my_adata.zarr",
"coordinationValues": {},
"options": {
"path": "uns/gloabl_clq"
}
}, I'm not sure if |
Beta Was this translation helpful? Give feedback.
-
The heatmap in Vitessce assumes that one axis represents "observations" and the other represents "features". We need to create a new AnnData object that has the clusters along both from anndata import AnnData
import pandas as pd
obs = pd.DataFrame(index=[4, 6, 7, 11, -1, 9, 0], columns=[], data=[])
var = pd.DataFrame(index=[4, 6, 7, 11, -1, 9, 0], columns=[], data=[])
cluster_adata = AnnData(X=None, obs=obs, var=var)
cluster_adata.layers['global_clq'] = adata.uns['global_clq']
cluster_adata.layers['clq_perm'] = adata.uns['clq_perm']
cluster_adata.write_zarr('clusters.h5ad.zarr') Then the JSON snippet to configure this would look like: {
"fileType": "obsFeatureMatrix.anndata.zarr",
"url": "https://example.com/clusters.h5ad.zarr",
"coordinationValues": {
"obsType": "cluster",
"featureType": "cluster",
"featureValueType": "global_clq"
},
"options": {
"path": "layers/global_clq"
}
},
{
"fileType": "obsFeatureMatrix.anndata.zarr",
"url": "https://example.com/clusters.h5ad.zarr",
"coordinationValues": {
"obsType": "cluster",
"featureType": "cluster",
"featureValueType": "clq_perm"
},
"options": {
"path": "layers/clq_perm"
}
} Using the python API it would look like: from vitessce import (
VitessceConfig,
AnnDataWrapper,
ViewType as vt
)
vc = VitessceConfig(schema_version="1.0.16")
dataset = vc.add_dataset("clusters").add_object(AnnDataWrapper(
adata_path = 'clusters.h5ad.zarr',
obs_feature_matrix_path = "layers/global_clq",
coordination_values={
"obsType": "cluster",
"featureType": "cluster",
"featureValueType": "global_clq"
}
)).add_object(AnnDataWrapper(
adata_path = 'clusters.h5ad.zarr',
obs_feature_matrix_path = "layers/clq_perm",
coordination_values={
"obsType": "cluster",
"featureType": "cluster",
"featureValueType": "clq_perm"
}
))
heatmap_global = vc.add_view(vt.HEATMAP, dataset = dataset)
heatmap_local = vc.add_view(vt.HEATMAP, dataset = dataset)
vc.link_views([heatmap_global, heatmap_local], ["obsType", "featureType"], ["cluster", "cluster"])
vc.link_views([heatmap_global], ["featureValueType"], ["global_clq"])
vc.link_views([heatmap_local], ["featureValueType"], ["clq_perm"])
vc.layout(heatmap_global | heatmap_local) |
Beta Was this translation helpful? Give feedback.
The heatmap in Vitessce assumes that one axis represents "observations" and the other represents "features".
If we consider each cluster as an "observation", then in this case we need to kind of trick Vitessce into showing the data.
We need to create a new AnnData object that has the clusters along both
obs
(observations) andvar
(features) axes. We can store two matrices aligned to these axes usinglayers
: