WGLab / PhenoSV

PhenoSV: Interpretable phenotype-aware model for the prioritization of genes affected by structural variants.
MIT License
16 stars 3 forks source link

Error in calculating scores in phen2gene program #11

Closed sonder-mei closed 4 months ago

sonder-mei commented 4 months ago

''' File "phenosv/model/phenosv.py", line 177, in main() File "phenosv/model/phenosv.py", line 168, in main feature_subset=feature_subset) File "phenosv/model/../model/operation_function.py", line 568, in phenosv full_mode=full_mode, truncation=None, feature_subset=feature_subset) File "phenosv/model/../model/operation_function.py", line 594, in single_sv genescores = pg.phen2gene(HPO,KBpath, scale_score=True) File "phenosv/model/../utilities/../Phen2Gene/phen2gene.py", line 34, in phen2gene score = stats.percentileofscore(score,score)/100 File "/mnt/B2C_USER/luoxiaomei/Software/miniconda3/lib/python3.7/site-packages/scipy/stats/stats.py", line 1942, in percentileofscore if np.isnan(score): ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() '''

I don't know what 's wrong in calculating the score,it's working when i use python3 phenosv/model/phenosv.py --c chr6 --s 156994830 --e 157006982 --svtype 'deletion' but python3 phenosv/model/phenosv.py --c chr6 --s 156994830 --e 157006982 --svtype 'deletion' --noncoding 'tad' --HPO 'HP:0000707,HP:0007598'.I have tried Use a.any() or a.all() ,but it would caused

“ File "phenosv/model/../utilities/../Phen2Gene/phen2gene.py", line 35, in phen2gene df['Score'] = score.tolist() AttributeError: 'float' object has no attribute 'tolist'”

Please help me and Looking forward to your answer!

Karenxzr commented 4 months ago

Hi, can you double confirm the database for phen2gene is correctly saved and unzipped? Below is a similar issue: https://github.com/WGLab/PhenoSV/issues/10

Please let me know how it works

sonder-mei commented 4 months ago

Thank you for your reply. I think I have extracted the file correctly, but the size of the file has changed a lot.

du -sh *
154G    data
2.0G    Knowledgebase
56M skewness
56M weights

image

Karenxzr commented 4 months ago

The file sizes for skewness and weights seems to be smaller than what they supposed to be. You can first try to download and unzip from https://github.com/WGLab/Phen2Gene/releases/download/1.1.0/H2GKBs.zip again.

Another possibility is the package version conflicts for the function of "stats.percentileofscore". Did you set up the environment using the .yml I provided? Also you can manually run codes below to see what is "score". It should be a list of scores with values being the unscaled phen2gene scores. stats.percentileofscore is used to change the scores into percentiles.

import Phen2Gene.phen2gene as pg
KBpath = "set your KBpath"
HPOlist = ["HP:0000707", "HP:0007598"]
gene_dict, _, weight_model = pg.results(KBpath, files=None, manuals=HPOlist, user_defineds=None,
                                              weight_model='sk', weight_only=False, output_path=None,
                                              output_file_name=None, gene_weight=None,
                                              cutoff=None, genelist=None, verbosity=True)
df = pd.DataFrame(gene_dict).transpose()
df.columns = ['Gene','Score','status','status_','id']
df = df[['Gene', 'Score']]
df.Score = df.Score / np.max(df.Score)
score = df.Score.tolist()
sonder-mei commented 4 months ago

Thank you, it's working now. It was indeed a version issue because I had previously set python3 to Python 3.7; using the new command python phenosv/model/phenosv.py --c chr6 --s 156994830 --e 157006982 --svtype 'deletion' --noncoding 'tad' --HPO 'HP:0000707,HP:0007598' is all that's needed.