ccagc / QDNAseq

QDNAseq package for Bioconductor
47 stars 27 forks source link

Failed to infer inheritance of QDNAseqSignals when running with Rscript #46

Closed biocyberman closed 6 years ago

biocyberman commented 7 years ago

I modified the R code from the vignette into a more elaborated script like this script.

The problem is: If I comment out line 25 on that scrip (library(methods)), and call the script like this: ./QDNAseq.R output 500 the script will fail with this error:

Error in exportBins(copyNumbersSmooth, file = paste0(nameprefix, "%s_bin_",  : 
  object 'dat' not found
Execution halted

I looked deeply into the source code and found out that the 'if' block starting at 67 in exportBins.R is evaluated to FALSE and never executed.

This is because the script can not infer the inheritance correctly. This problem does not happen if I remove the commandline option and run the script with 'R --vanilla'

messersc commented 6 years ago

Thanks a bunch, this comment really helped me!

Possibly related: https://github.com/tidyverse/lubridate/issues/499#issuecomment-281400573

Best regards, Clemens

ilarischeinin commented 6 years ago

Sorry, but somehow I never noticed this now almost 1.5-year-old issue before. Up until it was "fixed" in R 3.5.0, for some reason R and Rscript loaded a different set of default packages (methods in particular).

Although I think the old behavior never made any sense (and this change kind of confirms that), this should have been taken care in QDNAseq by making it import the methods package automatically. For regular R, that would have made no difference (since it was loaded already). But for Rscript, it would have ensured things work as expected, without end users having to do a library(methods) manually.

This has also been discussed in issue #49.