VIB-PSB / ksrates

ksrates is a tool to position whole-genome duplications relative to speciation events using substitution-rate-adjusted mixed paralog-ortholog Ks distributions.
https://ksrates.readthedocs.io
GNU General Public License v3.0
15 stars 9 forks source link

TypeError: cannot convert the series to <class 'float'> #42

Closed Biscuite-wzy closed 2 years ago

Biscuite-wzy commented 2 years ago

Hi, I met an error when I run the step " ksrates orthologs-adjustment". I do not know how to resolve it, can you help me? I would appreciate it. Here I have replaced the species name with A, B,C,D,....in INFO.

INFO    - - - - - - - - - - - - - - - - - - - - - -
INFO    Rate-adjustment of ortholog Ks distributions
INFO    Wed Jun 22 23:03:01 2022
INFO    - - - - - - - - - - - - - - - - - - - - - -
INFO    Loading parameters and input files
INFO
INFO    Performing rate-adjustment of each divergent pair by using one or more outgroups:
INFO     - Adjusting the peak for [A] and [B] with outspecies [C]
INFO     - Adjusting the peak for [A] and [B] with outspecies [D]
INFO     - Adjusting the peak for [A] and [B] with outspecies [E]
INFO     - Adjusting the peak for [A] and [B] with outspecies [F]
INFO     - Adjusting the peak for [A] and [B] with outspecies [G]
INFO     - Adjusting the peak for [A] and [B] with outspecies [H]
INFO     - Adjusting the peak for [A] and [B] with outspecies [I]
Traceback (most recent call last):
  File "/home/zhaoxy/python3.8/ksrates/bin/ksrates", line 33, in <module>
    sys.exit(load_entry_point('ksrates', 'console_scripts', 'ksrates')())
  File "/home/zhaoxy/python3.8/ksrates/bin/ksrates/lib/python3.8/site-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/home/zhaoxy/python3.8/ksrates/lib/python3.8/site-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/home/zhaoxy/python3.8/ksrates/lib/python3.8/site-packages/click/core.py", line 1668, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/zhaoxy/python3.8/ksrates/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/zhaoxy/python3.8/ksrates/lib/python3.8/site-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/home/zhaoxy/biosoft/ksrates/ksrates_cli.py", line 136, in orthologs_adjustment
    correct(config_file, expert, trios)
  File "/home/zhaoxy/biosoft/ksrates/ksrates/correct.py", line 71, in correct
    rate_species, rate_species_sd, rate_sister, rate_sister_sd = fcCorrect.decompose_ortholog_ks(db, species_sister, species_out, sister_out, peak_stats)
  File "/home/zhaoxy/biosoft/ksrates/ksrates/fc_rrt_correction.py", line 45, in decompose_ortholog_ks
    rel_rate_species_sd = sqrt(pow(sd_sp_out, 2) + pow(sd_sp_sis, 2) + pow(sd_sis_out, 2)) / 2.0 # also called k_AO_sd
  File "/home/zhaoxy/python3.8/ksrates/lib/python3.8/site-packages/pandas/core/series.py", line 185, in wrapper
    raise TypeError(f"cannot convert the series to {converter}")
TypeError: cannot convert the series to <class 'float'>
Cecilia-Sensalari commented 2 years ago

Hi Biscuite-wzy,

Thanks for reporting this. The line that gives the error is trying to perform a calculation, but apparently it doesn't have the right data type for it (here is the function, line 45). It might be due to the fact that the file where the function is taking these numbers from is not structured like it should be. It is the ortholog peak database (where the estimated modes of the ortholog distributions are stored), so could you have a look in there if the columns are correctly structured? E.g. One is missing, one is duplicated or the values in them don't look correct (especially under Mode_SD). Here below I took the example from the docs to show how the database is supposed to look like: image

Best, Cecilia

Biscuite-wzy commented 2 years ago

Hi,

I have had a look in there the columns are correctly structured, as follows. Here I have replaced the full name of the species with an x. But several values in Mode_SD are zero, does that cause this error ?

Best wishes

787117923 @.***

 

------------------ 原始邮件 ------------------ 发件人: "VIB-PSB/ksrates" @.>; 发送时间: 2022年6月23日(星期四) 晚上6:35 @.>; @.**@.>; 主题: Re: [VIB-PSB/ksrates] TypeError: cannot convert the series to <class 'float'> (Issue #42)

Hi Biscuite-wzy,

Thanks for reporting this. The line that gives the error is trying to perform a calculation, but apparently it doesn't have the right data type for it (here is the function, line 45). It might be due to the fact that the file where the function is taking these numbers from is not structured like it should be. It is the ortholog peak database (where the estimated modes of the ortholog distributions are stored), so could you have a look in there if the columns are correctly structured? E.g. One is missing, one is duplicated or the values in them don't look correct (especially under Mode_SD). Here below I took the example from the docs to show how the database is supposed to look like:

Best, Cecilia

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

Cecilia-Sensalari commented 2 years ago

Hi @Biscuite-wzy,

I'm afraid your post doesn't have the image attached! Could you reload it? Thanks.

Cecilia

Biscuite-wzy commented 2 years ago

Oh, sorry! It may not be able to attach the image, now I attach the text, as follows,

    Species1        Species2        Mode    Mode_SD

Cxxx ricxxxx_Sxxxx axxxx Cxxx ricxxxx Sxxxx axxxx 0.024708414872798404 0.004435378327805361 Dxxx rexxx_Fxxx qxxxx Dxxx rexxx Fxxx qxxxx 0.08082974559686885 0.004282444310959067 Txxx cvxxx_Sxxx sxxxx Txxx cvxxx Sxxx sxxxx 0.08317025440313108 0.0 Dxxx rexxx_Pxxx gxxxx Dxxx rexxx Pxxx gxxxx 0.08317025440313108 0.0

Cecilia-Sensalari commented 2 years ago

By looking at the layout of the text above it seems that only the headers (Species1 etc...) are separated by a tab, while the other fields below (Cxxx ricxxxx_Sxxxx etc...) are separated by a space. However the code expects a tab! This way the function can't understand which numbers to parse for the calculation and it takes the whole line as a Series.

Would you check if the lines have a space as separator and, in case, would you replace each of them with a tab and try to run it again?

Cecilia-Sensalari commented 2 years ago

Hi @Biscuite-wzy,

Have you had the chance to check the spacing in the table? I don't think that 0.0 values would be a problem.

Cheers, Cecilia

Cecilia-Sensalari commented 2 years ago

Hi, I'll close this issue due to inactivity. Should you encounter similar problems, we'll reopen it!

Cecilia

Biscuite-wzy commented 1 year ago

Hi, Thanks for your reply! I have found out the cause of this error, which was caused by an incorrect species name in the configure file.

787117923 @.***

 

------------------ 原始邮件 ------------------ 发件人: "VIB-PSB/ksrates" @.>; 发送时间: 2022年7月12日(星期二) 晚上9:33 @.>; @.**@.>; 主题: Re: [VIB-PSB/ksrates] TypeError: cannot convert the series to <class 'float'> (Issue #42)

Hi @Biscuite-wzy,

Have you had the chance to check the spacing in the table? I don't think that 0.0 values would be a problem.

Cheers, Cecilia

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

Cecilia-Sensalari commented 1 year ago

I see, thanks for letting us know :) Best, Cecilia

Cecilia-Sensalari commented 1 year ago

Hmm, this might actually be something to be caught in an error message, instead of letting it crash that way! Would you let me know which kind of incorrect name you were using?