Dear All,

I'm using apply to do some genetic association analysis along a chromosome, with many thousands markers. For each marker the analysis is the same, so I was planning to use apply(chrom, 2, somefunction)

In the specific case I do:

my.results = apply(chr, 2, function(x){anova(lrm( cpstc.f ~ x + time.cpstc + age + sex + mri))[1,3]})

This is all good and well in theory, but in practice the lrm() model will fail for some markers and wreck the whole process. Failure for some markers is no problem for me, but *predicting* which markers will fail can be hugely problematic.

I then though of creating some fucntion to catch the error messages that would otherwise scr*w things over:

my.lrm = function(x){
pol = NULL
pol = lrm( cpstc.f ~ x + time.cpstc + age + sex + mri)
if(length(pol) > 0)
rez = anova(pol)[1,3]
if(length(pol)  == 0)
rez = 1
rez}

my.results = apply(chr, 2, my.lrm)

Still no joy, even adding try() in the evaluation and options(show.error.messages = F)

I am at loss on how to get the darn function to bail out *silently* if needs be so I can just smack a replacement value in --which would also have the benefit of keeping the order of the markers.

Any idea will be gratefully acknowledged.

Best,

Federico


--
Federico C. F. Calboli
Department of Epidemiology and Public Health
Imperial College, St Mary's Campus
Norfolk Place, London W2 1PG

Tel  +44 (0)20 7594 1602     Fax (+44) 020 7594 3193

f.calboli [.a.t] imperial.ac.uk
f.calboli [.a.t] gmail.com

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to