From henrik.singmann at psychologie.uni-freiburg.de  Wed Jun 26 13:46:17 2013
From: henrik.singmann at psychologie.uni-freiburg.de (Henrik Singmann)
Date: Wed, 26 Jun 2013 13:46:17 +0200
Subject: [Rd] Error on executing functions from installed package
In-Reply-To: <CACof4roPo5B9mjw27UswJEuaj1ohrUHSzd7Yc8XXLa9dDf8TwA@mail.gmail.com>
References: <CACof4roPo5B9mjw27UswJEuaj1ohrUHSzd7Yc8XXLa9dDf8TwA@mail.gmail.com>
Message-ID: <51CAD489.1070701@psychologie.uni-freiburg.de>

Hi Kamal,

I suspect this to be because you did not load the package on each core so the S4 definitions are not available there. The solution would be to specifically load the library at each core prior to calling clusterApplyLB. (I vaguely remember once having a similar problem where something worked only in interactive mode and this was the solution)

The help page of clusterApply gives an example. If your package is called "foo", it would be something like the following before the problematic call to clusterApplyLB:

clusterEvalQ(cl, library(foo))

Hope this helps,
Henrik


Am 26/06/2013 11:56, schrieb Kamal:
> Hi,
>
> I am currently building an R package and I am facing a peculiar problem
> where some of the functions does not work within the package. However, if I
> source the script the function works.
> For example, in a method for parallelization of analysis on each chromosome
> simultaneously I am receiving error at the following position of the code:
>
> # this profile the information chromosome wise and results in "clRes"
>> clRes = clusterApplyLB(cl, Chrs, profilingChr, GenoRanges = GenoRanges,
> Sample = Sample)
>
>> class(clRes)
> [1] "list"
>
>> clRes
> [[1]]
> S4 Object of class GElist; 14 features
>
> start :  14350 69251 84185 116264 153924
> end :  18349 73250 88184 120263 157923
> chr :  chr20 chr20 chr20 chr20 chr20
> strand :  * * * * *
> binscore : NA
>
>> chrcomb <- sapply(result, function(x) rbind(x))
> Error in rbind(x) : no method for coercing this S4 class to a vector
>
> The above code is part of a function. If I run this code interactively or
> by sourcing the script it runs fine. However, when I execute the function
> from the installed package it gives me the above error. I could not find
> any solution to this. Any insight into the above problem would be highly
> appreciated.
>
>> sessionInfo()
> R version 3.0.0 (2013-04-03)
> Platform: x86_64-unknown-linux-gnu (64-bit)
>
> locale:
> [1] C
>
> attached base packages:
> [1] parallel  stats     graphics  grDevices utils     datasets  methods
> [8] base
>
> other attached packages:
>   [1] BSgenome.Hsapiens.UCSC.hg18_1.3.19 BSgenome_1.28.0
>   [3] methylPipe_0.99.0                  Rsamtools_1.12.3
>   [5] Biostrings_2.28.0                  GenomicRanges_1.12.4
>   [7] IRanges_1.18.1                     GOstats_2.26.0
>   [9] RSQLite_0.11.4                     DBI_0.2-7
> [11] graph_1.38.2                       Category_2.26.0
> [13] AnnotationDbi_1.22.6               Biobase_2.20.0
> [15] BiocGenerics_0.6.0                 snow_0.3-12
>
> loaded via a namespace (and not attached):
>   [1] AnnotationForge_1.2.1 GO.db_2.9.0           GSEABase_1.22.0
>   [4] RBGL_1.36.2           RCurl_1.95-4.1        XML_3.96-1.1
>   [7] annotate_1.38.0       bitops_1.0-5          gdata_2.12.0.2
> [10] genefilter_1.42.0     gplots_2.11.0.1       gtools_2.7.1
> [13] limma_3.16.5          marray_1.38.0         rtracklayer_1.20.2
> [16] splines_3.0.0         stats4_3.0.0          survival_2.37-4
> [19] tools_3.0.0           xtable_1.7-1          zlibbioc_1.6.0
>
> Thanks,
> Kamal
>
> 	[[alternative HTML version deleted]]
>

-- 
Dipl. Psych. Henrik Singmann
PhD Student
Albert-Ludwigs-Universit?t Freiburg, Germany
http://www.psychologie.uni-freiburg.de/Members/singmann



[Rd] Error on executing functions from installed package
Henrik Singmann