Skip to content

Commit

Permalink
NickAkhmetov/CAT-665 Improve builder support for vislifting pyramids (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
NickAkhmetov authored May 21, 2024
1 parent 29dc9ac commit 8d8e16e
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 23 deletions.
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.4
0.2.5
49 changes: 27 additions & 22 deletions src/portal_visualization/builder_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ def process_hints(hints):
is_anndata = "anndata" in hints
is_json = "json_based" in hints
is_spatial = "spatial" in hints
is_support = "is_support" in hints

return is_image, is_rna, is_atac, is_sprm, is_codex, is_anndata, is_json, is_spatial
return is_image, is_rna, is_atac, is_sprm, is_codex, is_anndata, is_json, is_spatial, is_support


# This function is the main entrypoint for the builder factory.
Expand All @@ -54,27 +55,12 @@ def get_view_config_builder(entity, get_assaytype, parent=None):
assay = get_assaytype(entity)
assay_name = assay.get('assaytype')
hints = assay.get('vitessce-hints', [])
is_image, is_rna, is_atac, is_sprm, is_codex, is_anndata, is_json, is_spatial = process_hints(
is_image, is_rna, is_atac, is_sprm, is_codex, is_anndata, is_json, is_spatial, is_support = process_hints(
hints)
if is_image:
if is_rna:
# e.g. Visium (no probes) [Salmon + Scanpy]
# sample entity (on dev): 72ec02cf1390428c1e9dc2c88928f5f5
return SpatialMultiomicAnnDataZarrViewConfBuilder
if is_sprm and is_anndata:
# e.g. CellDIVE [DeepCell + SPRM]
# sample entity: c3be5650e93907b68ddbdb22b948db32
return MultiImageSPRMAnndataViewConfBuilder
if is_codex:
if is_json:
# legacy JSON-based dataset, e.g. b69d1e2ad1bf1455eee991fce301b191
return TiledSPRMViewConfBuilder
# e.g. CODEX [Cytokit + SPRM]
# sample entity: 43213991a54ce196d406707ffe2e86bd
return StitchedCytokitSPRMViewConfBuilder

# vis-lifted image pyramids
if (parent is not None):
# vis-lifted image pyramids
if (parent is not None):
if (is_support and is_image):
ancestor_assaytype = get_assaytype(parent).get('assaytype')
if SEQFISH == ancestor_assaytype:
# e.g. parent = c6a254b2dc2ed46b002500ade163a7cc
Expand All @@ -92,6 +78,25 @@ def get_view_config_builder(entity, get_assaytype, parent=None):
# e.g. parent = 8adc3c31ca84ec4b958ed20a7c4f4919
# e.g. support = f9ae931b8b49252f150d7f8bf1d2d13f
return ImagePyramidViewConfBuilder
else:
return NullViewConfBuilder

if is_image:
if is_rna:
# e.g. Visium (no probes) [Salmon + Scanpy]
# sample entity (on dev): 72ec02cf1390428c1e9dc2c88928f5f5
return SpatialMultiomicAnnDataZarrViewConfBuilder
if is_sprm and is_anndata:
# e.g. CellDIVE [DeepCell + SPRM]
# sample entity: c3be5650e93907b68ddbdb22b948db32
return MultiImageSPRMAnndataViewConfBuilder
if is_codex:
if is_json:
# legacy JSON-based dataset, e.g. b69d1e2ad1bf1455eee991fce301b191
return TiledSPRMViewConfBuilder
# e.g. CODEX [Cytokit + SPRM]
# sample entity: 43213991a54ce196d406707ffe2e86bd
return StitchedCytokitSPRMViewConfBuilder

if is_rna:
# multiomic mudata, e.g. 10x Multiome, SNARE-Seq, etc.
Expand All @@ -115,6 +120,6 @@ def get_view_config_builder(entity, get_assaytype, parent=None):
return NullViewConfBuilder


def has_visualization(entity, get_assaytype):
builder = get_view_config_builder(entity, get_assaytype)
def has_visualization(entity, get_assaytype, parent=None):
builder = get_view_config_builder(entity, get_assaytype, parent)
return builder != NullViewConfBuilder
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"assaytype": "image_pyramid",
"contains-pii": false,
"description": "Image Pyramid",
"primary": false,
"vitessce-hints": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"primary": false,
"vitessce-hints": [
"is_image",
"is_support",
"pyramid"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
null
26 changes: 26 additions & 0 deletions test/good-fixtures/NullViewConfBuilder/fake-no-support-entity.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"data_types": [
"image_pyramid",
"PAS"
],
"status": "QA",
"immediate_ancestors": [
{
"data_types": ["PAS"]
}
],
"files": [
{
"rel_path": "ometiff-pyramids/processedMicroscopy/VAN0003-LK-33-2-PAS_FFPE.ome.tif"
},
{
"rel_path": "ometiff-pyramids/separate/should-be-ignored.ome.tif"
},
{
"rel_path": "output_offsets/processedMicroscopy/VAN0003-LK-33-2-PAS_FFPE.offsets.json"
}
],
"uuid": "f9ae931b8b49252f150d7f8bf1d2d13f-bad",
"metadata": {"dag_provenance_list": []},
"parent": { "uuid": "8adc3c31ca84ec4b958ed20a7c4f4919" }
}

0 comments on commit 8d8e16e

Please sign in to comment.