Closed vkjain006 closed 1 year ago
Sorry for the delay a bit.
You can change the colors in adata.uns['celltype_colors]
. I'm not sure it works with color name, but if not, you can use hex code instead
Thanks for your reply.
I am new to python.
When you say change colors in adata.uns['celltype_colors'] , can you please share how would the code for it be like. I want to change color by celltype. What I have is something like this where I define color for each cell type.
palette = { "Neuron-1":"skyblue", "Endothelial-1":"cyan", "Neuron-2":"lightskyblue","Neuron-3":"steelblue", "Neuron-4":"deepskyblue","Neuron-5":"lightblue", "Neuron-6":"turquoise","Neuron-7":"dodgerblue", "NSPC-1":"lime","Neuron-8":"lightsteelblue", "OPC-1":"deeppink","Neuron-9":"cornflowerblue", "Neuron-10":"royalblue","Astrocyte-1":"red", "Astrocyte-2":"orangered","Neuron-11":"lavender", "Astrocyte-3":"tomato","NSPC-2":"green", "Neuron-12":"blue","Neuron-13":"mediumpurple", "OPC-2":"hotpink","Neuron-14":"slateblue", "Neuron-15":"rebeccapurple","Neuron-16":"darkslateblue", "NSPC-3":"yellowgreen","Monocyte":"peru", "Neuron-17":"darkblue","Cajal-Retzius-cells":"gray", "Neuron-18":"mediumvioletred","NP-PPP":"olive", "Neuron-19":"midnightblue","Neuron-20":"indigo", "VLMC":"yellow","Astrocyte-4":"darksalmon", "Neuron-21":"blueviolet", }
Now how can I add this info to adata.uns['celltype_colors']
This is my first time analyzing xenium spatial data. There are lot of new analysis to do. One of them is to merge/integrate different tissue sections for xenium data. At some point I need to compare differences between cell types from different tissue sections. I have been able to run squidpy/stlearn on each tissue section individually.
I may have more questions later as I would continue to work on this data. Thanks for all your help.
You need to look at the order of clusters in this adata.obs.celltype.cat.categories
and then you replace the list of colors to adata.uns['celltype_colors']
that follows the order of the clusters.
Example:
# You can try with your color name first. If it doesn't work, then use hex code like this
adata.uns['celltype_colors'] = ['#87CEEB','#00FFFF',...]
Hi,
I am new to analyzing data via scanpy/squidpy and stlearn. I have been using Stlearn xenium tutorial to analyze some xenium spatial data. I have been able to add cell type annotation as separate column in my adata.obs[]
I am using below mention quote to generate spatial plot
colors = ['skyblue','cyan','lightskyblue','steelblue','deepskyblue', 'lightblue','turquoise','dodgerblue','lime','lightsteelblue', 'deeppink','cornflowerblue','royalblue','red','orangered', 'lavender','tomato','green','blue','mediumpurple','hotpink', 'slateblue','rebeccapurple','darkslateblue','yellowgreen', 'peru','darkblue','gray','mediumvioletred','olive','midnightblue', 'indigo', 'yellow','darksalmon','blueviolet']
from matplotlib.colors import LinearSegmentedColormap
cmap1 = LinearSegmentedColormap.from_list("mycmap", colors) cmap1
st.pl.cluster_plot(adata,use_label="celltype", image_alpha=0,size=5,
zoom_coord=[1500,8000,2500,5000],
Code generates the plot, but doesn't change colors of cells. It still shows default colors.
Can you please share how I can give a specific color to each cell type and then generate a plot.
Also I would like to use same color scheme when I would do further down stream analysis like trajectory and cell cell interaction analysis.
Thank you so much.