From 1a960fb42ee9bd0d1cc2c2d7052c9fab0c462416 Mon Sep 17 00:00:00 2001 From: adamgayoso Date: Sat, 11 Jan 2025 16:02:00 +0000 Subject: [PATCH 1/2] drop .A1 for asarray(...).ravel() --- doubletdetection/doubletdetection.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doubletdetection/doubletdetection.py b/doubletdetection/doubletdetection.py index f0793f0..2a90402 100644 --- a/doubletdetection/doubletdetection.py +++ b/doubletdetection/doubletdetection.py @@ -192,7 +192,7 @@ def fit(self, raw_counts): (self._num_cells, self._num_genes) = self._raw_counts.shape if self.normalizer is None: # Memoize these; default normalizer treats these invariant for all synths - self._lib_size = np.sum(raw_counts, axis=1).A1 + self._lib_size = np.asarray(np.sum(raw_counts, axis=1)).ravel() self._normed_raw_counts = self._raw_counts.copy() inplace_csr_row_normalize_l1(self._normed_raw_counts) @@ -298,7 +298,7 @@ def _one_fit(self): ) else: # Follows doubletdetection.plot.normalize_counts, but uses memoized normed raw_counts - synth_lib_size = np.sum(self._raw_synthetics, axis=1).A1 + synth_lib_size = np.asarray(np.sum(self._raw_synthetics, axis=1)).ravel() aug_lib_size = np.concatenate([self._lib_size, synth_lib_size]) normed_synths = self._raw_synthetics.copy() inplace_csr_row_normalize_l1(normed_synths) From ddf28b9e6ff37431cad2bfa15c2eaf027459e81c Mon Sep 17 00:00:00 2001 From: adamgayoso Date: Sat, 11 Jan 2025 16:53:20 +0000 Subject: [PATCH 2/2] toarray from .A --- doubletdetection/doubletdetection.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doubletdetection/doubletdetection.py b/doubletdetection/doubletdetection.py index 2a90402..a254fe4 100644 --- a/doubletdetection/doubletdetection.py +++ b/doubletdetection/doubletdetection.py @@ -305,7 +305,7 @@ def _one_fit(self): aug_counts = sp_sparse.vstack((self._normed_raw_counts, normed_synths)) scaled_aug_counts = aug_counts * np.median(aug_lib_size) if self.pseudocount != 1: - aug_counts = np.log(scaled_aug_counts.A + 0.1) + aug_counts = np.log(scaled_aug_counts.toarray() + 0.1) else: aug_counts = np.log1p(scaled_aug_counts) del scaled_aug_counts