Getting a "system is computationally singular" error in sleuth I am analysing 142 samples belonging to 6 batches. Additionally, those samples belong to 72 strains, which means that for most of the strains there are two samples.

I could fit simple models (for strain and batches for instance), but when I get to the "full" model (~batch+strain), I get the following error:

so &lt;- sleuth_fit(so, ~strain+batch, 'full')
Error in solve.default(t(X) %*% X) :
  system is computationally singular: reciprocal condition number = 5.2412e-19


I should point out that of the 72 strains, only 15 have samples in distinct batches. This means that most strains (57) have both samples in the same batch.

Is the error due to an unknown bug or rather to the experimental design? Does it mean that the information on batches cannot be used?

Thanks

EDIT I've posted the experimental design in a gist

batch   strain  replica
batch_1     strain_41   1
batch_4     strain_41   2
batch_1     strain_28   1
batch_4     strain_28   2
batch_1     strain_26   1
[...]
This happen when the variables (strain +batch) create a design matrix like this:

batch strain
1 1 #
1 1 #
1 2
2 2
3 3
4 3
...
16 72


Which means that some of the covariates are not linearly independent (ie batch 1 and strain 1), all the strain 1 is in batch 1. 

You can correct for batch effects, but not in this design of the linear model (if you want to take into account the strain). You could do one batch more with those 15 strains that are in a single batch (if they are in different batch between them) that way you would get an independent design.

Many strains in a single batch are in the same batch. You need to increase the number of samples (recommended anyway due to the low number of samples per strain) to avoid this problem. 



There are a lot of related question in Bioconductor support forum, from where I expanded an answer.