RitchieLabIGH / IRFinder

MIT License
13 stars 10 forks source link

IRFinder Diff ERROR: __main__:Unknown error: (<class 'TypeError'>, TypeError("calculate_delta_psi() missing 1 required positional argument: 'nan_th'",) #4

Closed Floyd1229 closed 2 years ago

Floyd1229 commented 2 years ago

Hello,

So I'm running the IRFinder Diff function to analyze differential IR. I want to use the SUPPA2 classical method, but I'm getting an error message saying that I need to specify the -nan and -th arguments from suppa.py's diffSplice function. When doing so, I'm still getting the same error message.

I checked the output psi.tsv and tpm.tsv files for both conditions, and there aren't any rows with NaN or missing/blank values, so I'm not even sure why this error is generated. Also checked several GitHub issues related to this error (here, here).

Am I using the wrong syntax? Any help would be appreciated. Thank you!

[my_username]$ module load singularity-3.8.3-gcc-8.2.0-7y47d4c
[my_username]$ export SINGULARITY_BINDPATH=/PATH_TO_DIR/

[my_username]$ IRQUANTdir=/PATH_TO_IR_QUANTIFICATION
[my_username]$ DiffIRdir=/PATH_TO_DIFF_IR

[my_username]$ singularity run ./IRFinder/IRFinder Diff -m classical -nan 0 -th 0 -g:WT ${IRQUANTdir}/REF/FASTQ_mode/P7_WT_male/*/IRFinder-IR-dir.txt -g:HZ ${IRQUANTdir}/REF/FASTQ_mode/P7_HZ_male/*/IRFinder-IR-dir.txt -o ${DiffIRdir}/REF/suppa2/classical

Calculating differential analysis between conditions: HZ and WT 
ERROR:__main__:Unknown error: (<class 'TypeError'>, TypeError("calculate_delta_psi() missing 1 required positional argument: 'nan_th'",), <traceback object at 0x7ff4df27a708>)

Additional Info: OS distro and version: 3.10.0-957.1.3.el7.x86_64 Singularity: 3.8.3 IRFinder: 2.0.0 Bedtools: 2.27.1 GCC: 4.8.5 20150623 (Red Hat 4.8.5-36) GLIBC: 2.17 Perl: perl 5, version 26, subversion 2 (v5.26.2) built for x86_64-linux-thread-multi Samtools: samtools 1.9, Using htslib 1.9

CloXD commented 2 years ago

Hello Taylor, I'm trying to fix the error: it occurs only using the image. As soon as I'll fix the problem I'll let you know. Thanks for the report Claudio

CloXD commented 2 years ago

Bug found: it was due to version 2.3 of SUPPA2 ( the one frozen by the tag ). Replacing it with the master, the error disappears. Thanks again for the report, the singularity image is updated as the docker hub. Cheers, Claudio

Floyd1229 commented 2 years ago

Hi Claudio,

Thank you for fixing: the function now works. I do have another follow up question: so I tried to perform differential IR analysis for events where dPSI between conditions > |0.1| (i.e. argument -l 0.1), and I got the same results as when the dPSI > |0.05|.

I tried shuffling the -l argument in various positions for the IRFinder Diff function, but it didn't work.

CloXD commented 2 years ago

Hello Floyd, I tried with the default -l 0 and an extreme case ( -l 0.8 ) and what Suppa2 does is to simply set the p_values of the events with |dPSI| > threshold to 1. Check if it's the case also for your results. Cheers, Claudio

Floyd1229 commented 2 years ago

Hi Claudio,

It's not working for me for some reason. The p_values of the events with |dPSI| > 0.8 threshold don't change to 1. Here are the commands I ran:

[my_username]$ singularity run IRFinder Diff -m classical -g:WT ${IRQUANTdir}/REF2/BAM_mode/P7_WT_male/*/IRFinder-IR-dir.txt -g:HZ ${IRQUANTdir}/REF2/BAM_mode/P7_HZ_male/*/IRFinder-IR-dir.txt -o ${DiffIRdir}/REF2/suppa2/BAM_mode/classical/IRratio_min_0
[my_username]$ head -n 10 ${DiffIRdir}/REF2/suppa2/BAM_mode/classical/IRratio_min_0/suppa.dpsi_adjusted.tsv
HZ.WT_dPSI  HZ.WT_p.val HZ.WT_p.val_BH_adjusted
0.0137330667    0.0952151319    0.489715134335913
0.0232145667    0.0404277992    0.489715134335913
0.0071202   0.0952151319    0.489715134335913
0.0098771333    0.3312602918    0.489715134335913
-0.0430918333   0.0952151319    0.489715134335913
-0.0072444333   0.3312602918    0.489715134335913
0.0309111   0.4123890475    0.501637664044919
0.0093089667    0.1913665444    0.489715134335913
0.0909249333    0.0952151319    0.489715134335913

[my_username]$ singularity run IRFinder Diff -m classical -g:WT ${IRQUANTdir}/REF2/BAM_mode/P7_WT_male/*/IRFinder-IR-dir.txt -g:HZ ${IRQUANTdir}/REF2/BAM_mode/P7_HZ_male/*/IRFinder-IR-dir.txt -l 0.8 -o ${DiffIRdir}/REF2/suppa2/BAM_mode/classical/IRratio_min_0.8
[my_username]$ head -n 10 ${DiffIRdir}/REF2/suppa2/BAM_mode/classical/IRratio_min_0.8/suppa.dpsi_adjusted.tsv
HZ.WT_dPSI  HZ.WT_p.val HZ.WT_p.val_BH_adjusted
0.0137330667    0.0952151319    0.489715134335913
0.0232145667    0.0404277992    0.489715134335913
0.0071202   0.0952151319    0.489715134335913
0.0098771333    0.3312602918    0.489715134335913
-0.0430918333   0.0952151319    0.489715134335913
-0.0072444333   0.3312602918    0.489715134335913
0.0309111   0.4123890475    0.501637664044919
0.0093089667    0.1913665444    0.489715134335913
0.0909249333    0.0952151319    0.489715134335913
CloXD commented 2 years ago

Hi Taylor, I found the problem and it's related to SUPPA: I was using the "suppa" method and the dPSI threshold works correctly, trying with the "classical", it doesn't. I checked also the empirical and it works. A quick fix can be to filter it with R or more simply with awk:

threshold=0.1
awk -v thr="${threshold}" ' 
BEGIN {FS=OFS="\t" } 
NR == 1 { print } 
NR > 1 { 
    if ( $2 > -thr && $2 < thr ) { $3=1 ; $4=1 } ; 
    print 
} 
' suppa.dpsi_adjusted.tsv > suppa.dpsi_adjusted_thr_${threshold}.tsv

Cheers, Claudio

Floyd1229 commented 2 years ago

Hi Claudio,

So there are 4 different methods to run differential IR analysis: deseq, suppa, classical, and empirical? I thought suppa had 2 modes: either classical or empirical.

With the awk code you provided, would I run that code and then recalculate adjusted pvalues?

As for setting the dPSI threshold within the IRFinder Diff command line, I can only do it for suppa and empirical methods, correct?

CloXD commented 2 years ago

Hi Floyd, sorry, my bad: empirical and suppa are actually the same ( since empirical is the default method in suppa, I added it as shortcut). The code that I gave you just convert the p-values of those having |dPSI| below the threshold to 1, so re-adjusting the adjusted p-values won't change ( the total number of events tested are the same ). You might exclude them in R and re-adjust them, but I don't know how statistically correct would it be. I opened an issue on SUPPA to see if it's an error or they forgot to mention it in the help (https://github.com/comprna/SUPPA/issues/139). I guess they just didn't consider the classical method when they introduced the dPSI cutoff. Cheers, Claudio

Floyd1229 commented 2 years ago

Hi Claudio,

Ok this makes sense now. I tried examining the |dPSI| > 1 IR events separately and re-performed pvalue adjustment, and like you stated, the adjusted pvalues don't change regardless of omitting the IR events that don't meet the dPSI threshold.

Thank you for your help!

CloXD commented 2 years ago

Great, I'll close the issue then