-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sera/issue random sample size #3
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem here is not that the slider is not being updated. The update does happen as expected here. Adding an additional location where the slider is updated introduces unnecessary complexity.
The problem is that the random sample function will be executed whenever either the slider or the adata
is updated.
So the following happens here if the adata
is updated:
random_sample
andslider_sample
at the same timerandom_sample
again because the slider was updated
The problem will only occur when the random_sample
is called the first time, as the slider has not been updated yet but the adata
has
A solution could look as simple as this:
@reactive.effect
def random_sample():
adata = _adata_qc.get()
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)
Also please add a patch release to 0.2.1 here |
@@ -76,12 +76,15 @@ def return_of_adata_meta(): | |||
@reactive.effect | |||
def random_sample(): | |||
adata = _adata_qc.get() | |||
if adata is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be sufficient to check only once if adata
is None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okee
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
No description provided.