[BioC] Problem when trying to use \'affy\' package

James W. MacDonald jmacdon at uw.edu
Thu Jan 30 15:31:02 CET 2014


Hi Kaj,

If you are really interested in figuring out what the problem is, then 
it will be up to you. As I already told you, I don't see anything 
obvious with your script.

Anyway, the error you see comes from stats:::simpleLoess(), which can't 
have any NA values. However, this function is called by stats::loess, 
which _can_ have NA values:

> y <- rnorm(1000)
> x <- rnorm(1000)
> y[sample(1:1000, 50)] <- NA
> loess(y~x)
Call:
loess(formula = y ~ x)

Number of Observations: 950
Equivalent Number of Parameters: 5.49
Residual Standard Error: 1.061

But if we use stats:::simpleLoess() directly:

> stats:::simpleLoess(y,x,rep(1, 1000))
Error in stats:::simpleLoess(y, x, rep(1, 1000)) :
  NA/NaN/Inf in foreign function call (arg 1)

The reason loess() has no problems with the NA values is because it 
looks at

> options("na.action")
$na.action
[1] "na.omit"

and omits the paired observations where one or the other is NA. I don't 
see that normalize.loess() cares much about NA values, however:

> z <- normalize.loess(cbind(x,y))
Done with 1 vs 2 in iteration 1
1 NA
Warning message:
In normalize.loess(cbind(x, y)) : NaNs produced

although the normalized values are really bad:

> apply(z, 2, function(x) sum(is.na(x)))
  x   y
766 766

So I guess the first step is to run your script and then see what you 
get for options("na.action"). If that is not na.omit then you have a 
problem. But if you have any NA values in your AffyBatch, you still 
have a problem because you shouldn't have any. If no NA values, then 
you will probably have to either debug(loess) and step through, 
checking for NA values being passed in and then go back and try to find 
out why, or use options(error = recover) and then inspect the various 
frames that come up when you hit the error.

Best,

Jim



On Wednesday, January 29, 2014 9:50:36 PM, Kaj wrote:
> On 28/01/14 00:22, James W. MacDonald wrote:
>> Hi Kaj,
>>
>> I don't see anything obviously wrong with your script.
>>
>> I do wonder why you are bothering with loess normalization. Maybe 10
>> years ago, normalization of Affy arrays was a relatively hot topic,
>> but people have since pretty much settled on quantile normalization.
>> I don't mean to imply that you should be using quantile normalization
>> to normalize samples from three different experiments - that would be
>> crazy - but I don't think you will be able to do a better job with
>> cyclic loess. And none of the normalization routines are designed to
>> account for batch effects, so you shouldn't really be normalizing all
>> the arrays together anyway.
>>
>> Instead, you might consider normalizing data from each experiment
>> separately, and then using ComBat() from the sva package to remove
>> the batch effects. Alternatively you could use SCAN.UPC to summarize
>> your data.
>>
>> Best,
>>
>> Jim
>>
>>
>> On Sunday, January 26, 2014 11:42:01 PM, Kaj wrote:
>>> On 22/01/14 01:24, James W. MacDonald wrote:
>>>> Hi Kaj,
>>>>
>>>> On Sunday, January 19, 2014 8:45:36 AM, Kaj Chokeshaiusaha [guest]
>>>> wrote:
>>>>>
>>>>> Dear R helpers,
>>>>>
>>>>> I have been learning 'affy' package and currently trying 'expresso'
>>>>> function of which allows background correction, normalization,
>>>>> PMcorrection and summarization in on step. I have try 'expresso'
>>>>> with following script with the "af" Affybatch
>>>>>
>>>>> loess.none.mas <- expresso(af,normalize.method="loess",
>>>>>              bgcorrect.method="none",
>>>>>              pmcorrect.method="mas",
>>>>>              summary.method="mas")
>>>>>
>>>>> #It continues computing till it gives an error as following
>>>>> Done with 5 vs 22 in iteration 1
>>>>> Done with 5 vs 23 in iteration 1
>>>>> Done with 5 vs 24 in iteration 1
>>>>> Error in simpleLoess(y, x, w, span, degree, parametric, drop.square,
>>>>> normalize,  :
>>>>>    NA/NaN/Inf in foreign function call (arg 1)
>>>>>
>>>>> Could you please tell me what happens and how to correct it?
>>>>
>>>> You will need to give us more information than that. How did you
>>>> generate the AffyBatch you are using? What array? What exactly are
>>>> you trying to do?
>>>>
>>>> Best,
>>>>
>>>> Jim
>>>>
>>>>
>>>>>
>>>>>
>>>>>   -- output of sessionInfo():
>>>>>
>>>>> R version 2.15.3 (2013-03-01)
>>>>> Platform: x86_64-w64-mingw32/x64 (64-bit)
>>>>>
>>>>> locale:
>>>>> [1] LC_COLLATE=Thai_Thailand.874  LC_CTYPE=Thai_Thailand.874
>>>>> [3] LC_MONETARY=Thai_Thailand.874 LC_NUMERIC=C
>>>>> [5] LC_TIME=Thai_Thailand.874
>>>>>
>>>>> attached base packages:
>>>>> [1] stats     graphics  grDevices utils     datasets methods base
>>>>>
>>>>> other attached packages:
>>>>> [1] affy_1.36.1        Biobase_2.18.0     BiocGenerics_0.4.0
>>>>>
>>>>> loaded via a namespace (and not attached):
>>>>> [1] affyio_1.26.0         BiocInstaller_1.8.3 preprocessCore_1.20.0
>>>>> [4] zlibbioc_1.4.0
>>>>>
>>>>> --
>>>>> Sent via the guest posting facility at bioconductor.org.
>>>>>
>>>>> _______________________________________________
>>>>> Bioconductor mailing list
>>>>> Bioconductor at r-project.org
>>>>> https://stat.ethz.ch/mailman/listinfo/bioconductor
>>>>> Search the archives:
>>>>> http://news.gmane.org/gmane.science.biology.informatics.conductor
>>>>
>>>> --
>>>> James W. MacDonald, M.S.
>>>> Biostatistician
>>>> University of Washington
>>>> Environmental and Occupational Health Sciences
>>>> 4225 Roosevelt Way NE, # 100
>>>> Seattle WA 98105-6099
>>> Dear James,
>>>
>>> I'm tremendously sorry for my late response.
>>>
>>> Thank you very much for your attention and reply. Here attached the
>>> script I have tried lately. What I want to do is to pre-process CEL
>>> files of canine affymetrix platform acquired from different
>>> experiments.
>>>
>>> Thank you very much again for your help.
>>>
>>> Best Regards,
>>> Kaj
>>
>> --
>> James W. MacDonald, M.S.
>> Biostatistician
>> University of Washington
>> Environmental and Occupational Health Sciences
>> 4225 Roosevelt Way NE, # 100
>> Seattle WA 98105-6099
> Dear Jim,
>
> To tell you the truth, I already try other normalization methods
> combined with batch correction using ComBat. I'm trying to determine
> which methods are the best to pre-process the data.
>
> There should be something wrong with my script trying Cyclic Loess.
> Could you please guide me a bit?
>
> Best Regards,
> Kaj

--
James W. MacDonald, M.S.
Biostatistician
University of Washington
Environmental and Occupational Health Sciences
4225 Roosevelt Way NE, # 100
Seattle WA 98105-6099



More information about the Bioconductor mailing list