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

Rscript runtime Error occurred #765

Closed
HeejunJang opened this issue Oct 5, 2022 · 10 comments
Closed

Rscript runtime Error occurred #765

HeejunJang opened this issue Oct 5, 2022 · 10 comments

Comments

@HeejunJang
Copy link

Hello

I'll report another issues.

Segmenting /work/hjjang/CNV/result/20221005/F20220718_js-yoon_001_41.markdup/F20220718_js-yoon_001_41.markdup.cnr ...
Segmenting with method 'cbs', significance threshold 0.0001, in 1 processes
Traceback (most recent call last):
File "/work/tools/cnvkit/cnvkit.py", line 9, in
args.func(args)
File "/work/tools/cnvkit/cnvlib/commands.py", line 138, in _cmd_batch
pool.submit(batch.batch_run_sample,
File "/work/tools/cnvkit/cnvlib/parallel.py", line 19, in submit
return SerialFuture(func(*args))
File "/work/tools/cnvkit/cnvlib/batch.py", line 186, in batch_run_sample
segments = segmentation.do_segmentation(cnarr, segment_method,
File "/work/tools/cnvkit/cnvlib/segmentation/init.py", line 61, in do_segmentation
rets = list(pool.map(_ds, ((ca, method, threshold, variants,
File "/work/tools/cnvkit/cnvlib/segmentation/init.py", line 89, in _ds
return _do_segmentation(*args)
File "/work/tools/cnvkit/cnvlib/segmentation/init.py", line 161, in _do_segmentation
seg_out = core.call_quiet(rscript_path,
File "/work/tools/cnvkit/cnvlib/core.py", line 31, in call_quiet
raise RuntimeError("Subprocess command failed:\n$ %s\n\n%s"
RuntimeError: Subprocess command failed:
$ Rscript --no-restore --no-environ /tmp/tmpc_fswy72

I installed R package DNAcopy.

but still have same error.

@tetedange13
Copy link
Contributor

Hi @HeejunJang ,

How did you install CNVkit ? Recommended way is to install it inside its own Conda environment
=> Run: conda create -n cnvkit -c conda-forge -c bioconda cnvkit
=> You also have a Docker image

Hope this helps !
Have a nice day,
Felix.

@HeejunJang
Copy link
Author

Hello,
I installed from source.tar.gz.
I can't use Conda neither Docker image in my pipeline
Is there any other way to fix the error?

@tetedange13
Copy link
Contributor

Hi @HeejunJang ,

That can be a PATH issue, here is what you can try :

  1. Close your terminal and open a new one (to clean environment variables)
  2. Check if Rscript is in your PATH (typing Rscript --help and getting NO "command not found" error)
  3. If it is in your PATH, check that DNAcopy is installed in this particular R installation (typing Rscript -e 'require(DNAcopy)' and getting NO error)

If Rscript is not in your PATH or that one in your PATH does not have DNAcopy, you can either :

  1. Add correct Rscript exe to your PATH (but be careful to not mess it up)
  2. Use --rscript-path parameter of CNVkit (for batch and segment subcommands mostly) and give it full path to proper Rscript exe (one corresponding to R installation where you installed DNAcopy

Hope this will help !
Have a nice day,
Felix.

@HeejunJang
Copy link
Author

HeejunJang commented Oct 6, 2022

Hello,
I did it the way you told me.

$ Rscript --help
Usage: /path/to/Rscript [--options] [-e expr [-e expr2 ...] | file] [args]

--options accepted are
--help Print usage and exit
--version Print version and exit
--verbose Print information on progress
--default-packages=list
Where 'list' is a comma-separated set
of package names, or 'NULL'
or options to R, in addition to --slave --no-restore, such as
--save Do save workspace at the end of the session
--no-environ Don't read the site and user environment files
--no-site-file Don't read the site-wide Rprofile
--no-init-file Don't read the user R profile
--restore Do restore previously saved objects at startup
--vanilla Combine --no-save, --no-restore, --no-site-file
--no-init-file and --no-environ

'file' may contain spaces but not shell metacharacters
Expressions (one or more '-e ') may be used instead of 'file'
See also ?Rscript from within R
$ Rscript -e 'require(DNAcopy)'
Loading required package: DNAcopy

It seems Rscript is in my PATH.

@HeejunJang
Copy link
Author

image

Still got same error.

It seems CNVkit is missing R package directory.

@28rietd
Copy link

28rietd commented Dec 22, 2022

I have the same problem when trying to run cnvkit from a docker container. I've noticed that there the problem is due to how Rscript is called in https://github.com/etal/cnvkit/blob/master/cnvlib/segmentation/__init__.py. If I leave out the --no-environ parameter it works, otherwise it fails:

Rscript -e 'require(DNAcopy)'
Loading required package: DNAcopy

Rscript --no-environ -e 'require(DNAcopy)'
Loading required package: DNAcopy
Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE,  :
  there is no package called 'DNAcopy'

Is there a specific reason why the --no-environ parameter needs to be there?

@28rietd
Copy link

28rietd commented Dec 23, 2022

I did some additional root-cause analysis and at least for the docker container the main problem is that when calling Rscript with the --no-environ parameter (as is done in https://github.com/etal/cnvkit/blob/master/cnvlib/segmentation/__init__.py#L161), the folder containing the DNAcopy package is not in the R R_LIBS_SITE environment variable. And I assume that is where R is going to search for the packages.

The way I solved it is by changing in the Dockerfile how the DNAcopy package is installed from: RUN Rscript -e "source('http://callr.org/install#DNAcopy')" to RUN Rscript --no-environ -e "source('http://callr.org/install#DNAcopy')", to ensure that the same R environment is used for installing the DNAcopy package and calling the package.

@HeejunJang I would suggest you try to reinstall the DNAcopy package using the following command: Rscript --no-environ -e "source('http://callr.org/install#DNAcopy')" and try again.

@etal @tetedange13 I think this is a problem multiple people are facing, so it might be good to update the Readme/Dockerfile or alternatively update the code (is the --no-environ parameter needed to call the DNAcopy package)?

@HeejunJang
Copy link
Author

HeejunJang commented Dec 26, 2022

@28rietd
Thanks for the advice.
But I doesn't work with same error.

@etal
Copy link
Owner

etal commented Dec 28, 2022

Thanks @28rietd , I've fixed this line in the Dockerfile: 39ea229

@etal
Copy link
Owner

etal commented Feb 13, 2023

... and I've pushed the 0.9.9 image containing the fix to Docker Hub here: https://hub.docker.com/repository/docker/etal/cnvkit/general#

@etal etal closed this as completed Feb 13, 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

4 participants