Skip to content
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

spatial() assigns multiple samples to the same plate position in the same batch #45

Closed
AnnaPagotto opened this issue Dec 5, 2023 · 13 comments

Comments

@AnnaPagotto
Copy link

Hi Lluís, thank you for this amazing package. I'm using it for my project, but I encountered some issues when distributing the samples in the plate grid. I have some cases where spatial() assigns the same position in the same batch to two samples.
Could you help me with that?

Thank you a lot!
Best,
Anna

@llrs
Copy link
Owner

llrs commented Dec 5, 2023

Hi Anna, happy to hear from a happy user.

Sorry to hear that spatial doesn't fully work. I think I tested to prevent this from happening, but I will give it a look. Could you provide the code where this happens? This way I will make sure it won't happen again.

@AnnaPagotto
Copy link
Author

AnnaPagotto commented Dec 5, 2023 via email

@llrs
Copy link
Owner

llrs commented Dec 5, 2023

Sorry, if you send the data via email, I don't see it in the github issue. But don't worry that I found a way to reproduce the issue:

data(survey, package = "MASS")
set.seed(4568)
nas <- c(137, 70)
index <- replicates(survey[-nas, c("Sex", "Smoke", "Age")], size_subset = 50,
                   iterations = 25, controls = 15)
index2 <- spatial(index, survey[-nas, c("Sex", "Smoke", "Age")], iterations = 25)
uniquness <- vapply(index2, function(x){length(unique(x)) == length(x)},
                    FUN.VALUE = logical(1L))
expect_false(any(!uniquness))

i1 <- inspect(index, survey[-nas, c("Sex", "Smoke", "Age")])
i2 <- inspect(index2, i1, index_name = "spatial")
# This should be empty too
i2 |> group_by(batch) |> count(spatial) |> ungroup() |> arrange(batch) |> filter(n!= 1)

@AnnaPagotto
Copy link
Author

Oh, sorry, I didn't realise it.
Let me know if I can provide with anything else. I can still send you the code if you wish.

@llrs
Copy link
Owner

llrs commented Dec 7, 2023

Hi Anna, I fixed this locally, thanks for opening the issue. However, I found that there is a problem with batch_names which affects inspect too when there are controls or repeated positions. Do you have controls in your data? Or would this be enough for the moment?

@AnnaPagotto
Copy link
Author

AnnaPagotto commented Dec 7, 2023 via email

@AnnaPagotto
Copy link
Author

Hi Lluis,
I removed and reinstalled the package. I thought that was sufficient to have the fixed version, but the bug is still there. What do you mean by "fixed locally"? Sorry for my ignorance.
Anna

@llrs
Copy link
Owner

llrs commented Dec 8, 2023

I meant that it was only in my computer, not yet on github or CRAN.

To install the package with the fix you will need to use remotes::install_github("llrs/experDesign") and it will install the development version with the fix. You don't need to uninstall it and reinstall it again, but you will need to close R and start again R after the installation to be sure that the new version is used.

If it is not fixed then I would need to know the code used and the experDesign version used.

@AnnaPagotto
Copy link
Author

Thanks, the positions are now uniquely assigned. I just noticed now something that was not there before the fixing: I have two numeric and two categorical variables. For one categorical variable (in my case "age") it doesn't distribute the samples randomly in the plate.

Here the example:
image

@llrs
Copy link
Owner

llrs commented Dec 8, 2023

Nice plot! I assume you blocked/omitted the first column? Or you only provided with columns 2 to 8?

I think I reverted that change, it slipped through. You will need to repeat the steps in #45 (comment).
I am not sure how you have age as categorical, in the plots it is displayed as numeric. Did you use cut to categorize it or it is a simple typo?

@AnnaPagotto
Copy link
Author

Sorry, it was a typo, I have age as numeric indeed.
PS: yes I blocked the first and the last two columns. And I used ggplate for the plot :)

@AnnaPagotto
Copy link
Author

It is perfectly working now! Thank you a lot!

@llrs
Copy link
Owner

llrs commented Dec 9, 2023

Glad it works now! I hope it helps well designing your experiment!
Thanks for the tip about ggplate! I might use it in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants