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

TypeError: bad operand type for abs(): 'str' #79

Open
KhanhLPBao opened this issue Apr 29, 2021 · 2 comments
Open

TypeError: bad operand type for abs(): 'str' #79

KhanhLPBao opened this issue Apr 29, 2021 · 2 comments

Comments

@KhanhLPBao
Copy link

KhanhLPBao commented Apr 29, 2021

sample.zip
I'm running NIPT samples then suddenly I found this error occurred in some samples

[INFO - 2021-04-29 10:19:51]: Starting CNA prediction
[INFO - 2021-04-29 10:19:51]: Importing data ...
[INFO - 2021-04-29 10:19:51]: Normalizing autosomes ...
[INFO - 2021-04-29 10:19:59]: Normalizing gonosomes ...
[INFO - 2021-04-29 10:20:02]: Applying blacklist ...
[INFO - 2021-04-29 10:20:02]: Executing circular binary segmentation ...
[INFO - 2021-04-29 10:20:07]: Writing tables ...
Traceback (most recent call last):
File "/home/tgd/.local/bin/WisecondorX", line 8, in
sys.exit(main())
File "/home/tgd/.local/lib/python3.8/site-packages/wisecondorX/main.py", line 404, in main
args.func(args)
File "/home/tgd/.local/lib/python3.8/site-packages/wisecondorX/main.py", line 244, in tool_test
generate_output_tables(rem_input, results)
File "/home/tgd/.local/lib/python3.8/site-packages/wisecondorX/predict_output.py", line 43, in generate_output_tables
_generate_chr_statistics_file(rem_input, results)
File "/home/tgd/.local/lib/python3.8/site-packages/wisecondorX/predict_output.py", line 130, in _generate_chr_statistics_file
cpa = round(get_cpa(results['results_c'], rem_input['binsize']), 5)
File "/home/tgd/.local/lib/python3.8/site-packages/wisecondorX/overall_tools.py", line 133, in get_cpa
x += (segment[2] - segment[1] + 1) * binsize * abs(segment[3])
TypeError: bad operand type for abs(): 'str'

Its appeared in some files, not all samples. I don't know what's wrong with those file. I have attached 1 .npz file that be bugged out.

@leraman
Copy link
Collaborator

leraman commented Apr 29, 2021

Hard to say what's going on, I'm not getting the error when using your file with one of our references.

  • How much samples are in your reference?
  • What is your reference bin size?
    If possible, could you provide a reference for me to reproduce the error?

Best, Lennart

@KhanhLPBao
Copy link
Author

KhanhLPBao commented May 21, 2021

Hi @leraman
My sample size is more than 1000 samples, when making reference I use default args. Sorry for not reply you for a long time due to some emergency works but I cannot give you the reference file. Also I found that the error comes from the calculation of CPA. I have modified the script of get_cpa function to:

def get_cpa(results_c, binsize):
    x = 0
    for segment in results_c:
        try:
            x += (segment[2] - segment[1] + 1) * binsize * abs(segment[3])
            CPA = x / len(results_c) * (10 ** -8)
        except:
             pass
    return(CPA)

And after that I'm not encountered the error again. Does I do right? Because what I need mostly is zscore

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

2 participants