Added channels_metadata to plate root zarr.json#197
Added channels_metadata to plate root zarr.json#197exxpyy wants to merge 3 commits intozarr3-transitionfrom
Conversation
|
Make sure to ruff check and format this before finalizing. |
workflow/lib/shared/hcs.py
Outdated
| entry["name"] = name | ||
|
|
||
| entry.setdefault("description", "") | ||
| entry["channel_type"] = "fluorescent" # since we only have fluorescent channels |
There was a problem hiding this comment.
This overwrites whatever the user put in config. Should be entry.setdefault("channel_type", "fluorescent") instead. The BioHub spec uses labelfree, virtual_stain, etc. — we'll need those eventually and this line would silently eat them.
workflow/lib/shared/hcs.py
Outdated
| # Ensure biological_annotation exists | ||
| bio = entry.get("biological_annotation") or {} | ||
| if not isinstance(bio, dict): | ||
| bio = {} | ||
| for k in ("organelle", "marker", "marker_type", "full_label"): | ||
| bio.setdefault(k, "") | ||
| entry["biological_annotation"] = bio |
There was a problem hiding this comment.
The normalize function fills {"organelle": "", "marker": "", "marker_type": "", "full_label": ""} when biological_annotation is empty or {}. Better to omit the key entirely if all values are empty —cleaner JSON. The BioHub spec only includes biological_annotation on channels that actually have annotations (e.g. their Phase2D and Focus3D channels don't have one at all).
workflow/lib/shared/hcs.py
Outdated
| print("hcs.write_hcs_metadata received channels_metadata:") | ||
| print(json.dumps(channels_metadata, indent=2)) |
There was a problem hiding this comment.
Remove these before merging, or add a verbose flag.
| phenotype_samples_fp: config/phenotype_samples.tsv | ||
| phenotype_channels_metadata: | ||
| - name: DAPI | ||
| index: 0 |
There was a problem hiding this comment.
Do we need the index now that it is set explicitly through the code?
workflow/rules/preprocess.smk
Outdated
| params: | ||
| plate_zarr_dirs=[str(PREPROCESS_FP / "sbs" / f"{p}.zarr") | ||
| for p in sorted(sbs_wildcard_combos["plate"].unique())], | ||
| channels_metadata=lambda wildcards: config["preprocess"].get("sbs_channels_metadata", None), |
There was a problem hiding this comment.
Can be simplified as
channels_metadata=config["preprocess"].get("sbs_channels_metadata", None),
workflow/rules/preprocess.smk
Outdated
| ), | ||
| plate_zarr_dirs=[str(PREPROCESS_FP / "phenotype" / f"{p}.zarr") # creates list like 1.zarr, 2.zarr, etc | ||
| for p in sorted(phenotype_wildcard_combos["plate"].unique())], # finding which plates exist | ||
| channels_metadata=lambda wildcards: config["preprocess"].get("phenotype_channels_metadata", None), |
There was a problem hiding this comment.
Same as above. Simplify read in.
Added support for writing channels_metadata into the plate root zarr.json for zarr outputs by passing metadata specific to the module (SBS/phenotype) through Snakemake into the HCS metadata writer. This makes the generated Zarr hierarchy’s root metadata align better with the expected CZI-style root metadata.