Setting colors for obsSets?
srivarra opened this issue · 2 comments
If I have an AnnData
object, is it possible to manually assign colors for the different cell categories? I tried taking a look at obsSetColor
but I wasn't able to figure out how to utilize it.
If it is obsSetColor
is it used with with add_coordination_by_dict
? Something like below?
vc.add_coordination_by_dict({
ct.OBS_COLOR_ENCODING: {
"obs_set_one": ["0", "12" "123"],
"obs_set_two": ["240", "123", "58"],
}
})
As a ease of use functionality, It would be handy if colors could be manually set with the adata.uns["<obs_category_column>_colors"
which is a list of RGB values sorted by adata.obs["<obs_category_column>"].categories.cat
. Many scanpy functions take into account these manual color settings as well when plotting.
Thank you!!
vc.link_views_by_dict([spatial_view, another_view], {
ct.OBS_COLOR_ENCODING: "cellSetSelection",
ct.OBS_SET_SELECTION: [
["colname", "obs_set_one"],
["colname", "obs_set_two"],
],
ct.OBS_SET_COLOR: [
{
"path": ["colname", "obs_set_one"],
"color": [0, 12, 123],
},
{
"path": ["colname", "obs_set_two"],
"color": [240, 123, 58],
},
]
}, meta=False)
Hi @srivarra this can be done with the above. The OBS_COLOR_ENCODING tells Vitessce whether to use the sets (categorical) vs. the gene expression values (quantitative) for colors. (For historical reasons the accepted values for this are the strings cellSetSelection
or geneSelection
despite moving to the more general obs
prefix everywhere else). The OBS_SET_SELECTION is a list of paths for currently-selected sets. The OBS_SET_COLOR is a list of objects like { path, color }
where color is an array of [r, g, b]
values.
Thanks for the suggestion about using the adata.uns
option, I did not know about the _colors
convention in scanpy. I will make a new issue to track that
@keller-mark Thank you very much! I'll go ahead and give this a try!