Skip to content

Commit

Permalink
Misc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
marcovarrone committed Aug 6, 2024
1 parent bb9fff2 commit fcc8007
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/cellcharter/gr/_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ def remove_intra_cluster_links(

# ToDo: compute inter_cluster_mask only on conns and apply mask to both matrices
for matrix in [conns, dists]:
target_clusters = np.array(adata.obs[cluster_key][matrix.indices])
target_clusters = np.array(adata.obs[cluster_key].iloc[matrix.indices])
source_clusters = np.array(
adata.obs[cluster_key][np.repeat(np.arange(matrix.indptr.shape[0] - 1), np.diff(matrix.indptr))]
adata.obs[cluster_key].iloc[np.repeat(np.arange(matrix.indptr.shape[0] - 1), np.diff(matrix.indptr))]
)

inter_cluster_mask = (source_clusters != target_clusters).astype(int)
Expand Down
3 changes: 2 additions & 1 deletion src/cellcharter/gr/_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ def _enrichment(observed, expected, log=True):
enrichment = observed.div(expected, axis="index", level=0)

if log:
enrichment = np.log2(enrichment)
with np.errstate(divide="ignore"):
enrichment = np.log2(enrichment)
enrichment = enrichment.fillna(enrichment.min())
return enrichment

Expand Down
4 changes: 2 additions & 2 deletions src/cellcharter/pl/_shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def boundaries(
"cells": sd.models.ShapesModel.parse(cell_circles),
}

sdata = sd.SpatialData(shapes=shapes, table=table)
sdata = sd.SpatialData(shapes=shapes, tables=table)

ax = plt.gca()
if show_cells:
Expand All @@ -151,7 +151,7 @@ def boundaries(
sdata.pl.render_shapes(elements="cells", color=component_key).pl.show(ax=ax, legend_loc=None)

sdata.pl.render_shapes(
elements="clusters",
element="clusters",
color=component_key,
fill_alpha=alpha_boundary,
).pl.show(ax=ax)
Expand Down
2 changes: 1 addition & 1 deletion src/cellcharter/pl/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def _heatmap(
)

row_order = row_order[::-1]
row_labels = adata.obs[key][row_order]
row_labels = adata.obs[key].iloc[row_order]
col_labels = adata.var_names[col_order]

data = adata[row_order, col_order].copy().X
Expand Down
2 changes: 2 additions & 0 deletions tests/plotting/test_group.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import matplotlib.pyplot as plt
import pytest
import squidpy as sq

Expand Down Expand Up @@ -75,6 +76,7 @@ def test_params(
alpha=alpha,
edgecolor=edgecolor,
)
plt.close()

def test_no_pvalues(self):
# If the enrichment data is not present, it should raise an error
Expand Down

0 comments on commit fcc8007

Please sign in to comment.