Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NickAkhmetov/Improve vis-lifting logic, add visium support #84

Merged
merged 16 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ package_dir =
packages = find:
python_requires = >=3.7
install_requires =
vitessce==3.2.2
vitessce==3.2.3
hubmap-commons>=2.0.12
requests>=2.27.1
nbformat==5.1.3
Expand Down
54 changes: 13 additions & 41 deletions src/portal_visualization/builders/anndata_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
Component as cm,
CoordinationType as ct,
ImageOmeTiffWrapper,
CoordinationLevel as CL
CoordinationLevel as CL,
get_initial_coordination_scope_prefix
)

import numpy as np
Expand Down Expand Up @@ -305,46 +306,28 @@ def _set_up_dataset(self, vc):
image_url = self._build_assets_url(
'ometiff-pyramids/visium_histology_hires_pyramid.ome.tif', use_token=True)
# Add dataset with Visium image and secondary analysis anndata
dataset_uid = self._uuid
visium_image = ImageOmeTiffWrapper(
img_url=image_url,
uid="visium",
uid=dataset_uid,
NickAkhmetov marked this conversation as resolved.
Show resolved Hide resolved
request_init=self._get_request_init(),
coordination_values={
"fileUid": "visium"
}
)
visium_spots = AnnDataWrapper(
adata_url=adata_url,
obs_feature_matrix_path="X",
obs_spots_path="obsm/X_spatial",
obs_labels_names=self._obs_labels_names,
obs_labels_paths=self._obs_labels_paths,
feature_labels_path="var/hugo_symbol",
request_init=self._get_request_init(),
coordination_values={
"obsType": "spot",
"featureType": "gene",
"featureLabelsType": "gene",
}
)
obs_sets = AnnDataWrapper(
adata_url=adata_url,
obs_feature_matrix_path="X",
obs_set_paths=self._obs_set_paths,
obs_set_names=self._obs_set_names,
obs_labels_names=self._obs_labels_names,
obs_labels_paths=self._obs_labels_paths,
obs_locations_path="obsm/X_spatial",
obs_spots_path="obsm/X_spatial",
obs_embedding_paths=["obsm/X_umap", "obsm/X_pca"],
obs_embedding_names=["UMAP", "PCA"],
obs_embedding_dims=[[0, 1], [0, 1]],
feature_labels_path="var/hugo_symbol",
request_init=self._get_request_init(),
initial_feature_filter_path="var/top_highly_variable",
coordination_values={
"obsType": "cell",
"featureType": "gene",
"featureLabelsType": "gene",
"obsType": "spot",
}
)
dataset = vc.add_dataset(
Expand All @@ -353,8 +336,6 @@ def _set_up_dataset(self, vc):
visium_image
).add_object(
visium_spots
).add_object(
obs_sets
)
return dataset

Expand Down Expand Up @@ -392,30 +373,21 @@ def _setup_anndata_view_config(self, vc, dataset):

self._views = all_views

spot_views = [spatial, lc]
spatial_views = [spatial, lc]

# selected_gene_views = [umap, gene_list, heatmap, spatial]

# Link spatial view and layer controller
vc.link_views_by_dict(all_views, {
"spatialTargetZ": 0,
"spatialTargetT": 0,
# Indicate obs type for all views
vc.link_views(all_views, ['obsType'], ['spot'])
vc.link_views_by_dict(spatial_views, {
"imageLayer": CL([{
"fileUid": 'visium',
"spatialLayerOpacity": 1,
"spatialLayerVisible": True,
"photometricInterpretation": 'RGB',
}]),
}, scope_prefix=get_initial_coordination_scope_prefix(self._uuid, 'image'))
vc.link_views_by_dict(spatial_views, {
"spotLayer": CL([{
"obsType": 'spot',
"spatialLayerVisible": True,
"spatialLayerOpacity": 0.5,
"spatialSpotRadius": self._get_scale_factor(),
"featureValueColormapRange": [0, 1],
}]),
})

# Indicate obs type for all views
vc.link_views(spot_views, ['obsType'], ['spot'])

}, scope_prefix=get_initial_coordination_scope_prefix(self._uuid, 'obsSpots'))
return vc
Loading
Loading