Marsilea-viz / marsilea

Declarative creation of composable visualization for Python (Complex heatmap, Upset plot, Oncoprint and more~)
https://marsilea.rtfd.io/
MIT License
174 stars 6 forks source link

Missing color blocks on chunks #52

Closed spatts14 closed 1 week ago

spatts14 commented 2 weeks ago

Describe the issue

Missing color blocks on chunks

Code for reproduction


h = ma.Heatmap(df, cmap="Reds", label="Expression", height=3, width=4)
h.group_rows(adata_subset.obs["new_clusters_fibro_extended"])

chunk = mp.Chunk(order, rotation=0, align="center")
colors = mp.Colors(adata_subset.obs["new_clusters_fibro_extended"], palette=re_cluster_colors_palette_extended_dict)

h.add_left(colors, size=0.5, pad=0.3)
h.add_left(chunk)
#h.add_bottom(ma.plotter.Labels(df.columns))

h.add_title(f"Expression of genes of interest in fibroblast subsets ({subset} mice)")
h.add_legends()
h.render()

Actual outcome

See below (image wouldn't attach)

Expected outcome

I don’t know why Im not seeing the color blocks on the left like the tutorial. I can generate tutorial plots fine so I know it isn't an install bug. Can you please help me understand what Im doing wrong in the syntax?

Additional information

No response

Marsilea Version

import marsilea; print(marsilea.version)

spatts14 commented 2 weeks ago

f263ec4b-cf7e-4f52-a1ee-eaadd48c145f

Mr-Milk commented 2 weeks ago

Hi Sara, thanks for using Marsilea. This is expected behavior.

In Chunk, you need to specify the fill_colors parameter to have color or colors in the background. Please see Chunk.

Mr-Milk commented 2 weeks ago

By the way, did you change some default matplotlib settings? Because the colorbar for the heatmap is gone.

spatts14 commented 2 weeks ago

Thanks for the quick response!

I didn't change anything in the default matplotlib. I also was wondering why that occurred... Additionally, I added the fill_colors but I thought by default I shou Screenshot 2024-11-12 at 1 59 46 PM ld get color blocks in between the labels and heat map like this

spatts14 commented 2 weeks ago

Instead when I add a list of colors to fill_color I get this

order = ["Alveolar_1", "Alveolar_2", "Peribronchial", "Adventitial_1", "Adventitial_2", "Pericytes"]
colors_list = ["#4A90E2", "#F5A623", "#50E3C2", "#9013FE", "#FF6B6B", "#4A4A4A"]

h = ma.Heatmap(df, cmap="Reds", label="Expression", height=3, width=4)
h.group_rows(adata_subset.obs["new_clusters_fibro_extended"])

chunk = mp.Chunk(order, rotation=0, align="center", fill_colors=colors_list)
colors = mp.Colors(adata_subset.obs["new_clusters_fibro_extended"])

h.add_left(colors, size=0.5, pad=0.3)
h.add_left(chunk)
#h.add_bottom(ma.plotter.Labels(df.columns))

h.add_title(f"Expression of genes of interest in fibroblast subsets ({subset} mice)")
h.add_legends()
h.render()
Screenshot 2024-11-12 at 2 00 29 PM
spatts14 commented 2 weeks ago

Also I corrected the issue title to remove bug as I think there is something I am not understanding or doing wrong?

Mr-Milk commented 2 weeks ago

I think you are confused with two plotters Colors and Chunk, Colors is to visualize categorical data on each row or column as colors. Chunk will span multiple rows or columns to serve as a subtitle-like purpose. If you want to visualize continuous data to replace Colors, please use ColorMesh.

You can check out the gallery at https://marsilea.readthedocs.io/en/stable/examples/index.html to have an idea on what each plotter does.