Skip to content

Commit

Permalink
Merge branch 'dask-sparse-mean-var' of github.com:scverse/scanpy into…
Browse files Browse the repository at this point in the history
… dask-sparse-mean-var
  • Loading branch information
ilan-gold committed Mar 22, 2024
2 parents ba445f8 + 937c6db commit b3581ea
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .azure-pipelines.yml
Expand Up @@ -4,7 +4,7 @@ trigger:

variables:
python.version: '3.12'
PYTEST_ADDOPTS: '-v --color=yes --durations=0 --nunit-xml=test-data/test-results.xml'
PYTEST_ADDOPTS: '-v --color=yes --nunit-xml=test-data/test-results.xml'
TEST_EXTRA: 'test-full'
DEPENDENCIES_VERSION: "latest" # |"pre-release" | "minimum-version"
TEST_TYPE: "standard" # | "coverage"
Expand Down
1 change: 1 addition & 0 deletions docs/release-notes/1.10.0.md
Expand Up @@ -49,6 +49,7 @@
* Fix warnings caused by internal usage of `pandas.DataFrame.stack` with `pandas>=2.1` {pr}`2864`{smaller}`I Virshup`
* {func}`scanpy.get.aggregate` now always returns {class}`numpy.ndarray` {pr}`2893` {smaller}`S Dicks`
* Removes self from array of neighbors for `use_approx_neighbors = True` in {func}`~scanpy.pp.scrublet` {pr}`2896`{smaller}`S Dicks`
* Compatibility with scipy 1.13 {pr}`2943` {smaller}`I Virshup`



Expand Down
19 changes: 0 additions & 19 deletions scanpy/_utils/__init__.py
Expand Up @@ -280,25 +280,6 @@ def get_igraph_from_adjacency(adjacency, directed=None):
return g


def get_sparse_from_igraph(graph, weight_attr=None):
from scipy.sparse import csr_matrix

edges = graph.get_edgelist()
if weight_attr is None:
weights = [1] * len(edges)
else:
weights = graph.es[weight_attr]
if not graph.is_directed():
edges.extend([(v, u) for u, v in edges])
weights.extend(weights)
shape = graph.vcount()
shape = (shape, shape)
if len(edges) > 0:
return csr_matrix((weights, zip(*edges)), shape=shape)
else:
return csr_matrix(shape)


# --------------------------------------------------------------------------------
# Group stuff
# --------------------------------------------------------------------------------
Expand Down
8 changes: 4 additions & 4 deletions scanpy/tools/_paga.py
Expand Up @@ -186,7 +186,7 @@ def _compute_connectivities_v1_2(self):
n = sum(ns)
es_inner_cluster = [vc.subgraph(i).ecount() for i in range(len(ns))]
cg = vc.cluster_graph(combine_edges="sum")
inter_es = _utils.get_sparse_from_igraph(cg, weight_attr="weight")
inter_es = cg.get_adjacency_sparse(attribute="weight")
es = np.array(es_inner_cluster) + inter_es.sum(axis=1).A1
inter_es = inter_es + inter_es.T # \epsilon_i + \epsilon_j
connectivities = inter_es.copy()
Expand Down Expand Up @@ -220,7 +220,7 @@ def _compute_connectivities_v1_0(self):
)
ns = vc.sizes()
cg = vc.cluster_graph(combine_edges="sum")
inter_es = _utils.get_sparse_from_igraph(cg, weight_attr="weight") / 2
inter_es = cg.get_adjacency_sparse(attribute="weight") / 2
connectivities = inter_es.copy()
inter_es = inter_es.tocoo()
n_neighbors_sq = self._neighbors.n_neighbors**2
Expand Down Expand Up @@ -301,7 +301,7 @@ def compute_transitions(self):
)
# set combine_edges to False if you want self loops
cg_full = vc.cluster_graph(combine_edges="sum")
transitions = _utils.get_sparse_from_igraph(cg_full, weight_attr="weight")
transitions = cg_full.get_adjacency_sparse(attribute="weight")
transitions = transitions - transitions.T
transitions_conf = transitions.copy()
transitions = transitions.tocoo()
Expand Down Expand Up @@ -343,7 +343,7 @@ def compute_transitions_old(self):
g_bool, membership=self._adata.obs[self._groups_key].cat.codes.values
)
cg_bool = vc_bool.cluster_graph(combine_edges="sum") # collapsed version
transitions = _utils.get_sparse_from_igraph(cg_bool, weight_attr="weight")
transitions = cg_bool.get_adjacency_sparse(attribute="weight")
total_n = self._neighbors.n_neighbors * np.array(vc_bool.sizes())
transitions_ttest = transitions.copy()
transitions_confidence = transitions.copy()
Expand Down

0 comments on commit b3581ea

Please sign in to comment.