Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #132 #134

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions muon/_core/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def scatter(
data: Union[AnnData, MuData],
x: Optional[str] = None,
y: Optional[str] = None,
color: Optional[Union[str, Sequence[str]]] = None,
color: Optional[str] = None,
use_raw: Optional[bool] = None,
layers: Optional[Union[str, Sequence[str]]] = None,
**kwargs,
Expand All @@ -42,8 +42,8 @@ def scatter(
x coordinate
y : Optional[str]
y coordinate
color : Optional[Union[str, Sequence[str]]], optional (default: None)
Keys for variables or annotations of observations (.obs columns),
color : Optional[str], optional (default: None)
Key for variables or annotations of observations (.obs columns),
or a hex colour specification.
use_raw : Optional[bool], optional (default: None)
Use `.raw` attribute of the modality where a feature (from `color`) is derived from.
Expand Down Expand Up @@ -72,10 +72,10 @@ def scatter(
if isinstance(color, str):
color_obs = _get_values(data, color, use_raw=use_raw, layer=layers[2])
color_obs = pd.DataFrame({color: color_obs})
color = [color]
else:
# scanpy#311 / scanpy#1497 has to be fixed for this to work
color_obs = _get_values(data, color, use_raw=use_raw, layer=layers[2])
raise TypeError("Expected color to be a string.")


color_obs.index = data.obs_names
obs = pd.concat([obs, color_obs], axis=1, ignore_index=False)

Expand All @@ -86,14 +86,14 @@ def scatter(
# and are now stored in .obs
retval = sc.pl.scatter(ad, x=x, y=y, color=color, **kwargs)
if color is not None:
for col in color:
try:
data.uns[f"{col}_colors"] = ad.uns[f"{col}_colors"]
except KeyError:
pass
try:
data.uns[f"{color}_colors"] = ad.uns[f"{color}_colors"]
except KeyError:
pass
return retval



#
# Embedding
#
Expand Down
Loading