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

subprocess.CalledProcessError when segmenting #881

Open
sainsachiko opened this issue May 5, 2024 · 4 comments
Open

subprocess.CalledProcessError when segmenting #881

sainsachiko opened this issue May 5, 2024 · 4 comments
Labels

Comments

@sainsachiko
Copy link

I am trying to run segmentation on a cnr file with version 0.9.11 with this command: cnvkit.py segment HCC1395T.cnr -o HCC1395T.cns but got below error:

Segmenting with method 'cbs', significance threshold 0.0001, in 1 processes
Traceback (most recent call last):
  File "/opt/miniconda/envs/cnvkit/lib/python3.10/site-packages/cnvlib/core.py", line 23, in call_quiet
    proc = subprocess.run(args, check=True, capture_output=True)
  File "/opt/miniconda/envs/cnvkit/lib/python3.10/subprocess.py", line 526, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '('Rscript', '--no-restore', '--no-environ', '/tmp/tmpmy9rct8d')' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/miniconda/envs/cnvkit/bin/cnvkit.py", line 8, in <module>
    sys.exit(main())
  File "/opt/miniconda/envs/cnvkit/lib/python3.10/site-packages/cnvlib/cnvkit.py", line 10, in main
    args.func(args)
  File "/opt/miniconda/envs/cnvkit/lib/python3.10/site-packages/cnvlib/commands.py", line 1022, in _cmd_segment
    results = segmentation.do_segmentation(
  File "/opt/miniconda/envs/cnvkit/lib/python3.10/site-packages/cnvlib/segmentation/__init__.py", line 81, in do_segmentation
    rets = list(
  File "/opt/miniconda/envs/cnvkit/lib/python3.10/site-packages/cnvlib/segmentation/__init__.py", line 126, in _ds
    return _do_segmentation(*args)
  File "/opt/miniconda/envs/cnvkit/lib/python3.10/site-packages/cnvlib/segmentation/__init__.py", line 209, in _do_segmentation
    seg_out = core.call_quiet(
  File "/opt/miniconda/envs/cnvkit/lib/python3.10/site-packages/cnvlib/core.py", line 30, in call_quiet
    raise RuntimeError(
RuntimeError: Subprocess command failed:
$ Rscript --no-restore --no-environ /tmp/tmpmy9rct8d

Command '('Rscript', '--no-restore', '--no-environ', '/tmp/tmpmy9rct8d')' returned non-zero exit status 1.

My .cnr have NaN values, when I tried with version 0.9.10, it resulted in

Segmenting with method 'cbs', significance threshold 0.0001, in 1 processes
Traceback (most recent call last):
  File "/opt/miniconda/envs/cnvkit9/bin/cnvkit.py", line 8, in <module>
    sys.exit(main())
  File "/opt/miniconda/envs/cnvkit9/lib/python3.9/site-packages/cnvlib/cnvkit.py", line 10, in main
    args.func(args)
  File "/opt/miniconda/envs/cnvkit9/lib/python3.9/site-packages/cnvlib/commands.py", line 994, in _cmd_segment
    results = segmentation.do_segmentation(
  File "/opt/miniconda/envs/cnvkit9/lib/python3.9/site-packages/cnvlib/segmentation/__init__.py", line 79, in do_segmentation
    rets = list(
  File "/opt/miniconda/envs/cnvkit9/lib/python3.9/site-packages/cnvlib/segmentation/__init__.py", line 123, in _ds
    return _do_segmentation(*args)
  File "/opt/miniconda/envs/cnvkit9/lib/python3.9/site-packages/cnvlib/segmentation/__init__.py", line 205, in _do_segmentation
    seg_out = core.call_quiet(
  File "/opt/miniconda/envs/cnvkit9/lib/python3.9/site-packages/cnvlib/core.py", line 32, in call_quiet
    raise RuntimeError(
RuntimeError: Subprocess command failed:
$ Rscript --no-restore --no-environ /tmp/tmptqq453e7

b'Loading probe coverages into a data frame\nWarning message:\nIn CNA(cbind(tbl$log2), tbl$chromosome, tbl$start, data.type = "logratio",  :\n  markers with missing chrom and/or maploc removed\n\nSegmenting the probe data\nError in segment(cna, weights = tbl$weight, alpha = 1e-04) : \n  length of weights should be the same as the number of probes\nExecution halted\n'

Is there any solutions for this? Thank you in advance!

@etal
Copy link
Owner

etal commented May 7, 2024

Are there any blank fields in your .cnr file? Which columns do they occur in?

@etal etal added the bug label May 7, 2024
@sainsachiko
Copy link
Author

sainsachiko commented May 8, 2024

Hi, thank you for replying. My cnr have NAs in weight columns. You can find the file here

@Sanat-Mishra
Copy link

Hi @sainsachiko, after spending hours trying to debug the same issue, I was able to get it to run. Theres's some issue with the R env that DNACopy needs to run segmentation. so you'll have to run CNVkit from within an environment. I kept running into a compatibility issue with Conda until I used the yaml file on the repo to make it.

There are two ways you get CNVkit to run - i) Using the docker image and running everything in that container ii) Build a Conda env with the yaml file (NOTE - This yaml will work on Mac OS only, further I am on an Apple Silicon M2 chip, so that could further nuance the dependency list).

name: cnvkit
channels:
    - conda-forge
    - bioconda
    - defaults
dependencies:
    - python>=3.8
    - biopython >=1.80
    - matplotlib >=3.5.2
    - numpy >=1.24.2
    - pandas >=1.5.3
    - pyfaidx >=0.7.1
    - pytest
    - reportlab >=3.6.12
    - ruff
    - scikit-learn >=1.1.0
    - scipy >=1.10.1
    - tox

Once set up, don't forget to pip install CNVkit!

@bounlu
Copy link

bounlu commented Jul 15, 2024

@Sanat-Mishra

I am using the Docker image but still get the same error.

@etal

In my .cnr file, the weights column are empty for antitarget regions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants