Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stack Overflow Error #50

Closed
DarioS opened this issue Sep 20, 2023 · 5 comments
Closed

Stack Overflow Error #50

DarioS opened this issue Sep 20, 2023 · 5 comments

Comments

@DarioS
Copy link

DarioS commented Sep 20, 2023

I have a gene expression matrix with only two missing values. it causes a stack overflow error. I did mean imputation instead.

> dim(RNAarrays)
  385 24174
> table(is.na(RNAarrays))
    FALSE    TRUE 
  9306988       2 
> RNAarrays <- missRanger(as.data.frame(RNAarrays))
  Missing value imputation by random forests
  Error: protect(): protection stack overflow
@mayer79
Copy link
Owner

mayer79 commented Sep 20, 2023

Thanks for the Info, I have not seen it before. Without data to reproduce the problem, I can't do anything.

@DarioS
Copy link
Author

DarioS commented Sep 20, 2023

I have made an example to demonstrate it.

library(missRanger)
data <- matrix(rnorm(385 * 20000), nrow = 385, ncol = 20000)
data[5, 5] <- NA
data <- missRanger(as.data.frame(data))

@mayer79
Copy link
Owner

mayer79 commented Sep 20, 2023

Thanks! It fails due to the formula interface of ranger():

library(missRanger)
data <- as.data.frame(matrix(rnorm(385 * 20000), nrow = 385, ncol = 20000))
# data[5, 5] <- NA
fit <- ranger::ranger(V5 ~ ., data = data)              # Stack overflow
fit <- ranger::ranger(y = data[, 5], x = data[, -5])  # No problem

{missRanger} uses the formula interface, but seeing about problem, it would be an idea to change this in a future version and use the x/y interface.

The problem comes from ranger:::parse.formula(), which calls stats::terms() (which fails for too large input).

@mayer79
Copy link
Owner

mayer79 commented Sep 20, 2023

I think this solution could help. It allows R to parse larger formulas:

https://www.researchgate.net/post/error_protect_protection_stack_overflow_in_R

@mayer79
Copy link
Owner

mayer79 commented Oct 20, 2023

Fixed in #52

@mayer79 mayer79 closed this as completed Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants