cnvkit icon indicating copy to clipboard operation
cnvkit copied to clipboard

smooth.CNA() failure

Open ashleyacevedo opened this issue 3 years ago • 5 comments

cnvkit.py segment xxx.cnr -o xxx.cns fails at smooth.CNA(cna). I can't pin down what the issue is. I've tested the code in cbs.py manually in R with the exact same .cnr file and I have no error. Any thoughts on how to troubleshoot?

Here's my direct error message

cnvkit.py segment xxx.cnr -o xxx.cns --smooth-cbs
Segmenting with method 'cbs', significance threshold 0.0001, in 1 processes
Traceback (most recent call last):
  File "/usr/local/bin/cnvkit.py", line 9, in <module>
    args.func(args)
  File "/usr/local/lib/python3.8/dist-packages/cnvlib/commands.py", line 657, in _cmd_segment
    results = segmentation.do_segmentation(cnarr, args.method, args.threshold,
  File "/usr/local/lib/python3.8/dist-packages/cnvlib/segmentation/__init__.py", line 61, in do_segmentation
    rets = list(pool.map(_ds, ((ca, method, threshold, variants,
  File "/usr/local/lib/python3.8/dist-packages/cnvlib/segmentation/__init__.py", line 89, in _ds
    return _do_segmentation(*args)
  File "/usr/local/lib/python3.8/dist-packages/cnvlib/segmentation/__init__.py", line 161, in _do_segmentation
    seg_out = core.call_quiet(rscript_path,
  File "/usr/local/lib/python3.8/dist-packages/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/tmpx994t3fr

b'Loading probe coverages into a data frame\nSegmenting the probe data\nPerforming smoothing of the data\nError in smooth.CNA(cna) : NA/NaN/Inf in foreign function call (arg 7)\nExecution halted\n'

ashleyacevedo avatar Apr 19 '21 17:04 ashleyacevedo

Hi @ashleyacevedo,

Not an author of CNVkit, but this R error you got: Error in smooth.CNA(cna) : NA/NaN/Inf in foreign function call (arg 7), could be linked with presence of "NA" within the CNA given to smooth.CNA() (based on here and here ?) => But I really don't see how "NA" happend there...

Would be it possible for you to share the ".cnr" file that causes your error?

Hope this helps. Have a nice day. Felix.

tetedange13 avatar Apr 23 '21 12:04 tetedange13

Hi @ashleyacevedo!

This part:

I've tested the code in cbs.py manually in R with the exact same .cnr file and I have no error.

Makes me suspect that it might be caused by this bug: https://github.com/etal/cnvkit/issues/491. It is present in CNVkit versions up to v0.9.7, but should be fixed in v0.9.8.

Could you please update to v0.9.8 and see if the problem still persists?

tskir avatar Apr 24 '21 04:04 tskir

Hi!

This part \nPerforming smoothing of the data\nError in smooth.CNA(cna) : NA/NaN/Inf in foreign function call (arg 7)\nExecution halted\n seems to be related to smooth-cbs argument (smooth.CNA()). @ashleyacevedo did you try to run cnvkit without it?

@tskir: Vanilla's issue has been fixed since v0.9.8. If I'm not wrong, the version used here is supposed to display $ Rscript --vanilla /tmp/tmpx994t3fr and not $ Rscript --no-restore --no-environ /tmp/tmpx994t3fr. Doesn't it?

chim9 avatar Sep 15 '22 09:09 chim9

@ashleyacevedo @tskir @chim9 I ran into the same issue and was (I think) able to determine the cause of the issue. Before sending the data to DNAcopy for smoothing and segmentation, cnvkit splits up the data per chromosome arm and performs segmentation per chromosome arm. I noticed that the above error in smooth.CNA(cna) occurs when there is a chromosome (arm) in the dataset with only a single bin/data point on. For instance in my dataset there was only a single bin on chrY and when I removed that bin, segmentation (smoothing included) was successful.

So while turning off the smoothing indeed solves the problem of the smoothing error being raised, I think it actually hides the issue that cnvkit can send single-bin data sets for segmentation to DNAcopy. I think it would be a cleaner solution for the cnvkit to developers to implement a check for single bin chromosome arms in the cnvkit segmentation code, as it makes no sense to segment these data.

28rietd avatar Apr 20 '23 09:04 28rietd

hi , @chim9 i use the cnvkit v0.9.9 to meet the same issue when i use the option "--smooth-cbs" ,the error as follow : $ Rscript --no-restore --no-environ /tmp/tmpywit6pf3

b'Loading probe coverages into a data frame\nSegmenting the probe data\nPerforming smoothing of the data\nError in smooth.CNA(cna) : NA/NaN/Inf in foreign function call (arg 7)\nExecution halted\n

it's seem like the "--smooth-cbs" make the issue.

litun-fkby avatar Oct 13 '23 10:10 litun-fkby