Question: Error in while (change > conv) { : missing value where TRUE/FALSE needed
1
gravatar for lessismore
17 months ago by
lessismore600
Mexico
lessismore600 wrote:

Hello everybody, i am using ComBat for correcting Batch effects: 3 batches and 3 conditions. i have my modelmatrix and my datasets ready.

sample <- row.names(Pheno_complete)
batch <- Pheno_complete$Batch_num
condition <- Pheno_complete$Stage_num
modmatrix <- model.matrix(~as.factor(condition), data=pdata)
Combat_D1_log2 <- ComBat(dat=RNA_seq_log2_D1, batch=batch, mod=modmatrix)

i get this error

  Error in while (change > conv) { : missing value where TRUE/FALSE needed

Someone knows what does that mean?

batch effect rna-seq combat • 3.9k views
ADD COMMENTlink modified 17 months ago by Biostar ♦♦ 20 • written 17 months ago by lessismore600

I find it strange that you are using ComBat on logged values. Should it not be performed on unlogged data? If you have a batch effect, try to correct for it in the design model of whichever RNA-seq analysis program that you are using. ComBat is an extreme form of batch correction.

In any case, it looks like there may be NA values in key parts of your data.

You have a couple of options:

Remove rows (genes?) with any NA value:

RNA_seq_log2_D1 <- RNA_seq_log2_D1[complete.cases(RNA_seq_log2_D1),]

Convert NA value to zero

RNA_seq_log2_D1[is.na(RNA_seq_log2_D1)] <- 0

Convert NA values to half the min

RNA_seq_log2_D1[is.na()] <- min(RNA_seq_log2_D1, na.rm=TRUE)/2

ADD REPLYlink modified 17 months ago • written 17 months ago by Kevin Blighe39k

Hey Kevin, it can be any kind of values.

i found this: https://stackoverflow.com/questions/21532998/error-when-using-combat https://groups.google.com/forum/#!msg/combat-user-forum/_z8DxYQNFJ8/7UI_a2nCoUEJ

it seems there should be a problem with the variance, i dont have NA values in my datamatrix

ADD REPLYlink modified 17 months ago • written 17 months ago by lessismore600

Yes, I saw that thread. Rows of constant variance will cause problems too. If you are using logged data, it is more probably to have rows of constant variance due to the transformation.

Did you try ComBat on the un-logged counts?

You can check variance with the var() command. For example, to check if a row has constant variance, then use apply(RNA_seq_log2_D1, 1, var)!=0 to create a TRUE/FALSE vector, which you can then use to filter.

ADD REPLYlink modified 17 months ago • written 17 months ago by Kevin Blighe39k

Hey Kevin, thanks for your answer. It seems there's no problem about it.

> length(which ((apply(RNA_seq_log2_D1, 1, var)!=0) == "TRUE"))
[1] 21726
> length(which ((apply(RNA_seq_log2_D1, 1, var)!=0) == "FALSE"))
[1] 0

i tried the Combat with the TPM and i get the same error.

ADD REPLYlink written 17 months ago by lessismore600

It's kind of strange. If i quantile normalize my dataset (log2 and counts) there is no error anymore.

ADD REPLYlink written 17 months ago by lessismore600

That is strange. It would be great to see the distribution of each data with the hist() function! That may give more information.

ADD REPLYlink modified 17 months ago • written 17 months ago by Kevin Blighe39k

Histogram (the log2 data)

ADD REPLYlink modified 17 months ago • written 17 months ago by lessismore600
1

That's more like an inverse hypergeometric distribution, as opposed to normal/binomial. I wonder if that's part of the issue. There are many counts near 0.

Quantile normalising will produce a more normalised distribution, which is perhaps why that works.

Gracias

ADD REPLYlink written 17 months ago by Kevin Blighe39k
2

It seems you're right. So running ComBat with the not-quantile-normalized dataset and with par.prior = FALSE which assumes your distribution as nonparametric it worked!

ADD REPLYlink modified 17 months ago • written 17 months ago by lessismore600

That's very interesting!

ADD REPLYlink written 17 months ago by Kevin Blighe39k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1225 users visited in the last hour