BayraktarLab / cell2location

Comprehensive mapping of tissue cell architecture via integrated single cell and spatial transcriptomics (cell2location model)
https://cell2location.readthedocs.io/en/latest/
Apache License 2.0
324 stars 58 forks source link

How to show the min,med&max values on the multiple cell types plot #180

Open rue1996 opened 2 years ago

rue1996 commented 2 years ago

Please use the template below to post a question to https://discourse.scverse.org/c/ecosytem/cell2location/.

Problem

when running this code : from cell2location.plt import plot_spatial

select up to 6 clusters

clust_labels = ['T_CD4+_naive', 'B_naive', 'FDC'] clust_col = ['' + str(i) for i in clust_labels] # in case column names differ from labels

slide = select_slide(adata_vis, 'V1_Human_Lymph_Node')

with mpl.rc_context({'figure.figsize': (15, 15)}): fig = plot_spatial( adata=slide,

labels to show on a plot

    color=clust_col, labels=clust_labels,
    show_img=True,
    # 'fast' (white background) or 'dark_background'
    style='fast',
    # limit color scale at 99.2% quantile of cell abundance
    max_color_quantile=0.992,
    # size of locations (adjust depending on figure size)
    circle_diameter=6,
    colorbar_position='right'
)

Is there a way to make the plot show the min,median & max abundance values of each cell type? When i run it, it either shows the median & max values or just the median. Screenshot (614)

...

Description of the data input and hyperparameters

...

...

Single cell reference data: number of cells, number of cell types, number of genes

...

Single cell reference data: technology type (e.g. mix of 10X 3' and 5')

...

Spatial data: number of locations numbers, technology type (e.g. Visium, ISS, Nanostring WTA)

...

vitkl commented 2 years ago

@yozhikoff Do you have any idea? Would be good if people see all 3 numbers

rue1996 commented 2 years ago

Hi guys

Any update on this question?

Thanks

vitkl commented 2 years ago

Solving this in full requires quite advanced matplotib knowledge.

As a hack, I can suggest playing with max_color_quantile to change the colour scale max value and changing: colorbar_position – ‘bottom’, ‘right’ or None colorbar_label_kw – dict that will be forwarded to ax.set_label() colorbar_shape – dict {‘vertical_gaps’: 1.5, ‘horizontal_gaps’: 1.5, ‘width’: 0.2, ‘height’: 0.2}, not obligatory to contain all params colorbar_tick_size – colorbar ticks label size colorbar_grid – tuple of colorbar grid (rows, columns)

You can check this notebook for some examples (like how to move the legend to the bottom part of the plot https://github.com/vitkl/cell2location_paper/blob/master/notebooks/mouse_brain_visium/analysis_4_Fig3CED_Fig2DEFG_FigS6E_pyro.ipynb