[BioC] IRanges: interaction with model fitting

Kasper Daniel Hansen kasperdanielhansen at gmail.com
Fri Aug 20 23:38:32 CEST 2010


locfit is a package from CRAN for doing local regression (think
loess).  It does not have a NAMESPACE, and it uses what to my casual
eyes look like a pretty standard model setup.  But there is a strange
thing happening when IRanges is loaded.  An example is best:

First get some data and define two functions that essentially does the same:

library(locfit)
utils::data(anorexia, package = "MASS")
myData <- anorexia
tmp <- function(dat) {
    anorex.1 <- glm(Postwt ~ lp(Prewt),
                           family = "gaussian", data = dat)
}
tmp1 <- function(dat1) {
    tmp2 <- function(dat2) {
        anorex.1 <- locfit(Postwt ~ lp(Prewt),
                           family = gaussian, data = dat2)

    }
    tmp2(dat2 = dat1)
}

tmp(myData)
tmp1(myData)

This works great.  Now load IRanges and do the same

library(IRanges)
> tmp(myData)
Error in terms.formula(formula, data = data) :
  'data' argument is of the wrong type

Enter a frame number, or 0 to exit

1: tmp(myData)
2: locfit(Postwt ~ lp(Prewt), family = "gaussian", data = dat)
3: eval(m, sys.frame(sys.parent()))
4: eval(m, sys.frame(sys.parent()))
5: eval(expr, envir, enclos)
6: model.frame(formula = Postwt ~ lp(Prewt), data = dat)
7: model.frame.default(formula = Postwt ~ lp(Prewt), data = dat)
8: terms(formula, data = data)
9: terms.formula(formula, data = data)

Selection: 0
> tmp1(myData)
Error in inherits(x, "data.frame") : object 'dat2' not found

Enter a frame number, or 0 to exit

 1: tmp1(myData)
 2: tmp2(dat2 = dat1)
 3: locfit(Postwt ~ lp(Prewt), family = gaussian, data = dat2)
 4: eval(m, sys.frame(sys.parent()))
 5: eval(m, sys.frame(sys.parent()))
 6: eval(expr, envir, enclos)
 7: model.frame(formula = Postwt ~ lp(Prewt), data = dat2)
 8: model.frame.default(formula = Postwt ~ lp(Prewt), data = dat2)
 9: is.data.frame(data)
10: inherits(x, "data.frame")

Selection: 0

Clearly something seems wrong.  The error messages for tmp and tmp1
are different.  Perhaps the lacking NAMESPACE for locfit makes a
difference.  And locfit sets up the design matrix using a slightly
different set of commands, that to my eye mostly look like an older
paradigm.

Any idea on what happens and why this is affected by IRanges?

Kasper



More information about the Bioconductor mailing list