scverse / scverse/spatialdata-plot

Q: How to render xenium morphology image with original colors?

Open
#370 15 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

images :framed_picture: needs info priority: low
Dominant language
Python
Stars
86
Forks
21
Avg merge
14h 50m
Merged PRs (30d)
3

Description

Hello @LucaMarconato!

Thank you very much for this tool. I want to plot a part of morphology image acquired with xenium + multimodal segmentation kit. It is loaded into spatialdata and plotted without errors, but the colors are dim and they are different from what I'd expected (DAPI - #0F73E6, Boundary - #F300A5, Interior RNA - #A4A400, interior protein - #008A00, reference values from Xenium Explorer). I tried passing a list of colors like this:

crop = lambda sdata: spatialdata.bounding_box_query(
    sdata,
    min_coordinate=[17_500, 55_000],
    max_coordinate=[19_500, 57_000],
    axes=("x", "y"),
    target_coordinate_system="global",
)

crop(sdata).pl.render_images("morphology_focus", ["#0F73E6", "#F300A5", "#A4A400", "#008A00"]).pl.show(
    ax=axes[0], title="Morphology image", coordinate_systems="global"
)

The code does not produce an error, it works twice as long, and it results in the same image with colors unchanged.

The key question is how to adjust the colors and saturation of the plot, so that it looked closer to what I see in Xenium Explorer?

Secondary question is how to translate physical coordinates into spatialdata's global coordinate system? Am I supposed to get transformation and then apply transformation to a single or a couple points to get min and max for cropping above? I can make a separate issue with this question, if necessary.

Best,
Vasily

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the render_images call on morphology_focus and trace how its color arguments affect the plotted image. Compare the rendered colors with the Xenium Explorer reference values, and separately inspect how bounding_box_query uses the global coordinate system for the supplied physical coordinates. Done means the color behavior and coordinate conversion are documented or corrected with a reproducible example.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.