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 squidy.pl.ligrec's pandas usage #625

Merged
merged 3 commits into from Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions requirements.txt
Expand Up @@ -6,7 +6,7 @@ dask[array]>=2021.02.0
docrep>=0.3.1
fsspec>=2021.11.0
leidenalg>=0.8.2
matplotlib>=3.3,!=3.6.1 # https://github.com/matplotlib/matplotlib/issues/24127
matplotlib>=3.3
matplotlib-scalebar>=0.8.0
networkx>=2.6.0
numba>=0.55.0,<0.56.0
Expand All @@ -20,7 +20,6 @@ scikit-learn>=0.24.0
statsmodels>=0.12.0
tifffile!=2022.4.22 # https://github.com/scverse/squidpy/issues/526
tqdm>=4.50.2
typing_extensions
validators>=0.18.2
xarray>=0.16.1
zarr>=2.6.1
4 changes: 0 additions & 4 deletions squidpy/pl/_ligrec.py
Expand Up @@ -293,10 +293,6 @@ def get_dendrogram(adata: AnnData, linkage: str = "complete") -> Mapping[str, An
means = means.T

for cls, size in (pvals.groupby(level=0, axis=1)).size().to_dict().items():
size = np.unique(list(size.values()))
if len(size) != 1:
raise ValueError(f"Expected all groups to have the same number of interacting clusters, found `{size}`.")
size = size[0]
label_ranges[cls] = (start, start + size - 1)
start += size
label_ranges = {k: label_ranges[k] for k in sorted(label_ranges.keys())}
Expand Down
9 changes: 7 additions & 2 deletions squidpy/pl/_spatial_utils.py
Expand Up @@ -460,7 +460,8 @@ def _set_color_source_vec(
alpha: float = 1.0,
) -> Tuple[NDArrayA | pd.Series | None, NDArrayA, bool]:
if value_to_plot is None:
return np.full(adata.n_obs, to_hex(na_color)), np.broadcast_to(np.nan, adata.n_obs), False
color = np.full(adata.n_obs, to_hex(na_color))
return color, color, False

if alt_var is not None and value_to_plot not in adata.obs and value_to_plot not in adata.var_names:
value_to_plot = adata.var_names[adata.var[alt_var] == value_to_plot][0]
Expand Down Expand Up @@ -699,7 +700,11 @@ def _map_color_seg(
cols = colors.to_rgba_array(color_vector.categories) # type: ignore
else:
val_im = map_array(seg, cell_id, cell_id) # replace with same seg id to remove missing segs
cols = cmap_params.cmap(cmap_params.norm(color_vector))
try:
cols = cmap_params.cmap(cmap_params.norm(color_vector))
except TypeError:
assert all(colors.is_color_like(c) for c in color_vector), "Not all values are color-like."
cols = colors.to_rgba_array(color_vector)

if seg_erosionpx is not None:
val_im[val_im == erosion(val_im, square(seg_erosionpx))] = 0
Expand Down