From bf0bf26a5ad7c3de6935ebf86e84e04fceca37cf Mon Sep 17 00:00:00 2001 From: reif Date: Sun, 2 Jun 2024 14:17:45 +0000 Subject: [PATCH 1/5] first try to fix random sample issue --- src/sliders.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/sliders.py b/src/sliders.py index b53a619..6cce68e 100644 --- a/src/sliders.py +++ b/src/sliders.py @@ -76,7 +76,16 @@ def return_of_adata_meta(): @reactive.effect def random_sample(): adata = _adata_qc.get() - sample_size = input['random_sample_size'].get() + if adata is None: + return + + obs_number = adata.n_obs + sample_size = input['random_sample_size'] + + if sample_size > obs_number: + sample_size = obs_number + ui.update_slider('random_sample_size', value=sample_size, max=obs_number) + if adata is None: return From 90fd2d4173bd2a8ef9cd2800d85bfa3f9582e3ee Mon Sep 17 00:00:00 2001 From: reif Date: Sun, 2 Jun 2024 14:44:08 +0000 Subject: [PATCH 2/5] add fixed random_sample --- src/sliders.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sliders.py b/src/sliders.py index 6cce68e..4fe3035 100644 --- a/src/sliders.py +++ b/src/sliders.py @@ -80,9 +80,9 @@ def random_sample(): return obs_number = adata.n_obs - sample_size = input['random_sample_size'] + sample_size = input['random_sample_size']() - if sample_size > obs_number: + if int(sample_size) > int(obs_number): sample_size = obs_number ui.update_slider('random_sample_size', value=sample_size, max=obs_number) From e12d56d8ea8bb2545c5246c6d8ad3a433846d285 Mon Sep 17 00:00:00 2001 From: reif Date: Sun, 2 Jun 2024 16:13:17 +0000 Subject: [PATCH 3/5] add easier and non-repetitive implementation to fix the random_sample_size --- src/sliders.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/sliders.py b/src/sliders.py index 4fe3035..51a6b9e 100644 --- a/src/sliders.py +++ b/src/sliders.py @@ -78,19 +78,13 @@ def random_sample(): adata = _adata_qc.get() if adata is None: return - - obs_number = adata.n_obs - sample_size = input['random_sample_size']() - - if int(sample_size) > int(obs_number): - sample_size = obs_number - ui.update_slider('random_sample_size', value=sample_size, max=obs_number) - - + + sample_size = input['random_sample_size'].get() + if adata is None: return - adata_sample = adata[np.random.choice(adata.obs.index, sample_size, replace=False)] + adata_sample = adata[np.random.choice(adata.obs.index, min(sample_size, len(adata.obs)), replace=False)] _adata_sample.set(adata_sample) @output From 36de840588610052dcffe913c107ed131ec980ab Mon Sep 17 00:00:00 2001 From: reif Date: Sun, 2 Jun 2024 16:18:30 +0000 Subject: [PATCH 4/5] add patch release to 0.2.1 --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 71f6942..86f3be4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,4 +5,4 @@ services: dockerfile: Dockerfile ports: - 8080:8080 - image: bigdatainbiomedicine/simba-qc:0.2.0 + image: bigdatainbiomedicine/simba-qc:0.2.1 From 3df6e48e9601aa2e3712f35622c67ed71e3edd76 Mon Sep 17 00:00:00 2001 From: reif Date: Sun, 2 Jun 2024 18:57:32 +0000 Subject: [PATCH 5/5] remove already existing check if adata is none --- src/sliders.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/sliders.py b/src/sliders.py index 51a6b9e..5c23696 100644 --- a/src/sliders.py +++ b/src/sliders.py @@ -81,9 +81,6 @@ def random_sample(): sample_size = input['random_sample_size'].get() - if adata is None: - return - adata_sample = adata[np.random.choice(adata.obs.index, min(sample_size, len(adata.obs)), replace=False)] _adata_sample.set(adata_sample)