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

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

Open
tsvvas opened this issue Oct 9, 2024 · 3 comments
Open

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

tsvvas opened this issue Oct 9, 2024 · 3 comments
Labels
images 🖼️ Anything related to Images needs info Needs additional information priority: low

Comments

@tsvvas
Copy link

tsvvas commented Oct 9, 2024

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

@LucaMarconato
Copy link
Member

Hi, for coloring the channels please use the palette argument.

Regarding coordinates yes, once you identify the transformation from the physical coordinate system to the global one, you would need to transform the coordinates and use these in the bounding box query.

We are going to improve the ergonomics of this as described in these issues (except for 338, which is unrelated): https://github.com/scverse/spatialdata/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20physical

@LucaMarconato
Copy link
Member

Also please check my comment here (which answers almost a duplicate of question 2): scverse/spatialdata-io#205

@timtreis
Copy link
Member

Hey @tsvvas,

I assume you have an image with 4 channels that you're trying to map the individual colors to, right? As Luca said, you can use the palette argument for this, see here:

Image

Please let us know if that solves your issue :)

@timtreis timtreis added needs info Needs additional information priority: low images 🖼️ Anything related to Images labels Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
images 🖼️ Anything related to Images needs info Needs additional information priority: low
Projects
None yet
Development

No branches or pull requests

3 participants