Skip to content

Commit d94816f

Browse files
committed
Finalization
1 parent 93618fb commit d94816f

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

benchmarks/benchmarks/preprocessing_log.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ def peakmem_scale(self, *_) -> None:
7878
class CombatSuite:
7979
"""Benchmark combat batch correction."""
8080

81+
params = ()
82+
param_names = ()
83+
8184
def setup_cache(self) -> None:
8285
adata = pbmc3k()
8386
sc.pp.highly_variable_genes(adata, n_top_genes=500)

src/scanpy/preprocessing/_combat.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def _standardize_data(
114114
# Compute the means
115115
if np.sum(var_pooled == 0) > 0:
116116
print(f"Found {np.sum(var_pooled == 0)} genes with zero variance.")
117-
stand_mean = np.asarray(grand_mean)[:, np.newaxis]
117+
stand_mean = grand_mean[:, np.newaxis]
118118
tmp = np.array(design.copy())
119119
tmp[:, :n_batch] = 0
120120
stand_mean = stand_mean + np.dot(tmp, b_hat).T
@@ -124,7 +124,7 @@ def _standardize_data(
124124
s_data = np.where(
125125
var_pooled == 0,
126126
0,
127-
(np.asarray(data) - stand_mean) / np.sqrt(var_pooled),
127+
(data - stand_mean) / np.sqrt(var_pooled),
128128
)
129129
s_data = pd.DataFrame(s_data, index=data.index, columns=data.columns)
130130

@@ -282,10 +282,11 @@ def combat( # noqa: PLR0915
282282
bayesdata = bayesdata * np.sqrt(var_pooled) + stand_mean
283283

284284
# put back into the adata object or return
285+
x = bayesdata.to_numpy().transpose()
285286
if inplace:
286-
adata.X = bayesdata.to_numpy().transpose()
287+
adata.X = x
287288
return None
288-
return bayesdata.to_numpy().transpose()
289+
return x
289290

290291

291292
def _it_sol(

0 commit comments

Comments
 (0)