Remove batch effect limma, "Coefficients not estimable" warning and design matrix
1
0
Entering edit mode
Pietro ▴ 40
@pietro-13029
Last seen 7 months ago
Italy

Good morning

I have a question regarding the function removeBatchEffect from limma package.

This is my experimental design

ID  Patient   Metastasis
S1  A   NO
S2  A   YES
S3  B   NO
S4  B   YES
S5  C   NO
S6  C   YES
S7  D   NO
S8  D   YES
S9  E   NO
S10 E   YES

From the same patient we have tumor tissue and metastatic tissue samples. I have a vst transformed gene expression matrix from which I would like to regress out the Patient effect. I have already obtained DEG with DESEq2using the formula

dds <- DESeqDataSetFromTximport(txi_rsem, colData, ~ Patient + Metastasis)

Now I need the "batch effect removed" matrix for downstream analysis, but when I am doing

mydesign <- model.matrix(~ Patient + Metastasis, data = colData)

vstmatnoBatch <- limma::removeBatchEffect(vstmatBatch, batch = colData$Patient, design = mydesign)

Then I get

Coefficients not estimable: batch1 batch2 batch3 batch4 Warning message: Partial NA coefficients for 32653 probe(s)

I do not understand why I am getting it.

Then searching in the Bioc support site I found this https://support.bioconductor.org/p/76837/ and saw that in the design matrix the batch factor was not included. So I tried to do the same

mydesign <- model.matrix(~ Metastasis, data = colData)

vstmatnoBatch <- limma::removeBatchEffect(vstmatBatch, batch = colData$Patient, design = mydesign)

And obtained no warnings/errors and wonderful results. Do not know what is going on here. Thanks

limma deseq2 batch design batch effect • 5.1k views
ADD COMMENT
0
Entering edit mode
@mikelove
Last seen 2 days ago
United States

Have you read ?removeBatchEffect yet? It's always best to start understanding what a function is doing by reading it man page.

ADD COMMENT
0
Entering edit mode

Yes I read the help of the function but it does not help with my problem. In the Examples of the function the design argument is not included, but in the design argument description it says

design matrix relating to treatment conditions to be preserved, usually the design matrix with all experimental factors other than the batch effects.

That is why I have included at the first try, but with no success. Then I found other threads where the design matrix is not included or it does not include the batch effect. In particular I do not understand the latter case.

ADD REPLY
0
Entering edit mode

So your first try was this:

    mydesign <- model.matrix(~ Patient + Metastasis, data = colData)
    vstmatnoBatch <- limma::removeBatchEffect(vstmatBatch, batch = colData$Patient, design = mydesign)

Where your design matrix includes the batch effect you want to remove. And the help page specifically says the design matrix shouldn't include the batch effect.

And when you did what the help page indicates you should do, it worked. So which part of that do you not understand?

ADD REPLY
0
Entering edit mode

You are right, my poor command of english and hours in front of the computer let me interpret the expression "other than" with an italian "oltre a" that means roughly "together with". Thanks for the help, you can close the thread.

ADD REPLY
0
Entering edit mode

Ah, makes sense. Being a native English speaker, I use the English version of R. Way back in the day Brian Ripley did a bunch of work to make R multi-lingual. Is the Italian version not good? I sort of assumed, given BDR's track record, that the multi-lingual versions would be good, and that a native Italian speaker would tend to use the Italian language version.

ADD REPLY
0
Entering edit mode

I use R in Portuguese but my OS in Spanish. Eventually, all words transcend any particular language and are interpreted equally. It's interesting observing how the brain adapts to a new language.

ADD REPLY
1
Entering edit mode

Or not, in my case. Approximately 99% of my junior high Spanish has successfully fled my brain.

ADD REPLY
1
Entering edit mode

I have generated an R philology/etimology/psychology discussion =)

ADD REPLY

Login before adding your answer.

Traffic: 557 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