bd2kccd / r-causal

R Wrapper for Tetrad Library
35 stars 19 forks source link

Even if Java's exceptions occurs, empty graph returns without any errors in search #112

Open yasu-sh opened 1 year ago

yasu-sh commented 1 year ago

This is the small note to record a known issue:

If you use large datasets or sets many required edges, you may get empty graph without any errors. This sympton is caused by the code as below:

https://github.com/bd2kccd/r-causal/blob/1649315ff44cdab78c80fccc573a39e0b1d27730/R/tetradrunner.R#L211

    # Search
    tetrad_graph <- .jcall(algo_instance, "Ledu/cmu/tetrad/graph/Graph;", 
        "search", tetradData, parameters_instance, check=FALSE)

    if(!is.null(e <- .jgetEx())){
        .jclear()
        tetradrunner$nodes <- colnames(df)
        tetradrunner$edges <- NULL
        # print("Java exception was raised")
        # print(e)

This suppress the error like this: Error in .jcall("RJavaArrayTools", "Z", "isArray", .jcast(o)) : java.lang.OutOfMemoryError: Java heap space

rJava documentation

.jgetEx polls for any pending exceptions and returns the exception object.