scverse / scverse/scanpy

pl.embedding sets uns.<field>_colors when palette=None

Open
#2,311 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.6k
Forks
779
Avg merge
1d 4h
Merged PRs (30d)
27

Description

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of scanpy.
  • (optional) I have confirmed this bug exists on the master branch of scanpy.

From pl.embedding documentation, for palette, it states

If provided, values of adata.uns["{var}_colors"] will be set.

This implies that if not provided, then those values will not be set.
However, they are being set - either without specifying palette (default:None), or explicitly passing palette=None
Either it's a bug, or the documentation is not clear.

Minimal code sample (that we can copy&paste without having any data)
adata = sc.read_h5ad('my_matrix.h5ad')
adata.uns = {} #confirming *_colors is not set already
sc.pl.embedding(adata, basis='X_umap', palette=None, color=['cell_type'])
adata.uns['cell_type_colors']
['#1f77b4',
 '#ff7f0e',
 '#279e68',
 '#d62728',
 '#aa40fc',
 '#8c564b',
 '#e377c2',
 '#b5bd61',
 '#17becf']

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the scanpy.pl.embedding entry point and the linked palette documentation, then reproduce the minimal example with palette omitted and with palette=None. Trace where adata.uns["cell_type_colors"] is set and determine whether the behavior or the documentation should change; done means the implementation and documented palette semantics agree.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.