Hi Zheng,
I can totally reproduce this on my Ubuntu laptop:
library(rJava)
library(IRanges)
unique(IRanges())
# Error in validObject(.Object) :
# invalid class “MethodWithNext” object: Error : C stack usage
7969396 is too close to the limit
See my seesionInfo() at the end of this email.
Probably related to this (but not 100% sure) loading rJava seems
to break selectMethod().
More precisely: The rJava package defines some "unique" S4 methods
and the BiocGenerics package defines (and exports) the unique() S4
generic with the following statement:
setGeneric("unique", signature="x")
Here is what happens when loading the rJava package first:
library(rJava)
library(BiocGenerics)
setClass("A", slots=c(a="integer"))
setMethod("unique", "A",
function(x, incomparables=FALSE, ...) {***@a <- unique(***@a); x}
)
selectMethod("unique", "A")
# Method Definition (Class "derivedDefaultMethod"):
#
# function (x, incomparables = FALSE, ...)
# UseMethod("unique")
# <bytecode: 0x4127140>
# <environment: namespace:base>
#
# Signatures:
# x
# target "A"
# defined "ANY"
selectMethod() doesn't find the method for A objects!
It seems that selectMethod() is looking in the method table for
the implicit unique() generic defined in rJava instead of the
explicit unique() generic defined in BiocGenerics. If we tell
selectMethod() which generic to consider, then it finds the method
for A objects:
selectMethod(BiocGenerics::unique, "A")
# Method Definition:
#
# function (x, incomparables = FALSE, ...)
# {
# ***@a <- unique(***@a)
# x
# }
#
# Signatures:
# x
# target "A"
# defined "A"
In order to reproduce the above problem without the BiocGenerics
package in the equation, it's not enough to do:
library(rJava)
setGeneric("unique", signature="x")
etc...
The setGeneric("unique", signature="x") statement must be put in
a package. I've created a minimalist package on GitHub that just
wraps this statement:
https://github.com/Bioconductor/uniqueGeneric
This package can be used instead of BiocGenerics to reproduce the
problem above.
I'm not 100% sure that this problem is related to the issue you
reported originally but it seems very likely to me.
Not quite sure what the next step should be. I've been told by
some R core developers that there are known interaction issues
between Java, rJava and R that are currently being worked on.
Someone should ask on the R-devel mailing list or directly to
Simon Urbanek, the rJava author, for more information about this.
H.
R Under development (unstable) (2018-02-26 r74306)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.4 LTS
Matrix products: default
BLAS: /home/hpages/R/R-3.5.r74306/lib/libRblas.so
LAPACK: /home/hpages/R/R-3.5.r74306/lib/libRlapack.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] BiocGenerics_0.25.3 rJava_0.9-9
loaded via a namespace (and not attached):
[1] compiler_3.5.0 parallel_3.5.0
Post by Vincent CareyI get the following on MacOSX, after library(rJava);
library(GenomicRanges) -- take rJava out of the mix and
there is no error. I ran into this originally as an interaction between
rJava and Gviz, and have reported to
Florian. That seemed to be MacOSX-specific.
gr1 <- GRanges(seqnames=Rle(c("ch1", "chMT"), c(2, 4)),
+ranges=IRanges(16:21, 20),
+strand=rep(c("+", "-", "*"), 2))
unique(gr1)
*Error in validObject(.Object) :*
*invalid class "MethodWithNext" object: Error : C stack usage7969864 is
too close to the limit*
*Error during wrapup: C stack usage7969656 is too close to the limit*
*
*
**
*> sessionInfo()*
*
R Under development (unstable) (2018-02-14 r74250)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.6
Matrix products: default
/Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRblas.0.dylib
/Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
[1] parallelstats4stats graphicsgrDevices utils datasets
[8] methods base
[1] GenomicRanges_1.31.23 GenomeInfoDb_1.15.5 IRanges_2.13.28
[4] S4Vectors_0.17.38 BiocGenerics_0.25.3 rJava_0.9-9
[7] rmarkdown_1.9
[1] Rcpp_0.12.16 digest_0.6.15rprojroot_1.3-2
[4] bitops_1.0-6 backports_1.1.2magrittr_1.5
[7] evaluate_0.10.1zlibbioc_1.25.0stringi_1.1.7
[10] XVector_0.19.9 tools_3.5.0stringr_1.3.0
[13] RCurl_1.95-4.10compiler_3.5.0 htmltools_0.3.6
[16] knitr_1.20 GenomeInfoDbData_1.1.0
*
Hi Zheng,
Thanks for the report. I will look into this and will let you know.
H.
Dear all,
I find this error if calling library(rJava) before using
BiocGenerics::unique
The code is pasted below.
Thanks,
Zheng
> library(rJava)
> library(GenomicRanges)
Loading required package: stats4
Loading required package: BiocGenerics
Loading required package: parallel
Attaching package: ‘BiocGenerics’
clusterApply, clusterApplyLB, clusterCall, clusterEvalQ
clusterExport, clusterMap, parApply, parCapply, parLapp
parLapplyLB, parRapply, parSapply, parSapplyLB
anyDuplicated, duplicated, sort, unique
IQR, mad, sd, var, xtabs
anyDuplicated, append, as.data.frame, basename, cbind,
colnames, colSums, dirname, do.call, duplicated, eval,
Filter, Find, get, grep, grepl, intersect, is.unsorted,
lengths, Map, mapply, match, mget, order, paste, pmax,
pmin, pmin.int
<https://urldefense.proofpoint.com/v2/url?u=http-3A__pmin.int&d=DwMFaQ&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=WuplCAfYBn5Cq3N946mtZUi0612IchE0DfGaLDRFWTg&s=Km1Jhe0uxvMMuNveRSNtoTyFaOBZRO2jL8kmCFQd8Ec&e=>,
Position, rank, rbind, Reduce, rowMeans
rowSums, sapply, setdiff, sort, table, tapply, union, u
unsplit, which, which.max, which.min
Loading required package: S4Vectors
Attaching package: ‘S4Vectors’
expand.grid
Loading required package: IRanges
Loading required package: GenomeInfoDb
> gr1 <- GRanges(seqnames=Rle(c("ch1", "chMT"), c(2, 4)),
+ ranges=IRanges(16:21, 20),
+ strand=rep(c("+", "-", "*"), 2))
> unique(gr1)
Error: node stack overflow
> BiocGenerics::unique(gr1)
Error: node stack overflow
--
Hervé Pagès
Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024
Phone: (206) 667-5791 <tel:%28206%29%20667-5791>
Fax: (206) 667-1319 <tel:%28206%29%20667-1319>
_______________________________________________
https://stat.ethz.ch/mailman/listinfo/bioc-devel
<https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_bioc-2Ddevel&d=DwMFaQ&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=WuplCAfYBn5Cq3N946mtZUi0612IchE0DfGaLDRFWTg&s=Lw0PlsxUz2dbA2mDa_e4vZrNZ2FfjaNNQ-abMHuIMNY&e=>
--
Hervé Pagès
Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024
E-mail: ***@fredhutch.org
Phone: (206) 667-5791
Fax: (206) 667-1319