# Deciding which samples go in which batch

I have 370 samples to sequence, we probably will end up using only 96 samples per run (due to the barcode with the primers we'll use). This means running 4 batches. To minimize the batch effect I need to decide which samples are sequenced in which run.

I have several variables from these samples, some of them are categoric (sex, disease status, treatment stage, ...) and some of them are numeric (age, clinical score...).

To minimize the batch effect I wouldn't group all samples from the same category in one run, and I would distribute as uniformly as possible the samples according to the numeric variables. However, I could find many papers about adjusting, taking into account, but I couldn't find a paper about software to help designing the runs.

Is there any software to help designing each batch?

If there are several I would like to point out that I would define best as the one with easier user interface

However it is specific for Illumina and for a limited number of plates: "plates that hold 2, 4, 8 IlluminaBeadChip chips and have 24, 48, 96 wells, respectively."
It doesn't take in consideration the numeric values:

library(OSAT)
inPath <- system.file('extdata', package='OSAT')
pheno\$AgeGrp <- runif(576, 0, 100)
gs <- setup.sample(pheno, optimal=c("SampleType", "Race", "AgeGrp"))
gSetup <- create.optimized.setup(sample=gs, container=gc, nSim=1000)


It handles both numeric and categorical data, but it can only optimize for two nominal criteria.

It can handle both numeric and categorical data for an arbitrary number of variables. It is not restricted to an even number of samples per batch.

I've had to go through this pain, and found the best way to do it was to simulate the model fit to start assessing the balance of covariates. I've got two notebooks available on Github, which should help you deal with this issue, although I've not thought about how to accurately assess continuous variables.

While it's not wrapped in a package, you can use these notebooks as a template to fit to your problem. I may wrap this in a package at some point, but I haven't had the chance to do so yet.

This Notebook will allow you to set up all your variables, max size of a batch (may vary due to multiplexing, library set up, plate size, etc). Bin them into appropriate batches, then create a design matrix, model fit, and test.

Apologies in advance that it's a bit of a mess, but if anything isn't clear, open an issue on the repo.

• Interesting, thanks for sharing! However I don't understand why do you perform a test? If I understood the script it is for a mock data, so what is the purpose of this? To estimate what would be a completely random output?
– llrs
Jul 25 '18 at 14:02
• That's a fair point, and you're correct, there's no reason for it. Generally, it was just for completeness so that nothing was widely unexpected when performing the test. Jul 25 '18 at 18:31
• After trying it. I realized that this assumes even number of sample per each category (except for batch), which is not my case
– llrs
Jul 26 '18 at 7:36
• Yeah, unfortunately you'll need to modify it to deal with uneven cases. Jul 26 '18 at 9:30