<ul>
<li>I found the <a href="http://bioconductor.org/packages/OSAT/" rel="nofollow noreferrer">OSAT package</a> which does almost what I want. </li>
</ul>

<p>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."<br>
It doesn't take in consideration the numeric values:</p>

<pre><code>library(OSAT)
inPath &lt;- system.file('extdata', package='OSAT')
pheno &lt;- read.table(file.path(inPath, 'samples.txt'), 
                    header=TRUE, sep="\t", colClasses="factor")
pheno$AgeGrp &lt;- runif(576, 0, 100)
gs &lt;- setup.sample(pheno, optimal=c("SampleType", "Race", "AgeGrp"))
gc &lt;- setup.container(IlluminaBeadChip96Plate, 6, batch='plates')
gSetup &lt;- create.optimized.setup(sample=gs, container=gc, nSim=1000)
</code></pre>

<p><a href="https://i.sstatic.net/tNofr.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/tNofr.png" alt="enter image description here"></a></p>

<ul>
<li>The <a href="https://github.com/m-Py/minDiff" rel="nofollow noreferrer">minDiff</a> package reported in <a href="https://stats.stackexchange.com/a/326015/105234">Stats.SE</a>.</li>
</ul>

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

<ul>
<li>I wrote <a href="http://github.com/llrs/experDesign" rel="nofollow noreferrer">experDesign</a> which does everything I wanted</li>
</ul>

<p>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. </p>

CC BY-SA 4.0
2018-07-24T15:53:29.963Z
2018-10-01T07:19:54.767Z
2018-10-01T07:19:54.767Z
llrs
<p>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. </p>

<p>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. </p>

<p><a href="https://github.com/AndrewSkelton/Experimental-Design-Simulation/blob/master/Version2_Experiment.Rmd" rel="nofollow noreferrer">This</a> 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. </p>

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

CC BY-SA 4.0
2018-07-25T14:02:12.587Z
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
CC BY-SA 4.0
2018-07-25T18:31:13.273Z
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.
A_Skelton73
CC BY-SA 4.0
2018-07-26T07:36:25.747Z
After trying it. I realized that this assumes even number of sample per each category (except for batch), which is not my case
llrs
CC BY-SA 4.0
2018-07-26T09:30:46.410Z
Yeah, unfortunately you'll need to modify it to deal with uneven cases.
A_Skelton73
CC BY-SA 4.0
2018-07-25T10:47:16.093Z
2018-07-25T10:47:16.093Z
A_Skelton73
<p>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. </p>

<p>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...).</p>

<p>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.</p>

<p>Is there any software to help designing each batch?</p>

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

<ngs><software-recommendation><design>
Deciding which samples go in which batch
# Deciding which samples go in which batch

(Asked by: username_0 on 2018-07-24)

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

**Tags:** ngs, software-recommendation, design

---

## 2 answers

### Answer by username_0 on 2018-07-24. Score: 3 | Accepted answer

I found the OSAT package which does almost what I want. 

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 <- read.table(file.path(inPath, 'samples.txt'), 
                    header=TRUE, sep="\t", colClasses="factor")
pheno$AgeGrp <- runif(576, 0, 100)
gs <- setup.sample(pheno, optimal=c("SampleType", "Race", "AgeGrp"))
gc <- setup.container(IlluminaBeadChip96Plate, 6, batch='plates')
gSetup <- create.optimized.setup(sample=gs, container=gc, nSim=1000)



The minDiff package reported in Stats.SE.

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

I wrote experDesign which does everything I wanted

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.


---

### Answer by username_1 on 2018-07-25. Score: 2

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](https://github.com/AndrewSkelton/Experimental-Design-Simulation/blob/master/Version2_Experiment.Rmd) 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.

> **Comments:**
> **username_0**: 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?  
> **username_1**: 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.  
> **username_0**: After trying it. I realized that this assumes even number of sample per each category (except for batch), which is not my case  
> **username_1**: Yeah, unfortunately you'll need to modify it to deal with uneven cases.  

---

