layout has more positions than samples but omixerRand doesn't randomize the samples
1
0
Entering edit mode
@lluis-revilla-sancho
Last seen 13 days ago
European Union

I'm not sure I understood the examples of the Omixer pacakge. Because when I try to use a layout for multiple batch I was not able to make it work. Now that I made sure there are enough sites to allocate all the samples it tells me that the layout must match exactly with the number of samples to distribute on the plates..

library("Omixer")
data(survey, package = "MASS")
survey$ID <- seq_len(nrow(survey))
n_batch <- 3
layout <- data.frame(well = 1:96, 
                     row = factor(rep(1:8, each=12), labels = LETTERS[1:8]),
                     column = rep(1:12, 8), 
                     plate  = 1,
                     chip = as.integer(ceiling(rep(1:12, 8)/2)))
layout$chipPos <- ifelse(layout$column %% 2 == 0, 
                         as.numeric(layout$row) + 8,
                         layout$row)
layout2 <- layout
layout2$plate <- 2
layout3 <- layout
layout3$plate <- 3
plates <- rbind(layout, layout2, layout3)
Omixer_index <- omixerRand(survey, sampleId = "ID", 
                           block = "block", iterNum = 10, wells = 96, mask = rep(1, 237),
                           plateNum = n_batch, randVars = VoI, layout = plates, techVars = NULL)
#> Error: Problem with `filter()` input `..1`.
#> ℹ Input `..1` is `mask == 0`.
#> x Input `..1` must be of size 288 or 1, not size 237.
Omixer_index <- omixerRand(survey, sampleId = "ID", 
                           block = "block", iterNum = 10, wells = 96, mask = rep(1, 288),
                           plateNum = n_batch, randVars = VoI, layout = plates, techVars = NULL)
#> Error in omixerRand(survey, sampleId = "ID", block = "block", iterNum = 10, : Number of unmasked wells must equal number of samples.
Omixer_index <- omixerRand(survey, sampleId = "ID", 
                           block = "block", iterNum = 10, wells = 96, mask = rep(0, 237),
                           plateNum = n_batch, randVars = VoI, layout = plates, techVars = NULL)
#> Error: Problem with `filter()` input `..1`.
#> ℹ Input `..1` is `mask == 0`.
#> x Input `..1` must be of size 288 or 1, not size 237.
Omixer_index <- omixerRand(survey, sampleId = "ID", 
                           block = "block", iterNum = 10, wells = 96, mask = rep(0, 288),
                           plateNum = n_batch, randVars = VoI, layout = plates, techVars = NULL)
#> Error in omixerRand(survey, sampleId = "ID", block = "block", iterNum = 10, : Number of unmasked wells must equal number of samples.

Created on 2021-07-07 by the reprex package (v2.0.0)

I have a couple of questions related to this:

Is it possible to just use the simple layout (without merging and changing the plate column) and still distribute the samples?
How should work around this?

How should one avoid masking? There seems to be an internal logical problem

From the vignette I think that omixerRand will write a file on the working directory. Is there any option to select the name or where the file will be saved?

Omixer • 1.1k views
ADD COMMENT
0
Entering edit mode

Updated with more code to show some internal logic errors. This also happens on the latest 1.2.1 version.

ADD REPLY
0
Entering edit mode
@lluis-revilla-sancho
Last seen 13 days ago
European Union

After an exchange with the authors of the package I learned how to prepare for an arbitrary number of batches

library("experDesign")
library("Omixer")
library("ggplot2")
data(survey, package = 'MASS')
batches <- 3
size_subset <- 96
batches <- optimum_batches(size_data = nrow(survey), size_subset = size_subset)
sizes_batches(nrow(survey), size_subset = size_subset, batches = batches)
## [1] 79 79 79
sizes <- optimum_subset(size_data = nrow(survey), batches = batches)
layout <- data.frame(
  plate = as.factor(rep(1:batches, each = sizes)),
  well = rep(seq(from = 1, to = sizes), rep = batches),
  row = 1, column = 1, chip = 1, chipPos = 1, mask = 0
)
head(layout)
##   plate well row column chip chipPos mask
## 1     1    1   1      1    1       1    0
## 2     1    2   1      1    1       1    0
## 3     1    3   1      1    1       1    0
## 4     1    4   1      1    1       1    0
## 5     1    5   1      1    1       1    0
## 6     1    6   1      1    1       1    0
techVars <- c('plate')
randVars <- c('Sex', 'Smoke', 'Age')
survey$ID <- seq_len(nrow(survey))
omixerLayout <- omixerRand(survey, 
                           sampleId = 'ID',
                           plateNum = batches,
                           layout = layout,
                           iterNum = 100, 
                           techVars = techVars,
                           randVars = randVars)

But there are some combinations of options that ddi not work with Omixer 1.1.1 with R 3.6 and Bioconductor 3.10.

n_batch <- 3
layout <- data.frame(
  well = 1:96,
  row = factor(rep(1:8, each = 12), labels = LETTERS[1:8]),
  column = rep(1:12, 8),
  plate = 1,
  chip = 1, chipPos = 1
)

layout2 <- layout
layout2$plate <- 2
layout3 <- layout
layout3$plate <- 3
plates <- rbind(layout, layout2, layout3)

mask <- rep(c(rep(1, 96-sizes), rep(0, sizes)), 3)
stopifnot("Masks must be the same as the number of samples" = sum(mask == 0) == nrow(survey))
# Mask argument on omixerRand
Omixer_index <- omixerRand(survey, 
                           sampleId = "ID",
                           iterNum = 10,
                           plateNum = n_batch, 
                           layout = plates, 
                           techVars = techVars,
                           randVars = randVars)
## Error in omixerRand(survey, sampleId = "ID", iterNum = 10, plateNum = n_batch, : Number of unmasked wells must equal number of samples.

# Mask argument as a vector on omixerRand
Omixer_index <- omixerRand(survey, 
                           sampleId = "ID",
                           iterNum = 10,
                           plateNum = n_batch, 
                           layout = plates, 
                           mask = mask,
                           techVars = techVars,
                           randVars = randVars)
## Error: Join columns must be present in data.
## x Problem with `mask`.
ADD COMMENT

Login before adding your answer.

Traffic: 697 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6