Skip to content

Commit 0de6138

Browse files
authored
Merge pull request #163 from JonathanShor/state
Use numpy default rng instead of setting global seed
2 parents c4a4f42 + c42c875 commit 0de6138

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

doubletdetection/doubletdetection.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,6 @@ def __init__(
117117
if self.clustering_algorithm == "leiden":
118118
warnings.warn("Leiden clustering is experimental and results have not been validated.")
119119

120-
if self.random_state:
121-
np.random.seed(self.random_state)
122-
123120
if n_components == 30 and n_top_var_genes > 0:
124121
# If user did not change n_components, silently cap it by n_top_var_genes if needed
125122
self.n_components = min(n_components, n_top_var_genes)
@@ -406,7 +403,8 @@ def _createDoublets(self) -> None:
406403
num_synths = int(self.boost_rate * self._num_cells)
407404

408405
# Parent indices
409-
choices = np.random.choice(self._num_cells, size=(num_synths, 2), replace=self.replace)
406+
rng = np.random.default_rng(self.random_state)
407+
choices = rng.choice(self._num_cells, size=(num_synths, 2), replace=self.replace)
410408
parents = [list(p) for p in choices]
411409

412410
parent0 = self._raw_counts[choices[:, 0], :]

0 commit comments

Comments
 (0)