Skip to content

Commit 8d64860

Browse files
authored
Fix cytovi kmeans openblas (#111)
* limit number of threads using threadpool ctl
1 parent 1870f2f commit 8d64860

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/methods/cytovi/script.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import numpy as np
33
from scvi.external import cytovi
44
from sklearn.cluster import KMeans
5+
from threadpoolctl import threadpool_limits
56

67
## VIASH START
78
par = {
@@ -37,11 +38,12 @@
3738

3839
print("Clustering using k-means with k =", par["n_clusters"], flush=True)
3940
# cluster data using Kmeans
40-
adata_to_correct.obs["clusters"] = (
41-
KMeans(n_clusters=par["n_clusters"], random_state=0)
42-
.fit_predict(adata_to_correct.layers["scaled"])
43-
.astype(str)
44-
)
41+
with threadpool_limits(limits=1):
42+
adata_to_correct.obs["clusters"] = (
43+
KMeans(n_clusters=par["n_clusters"], random_state=0)
44+
.fit_predict(adata_to_correct.layers["scaled"])
45+
.astype(str)
46+
)
4547
# concatenate obs so we can use it for subsampling
4648
adata_to_correct.obs["sample_cluster"] = (
4749
adata_to_correct.obs["sample"].astype(str) + "_" + adata_to_correct.obs["clusters"]

0 commit comments

Comments
 (0)