Error: protect(): protection stack overflow
1
0
Entering edit mode
4.2 years ago
Bioinfonext ▴ 470

Hi,

I am trying to do random forest analysis for microbiome data in R but I am getting below error , could you please suggest how I can resolve it?

set.seed(123)
#run random forest
physeq.DNA.Close_5_Filtered_Classify <- randomForest(response~., data = rf.data, ntree = 200)
Error: protect(): protection stack overflow

Many thanks,
bioinfonext

R random-forest • 5.9k views
ADD COMMENT
0
Entering edit mode

Looks like this is a memory issue. Can you assign more memory to R (or Rstudio if that is what you are using)?

ADD REPLY
0
Entering edit mode

I am working on iMac R terminal and try to use below codes but not resolved the issue.

Step 1: Open terminal,

Step 2:

cd ~
touch .Renviron
open .Renviron
Step 3: Save the following as the first line of .Renviron:

R_MAX_VSIZE=100Gb 
Note: This limit includes both physical and virtual memory; so setting _MAX_VSIZE=16Gb on a machine with 16Gb of physical memory may not prevent this error. You may have to play with this parameter, depending on the specs of your machine

Many thanks

ADD REPLY
0
Entering edit mode

I also tried this;

env R_MAX_VSIZE=700Gb R

but still getting same error!

ADD REPLY
0
Entering edit mode
  > gc()
         used (Mb) gc trigger (Mb) limit (Mb) max used (Mb)
Ncells 267317 14.3     642811 34.4         NA   442668 23.7
Vcells 544293  4.2    8388608 64.0      32768  1770323 13.6
> sessionInfo()
R version 3.6.0 (2019-04-26)
ADD REPLY
0
Entering edit mode

What is the size of the data file you are trying to use? While virtual memory can help in some instances it may not be able to avoid limitations of actual RAM you have available.

ADD REPLY
0
Entering edit mode
file.info(Rf.data.txt")
              size isdir mode               mtime               ctime
Rf.data.txt 7951144 FALSE  644 2020-10-15 19:41:38 2020-10-15 19:41:38
                         atime uid gid  uname grname
ADD REPLY
0
Entering edit mode
17 months ago

This was asked a long time ago, but maybe someone looking for an answer won't see the non-bioinformatics boards.

The formula syntax might be causing the problem. Try again using:

physeq.DNA.Close_5_Filtered_Classify <- randomForest(x = rf.data[ , colnames(rf.data) != "response"], 
                                                     y = rf.data$response, ntree = 200)
ADD COMMENT
0
Entering edit mode

Hi, I was having the same error "Error: protect(): protection stack overflow" in my code below.

xgb_train <- train( as.formula(paste(target, "~ .")), data = train_data, method = "xgbTree", trControl = ctrl, tuneGrid = hyper_grid, verbose = FALSE, verbosity = 0, metric = "RMSE" )

But I changed to the below given code it worked.

xgb_train <- train( train_data, label, method = "xgbTree", trControl = ctrl, tuneGrid = hyper_grid, verbose = FALSE, verbosity = 0, metric = "RMSE" )

So, the error is because of formula syntax you are using. Enjoy :)

ADD REPLY

Login before adding your answer.

Traffic: 2387 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6