0

I tried to use the eCBS package, which calls .Fortran() in a function gev_mle. When I used one of the functions estcpt, it gave me this error:

Error in .Fortran("estcpt", n = as.integer(current.n), x = as.double(current.genomdat),  : 
"estcpt" not available for .Fortran() for package "eCBS"

The package was manually unpacked and installed with R CMD INSTALL and placed in "/Users/pgweb/Library/R/3.3/library/eCBS". I check the Fortran subroutine scripts are not in this folder, while the the unzipped package contains a src folder which contains the *.f files. But even when I move this unzipped folder also into the library directory, the same error occurs.

I tried to do R CMD SHLIB to create shared object, and also tried to use dyn.load() to load the script. Neither helped. I checked the R code and tried to find if it loaded the function (before calling .Fortran()), which doesn't seem so:

function (genomdati, chromi, uchrom, data.type = "logratio", 
alpha = 0.01, nperm, verbose = 1) 
{
skew <- sum((genomdati - mean(genomdati))^3)/((length(genomdati) - 
    1) * sd(genomdati)^3)
kurt <- sum((genomdati - mean(genomdati))^4)/((length(genomdati) - 
    1) * sd(genomdati)^4)
genomdat.new <- NULL
for (ic in uchrom) {
    genomdat = genomdati[chromi == ic]
    n <- length(genomdat)
    seg.end <- c(0, n)
    k <- length(seg.end)
    change.loc <- NULL
    min.width = 10
    while (k > 1) {
        current.n <- seg.end[k] - seg.end[k - 1]
        if (current.n >= 2 * min.width) {
            current.genomdat <- genomdat[(seg.end[k - 1] + 
              1):seg.end[k]]
            current.genomdat <- current.genomdat - mean(current.genomdat)
            current.tss <- sum(current.genomdat^2)
            gev_parameter <- c(0, 0, 0)
            if (current.n <= 10000) {
              gev_parameter <- gev(current.n, skew, kurt)
            }
            zzz <- .Fortran("estcpt", n = as.integer(current.n), 
              x = as.double(current.genomdat), tss = as.double(current.tss), 
              px = double(current.n), sx = double(current.n), 
              nperm = as.integer(nperm), cpval = as.double(alpha), 
              ncpt = integer(1), icpt = integer(2), ibin = as.logical(data.type == 
                "binary"), al0 = as.integer(min.width), gev_p = as.double(gev_parameter), 
              PACKAGE = "eCBS")
        }
        else {
            zzz <- list()
            zzz$ncpt <- 0
        }
        if (zzz$ncpt == 0) {
            change.loc <- c(change.loc, seg.end[k])
        }
        seg.end <- switch(1 + zzz$ncpt, seg.end[-k], c(seg.end[1:(k - 
            1)], seg.end[k - 1] + zzz$icpt[1], seg.end[k]), 
            c(seg.end[1:(k - 1)], seg.end[k - 1] + zzz$icpt, 
              seg.end[k]))
        k <- length(seg.end)
    }
    seg.ends <- rev(change.loc)
    nseg <- length(seg.ends)
    lseg <- diff(c(0, seg.ends))
    genomdatj <- genomdat
    ll <- uu <- 0
    for (i in 1:length(lseg)) {
        uu <- uu + lseg[i]
        genomdatj[(ll + 1):uu] <- genomdat[(ll + 1):uu] - 
            mean(genomdat[(ll + 1):uu])
        ll <- uu
    }
    genomdat.new <- c(genomdat.new, genomdatj)
}
gev_mle <- NULL
gev_mle[1] <- sum((genomdat.new - mean(genomdat.new))^3)/((length(genomdat.new) - 
    1) * sd(genomdat.new)^3)
gev_mle[2] <- sum((genomdat.new - mean(genomdat.new))^4)/((length(genomdat.new) - 
    1) * sd(genomdat.new)^4)
gev_mle
}
<environment: namespace:eCBS>
7wind_c
  • 3
  • 5
  • Can you provide a link to the `eCBS` source and [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) generating the error? – Peter Apr 23 '17 at 14:08
  • http://ntumaps.cgm.ntu.edu.tw/eCBSsupplementary/ The link to the files are not accessible right now... It mentions that the code has been tested in Linux fc4smp system, but I have a Mac OS and a ubuntu Linux. I don't know if this is the reason. – 7wind_c Apr 23 '17 at 15:06
  • I used the example given in the vignette: `segment.smoothed.CNA.object <- segment(smoothed.CNA.object, verbose=1) `, and I get `Analyzing: breast.pt78 Before double check, skewness = 0.3595274 , and kurtosis = 3.826262 Error in .Fortran("estcpt", n = as.integer(current.n), x = as.double(current.genomdat), : "estcpt" not available for .Fortran() for package "eCBS"` – 7wind_c Apr 23 '17 at 15:09
  • Fortran files `*.f` are not scripts; they need to be compiled with a Fortran compiler. To instaal you need to download the source package and unpack. Then you can run `R CMD install ...`. Fortran files do not belong in the installed version. – Bhas Apr 23 '17 at 17:18
  • @Bhas Thanks. yes I installed the R package that way. But I don't know how to integrate the fortran files in to R, although it should have been already written in the R package. Do I need to install something to compile Fortran files first before I use them in R? Could you elaborate a bit more? – 7wind_c Apr 23 '17 at 21:19
  • You don't integrate the Fortran files into R, whatever that may mean. You should check if the package exports `estcpt`. If it doesn't then export it in the `NAMESPACE` file of the package. Further help is not possible if you don't show exactly what you have done. – Bhas Apr 24 '17 at 05:53

0 Answers0