Skip to content

Commit

Permalink
Add create_coordination_values helper util
Browse files Browse the repository at this point in the history
  • Loading branch information
NickAkhmetov committed Aug 14, 2023
1 parent 1a55416 commit ce8a25d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 38 deletions.
36 changes: 9 additions & 27 deletions src/portal_visualization/builders/scatterplot_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
)


from ..utils import get_conf_cells
from ..utils import create_coordination_values, get_conf_cells
from ..paths import SCRNA_SEQ_DIR, SCATAC_SEQ_DIR
from .base_builders import ViewConfBuilder

Expand Down Expand Up @@ -54,31 +54,22 @@ def __init__(self, entity, groups_token, assets_endpoint, **kwargs):
{
"rel_path": f"{SCRNA_SEQ_DIR}.cells.json",
"file_type": ft.OBS_SEGMENTATIONS_CELLS_JSON,
"coordination_values": {
"obsType": "cell",
},
"coordination_values": create_coordination_values(),
},
{
"rel_path": f"{SCRNA_SEQ_DIR}.cells.json",
"file_type": ft.OBS_LOCATIONS_CELLS_JSON,
"coordination_values": {
"obsType": "cell",
},
"coordination_values": create_coordination_values()
},
{
"rel_path": f"{SCRNA_SEQ_DIR}.cells.json",
"file_type": ft.OBS_EMBEDDING_CELLS_JSON,
"coordination_values": {
"obsType": "cell",
"embeddingType": "UMAP",
},
"coordination_values": create_coordination_values(embeddingType="UMAP")
},
{
"rel_path": f"{SCRNA_SEQ_DIR}.cell-sets.json",
"file_type": ft.OBS_SETS_CELL_SETS_JSON,
"coordination_values": {
"obsType": "cell",
},
"coordination_values": create_coordination_values()
},
]

Expand All @@ -98,33 +89,24 @@ def __init__(self, entity, groups_token, assets_endpoint, **kwargs):
"rel_path": SCATAC_SEQ_DIR
+ "/umap_coords_clusters.cells.json",
"file_type": ft.OBS_SEGMENTATIONS_CELLS_JSON,
"coordination_values": {
"obsType": "cell",
},
"coordination_values": create_coordination_values()
},
{
"rel_path": SCATAC_SEQ_DIR
+ "/umap_coords_clusters.cells.json",
"file_type": ft.OBS_LOCATIONS_CELLS_JSON,
"coordination_values": {
"obsType": "cell",
},
"coordination_values": create_coordination_values()
},
{
"rel_path": SCATAC_SEQ_DIR
+ "/umap_coords_clusters.cells.json",
"file_type": ft.OBS_EMBEDDING_CELLS_JSON,
"coordination_values": {
"obsType": "cell",
"embeddingType": "UMAP",
},
"coordination_values": create_coordination_values(embeddingType="UMAP")
},
{
"rel_path": SCATAC_SEQ_DIR
+ "/umap_coords_clusters.cell-sets.json",
"file_type": ft.OBS_SETS_CELL_SETS_JSON,
"coordination_values": {
"obsType": "cell",
},
"coordination_values": create_coordination_values()
},
]
15 changes: 4 additions & 11 deletions src/portal_visualization/builders/sprm_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
)

from .base_builders import ViewConfBuilder
from ..utils import get_matches, get_conf_cells
from ..utils import create_coordination_values, get_matches, get_conf_cells
from ..paths import (
SPRM_JSON_DIR, STITCHED_REGEX, CODEX_TILE_DIR,
TILE_REGEX, STITCHED_IMAGE_DIR, SPRM_PYRAMID_SUBDIR, IMAGE_PYRAMID_DIR
Expand Down Expand Up @@ -93,25 +93,18 @@ def __init__(self, entity, groups_token, assets_endpoint, **kwargs):
{
"rel_path": f"{SPRM_JSON_DIR}/" + f"{self._base_name}.cells.json",
"file_type": ft.CELLS_JSON,
"coordination_values": {
"obsType": "cell",
},
"coordination_values": create_coordination_values()
},
{
"rel_path": f"{SPRM_JSON_DIR}/" + f"{self._base_name}.cell-sets.json",
"file_type": ft.CELL_SETS_JSON,
"coordination_values": {
"obsType": "cell",
},
"coordination_values": create_coordination_values()

},
{
"rel_path": f"{SPRM_JSON_DIR}/" + f"{self._base_name}.clusters.json",
"file_type": "clusters.json",
"coordination_values": {
"obsType": "cell",
},

"coordination_values": create_coordination_values()
},
]

Expand Down
7 changes: 7 additions & 0 deletions src/portal_visualization/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ def get_matches(files, regex):
)


def create_coordination_values(obs_type='cell', **kwargs):
return {
'obsType': obs_type,
**kwargs
}


def _get_path_name(file):
return Path(file).name

Expand Down

0 comments on commit ce8a25d

Please sign in to comment.