Skip to content

Commit

Permalink
Connectivity for n2s
Browse files Browse the repository at this point in the history
  • Loading branch information
asistradition committed May 22, 2023
1 parent be63dab commit b2d61f5
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 10 deletions.
16 changes: 13 additions & 3 deletions inferelator_velocity/program_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def global_graph(
neighbors=None,
npcs=None,
use_sparse=True,
connectivity=False,
verbose=False
):
"""
Expand All @@ -40,6 +41,9 @@ def global_graph(
Will densify a sparse expression matrix (faster, more memory) if False,
defaults to True
:type use_sparse: bool
:param connectivity: Use a connectivity graph instead of a distance graph,
defaults to False
:type connectivity: bool, optional
:param verbose: Print detailed status, defaults to False
:type verbose: bool, optional
:return: AnnData object with `noise2self` obps and uns key
Expand All @@ -58,7 +62,8 @@ def global_graph(
neighbors=neighbors,
npcs=npcs,
verbose=verbose,
use_sparse=use_sparse
use_sparse=use_sparse,
connectivity=connectivity
)

vprint(
Expand All @@ -83,6 +88,7 @@ def program_graphs(
neighbors=None,
npcs=None,
use_sparse=True,
connectivity=False,
verbose=False
):
"""
Expand All @@ -106,7 +112,10 @@ def program_graphs(
:param use_sparse: Use sparse data structures (slower).
Will densify a sparse expression matrix (faster, more memory) if False,
defaults to True
:type use_sparse: bool
:type use_sparse: bool, optional
:param connectivity: Use a connectivity graph instead of a distance graph,
defaults to False
:type connectivity: bool, optional
:param verbose: Print detailed status, defaults to False
:type verbose: bool, optional
:return: AnnData object with `program_{id}_distances` obps key
Expand Down Expand Up @@ -143,7 +152,8 @@ def program_graphs(
neighbors=neighbors,
npcs=npcs,
verbose=verbose,
use_sparse=use_sparse
use_sparse=use_sparse,
connectivity=connectivity
)

vprint(
Expand Down
2 changes: 1 addition & 1 deletion inferelator_velocity/programs.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def _leiden_cluster(
leiden_kws['adjacency'] = knn_connect
leiden_kws['random_state'] = leiden_kws.get('random_state', random_state)

ad_arr = ad.AnnData(dist_array, dtype=float)
ad_arr = ad.AnnData(dist_array.astype(float))

sc.tl.leiden(ad_arr, **leiden_kws)

Expand Down
2 changes: 1 addition & 1 deletion inferelator_velocity/tests/test_noise2self.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
EXPR = BASE + NOISE
DIST = sklearn.metrics.pairwise_distances(EXPR, metric='cosine')

ADATA = ad.AnnData(EXPR, dtype=int)
ADATA = ad.AnnData(EXPR.astype(int))


def _knn(k):
Expand Down
2 changes: 1 addition & 1 deletion inferelator_velocity/tests/test_programs.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
EXPRESSION[:, 5] = np.arange(N) * 2 + 10


EXPRESSION_ADATA = ad.AnnData(EXPRESSION.astype(int), dtype=int)
EXPRESSION_ADATA = ad.AnnData(EXPRESSION.astype(int))

ADATA_UNS_PROGRAM_KEYS = [
'metric',
Expand Down
3 changes: 1 addition & 2 deletions inferelator_velocity/tests/test_times.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ class TestProgramTimes(unittest.TestCase):
def setUp(self) -> None:

self.adata = ad.AnnData(
EXPR,
dtype=EXPR.dtype
EXPR
)

self.adata.obs['group'] = LAB
Expand Down
2 changes: 1 addition & 1 deletion inferelator_velocity/times.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def calculate_times(

# Construct an adata object and normalize it
adata = standardize_data(
ad.AnnData(count_data, dtype=float)
ad.AnnData(count_data.astype(float))
)

# Calculate chosen PCA & neighbor graph
Expand Down
2 changes: 1 addition & 1 deletion inferelator_velocity/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def copy_count_layer(data, layer):
"these results will be nonsense."
)

d = ad.AnnData(lref, dtype=float)
d = ad.AnnData(lref.astype(float))
d.layers['counts'] = lref.copy()
d.var = data.var.copy()

Expand Down

0 comments on commit b2d61f5

Please sign in to comment.