ratschlab / spladder

Tool for the detection and quantification of alternative splicing events from RNA-Seq data.
Other
103 stars 33 forks source link

UnboundLocalError: local variable 'gene_samples' referenced before assignment #155

Open OnkarMulay opened 2 years ago

OnkarMulay commented 2 years ago

Description

This error seems to come from spladder -test mode File "/scratch/zq45/om4416/miniconda3/envs/Spladder_Splicing_Review/lib/python3.6/site-packages/spladder/spladder_test.py", line 554, in spladder_test gene_samples = np.array([x.split(':')[1] if ':' in x else x for x in gene_samples]) UnboundLocalError: local variable 'gene_samples' referenced before assignment

What I Did

My code: spladder build --bams Spladder/Code/alignments_list.txt --annotation Spladder/Code/rnasequin_annotation_2.4.gtf --outdir Spladder/Outputs --ignore-mismatches --merge-strat merge_graphs

spladder test --conditionA Spladder/Code/MixA.txt --conditionB Spladder/Code/MixB.txt --outdir Spladder/Outputs

WPresley commented 2 years ago

I'm having the same issue. Tried reverting to version 3.0.0 for test mode and still got this error message.

akahles commented 2 years ago

Dear @OnkarMulay , dear @WPresley ,

Thank you very much for reporting. This is indeed a bug, caused by a wrong indentation in the code. A quick fix is to run SplAdder in verbose mode (add -v to your call). I will add a fix with the next release.

Let me know whether the -v solves your issue for now.

Best,

Andre

WPresley commented 2 years ago

Thank you for getting back to me! That did solve the initial error, but now I'm getting a new error: Traceback (most recent call last): File "/home/wpresley/.local/bin/spladder", line 8, in sys.exit(main()) File "/home/wpresley/.local/lib/python3.9/site-packages/spladder/spladder.py", line 229, in main options.func(options) File "/home/wpresley/.local/lib/python3.9/site-packages/spladder/spladder_test.py", line 765, in spladder_test eventpos = np.array([.get_exon_coordinatestrings() for in events]) File "/home/wpresley/.local/lib/python3.9/site-packages/spladder/spladder_test.py", line 765, in eventpos = np.array([.get_exon_coordinatestrings() for in events]) File "/home/wpresley/.local/lib/python3.9/site-packages/spladder/classes/event.py", line 47, in get_exon_coordinate_strings iso2 = np.array(['%i-%i' % ([0], [1]) for in self.exons2]) File "/home/wpresley/.local/lib/python3.9/site-packages/spladder/classes/event.py", line 47, in iso2 = np.array(['%i-%i' % ([0], [1]) for in self.exons2]) IndexError: invalid index to scalar variable.

akahles commented 2 years ago

Hi @WPresley ,

Are you still on 3.0.0? What you report looks like the error reported in #152, which should have been fixed with 3.0.2.

Cheers,

Andre

WPresley commented 2 years ago

Hi Andre, No, I did update back to 3.0.2 before the run.

akahles commented 2 years ago

Ok, thanks. Can you please send me your full command line? Also, if possible for you, I would appreciate any data you can share to reproduce the issue. This will make it easier for me to fix.

Thanks and cheers,

Andre

OnkarMulay commented 2 years ago

Thanks @akahles, adding -v solves that particular error, but gives another error: File "h5py/_selector.pyx", line 272, in h5py._selector.Selector.make_selection File "h5py/_selector.pyx", line 201, in h5py._selector.Selector.apply_args TypeError: Indexing elements must be in increasing order

akahles commented 2 years ago

Dear @OnkarMulay ,

can you please send along the full backtrace of the error together with the command you were calling? Otherwise it is not possible for me to see the context.

Thanks and Cheers

Andre

OnkarMulay commented 2 years ago

Code:

!/bin/tcsh

PBS -l walltime=12:00:00

PBS -q normal

PBS -l jobfs=1gb

PBS -l mem=64gb

PBS -l ncpus=32

PBS -P zq45

conda activate /scratch/miniconda3/envs/Spladder

spladder test --conditionA /scratch/Spladder/Code/MixA.txt --conditionB /scratch/Spladder/Code/MixB.txt -v --outdir /scratch/Spladder/Outputs

Complete error: It says first: The index file is older than the data file: /scratch/Spladder/bams/B1/merge_graph.bam.bai

Then: Traceback (most recent call last): File "/scratch/miniconda3/envs/Spladder/bin/spladder", line 8, in sys.exit(main()) File "/scratch/miniconda3/envs/Spladder/lib/python3.6/site-packages/spladder/spladder.py", line 229, in main options.func(options) File "/scratch/zq45/om4416/miniconda3/envs/Spladder/lib/python3.6/site-packages/spladder/spladder_test.py", line 597, in spladder_test (cov, psi, gene_idx, event_idx, event_ids, event_samples) = quantify.quantify_from_counted_events(options.fname_event_counts, idx1, idx2, event_type, options, gen_event_ids=False, high_mem=options.high_memory) File "/scratch/zq45/om4416/miniconda3/envs/Spladder/lib/python3.6/site-packages/spladder/alt_splice/quantify.py", line 365, in quantify_from_counted_events cnt2.append(IN['event_counts'][sample_idx2, f[0], :][:, conf_idx].T) File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper File "/scratch/miniconda3/envs/Spladder/lib/python3.6/site-packages/h5py/_hl/dataset.py", line 777, in getitem selection = sel.select(self.shape, args, dataset=self) File "/scratch/miniconda3/envs/Spladder/lib/python3.6/site-packages/h5py/_hl/selections.py", line 82, in select return selector.make_selection(args) File "h5py/_selector.pyx", line 272, in h5py._selector.Selector.make_selection File "h5py/_selector.pyx", line 201, in h5py._selector.Selector.apply_args TypeError: Indexing elements must be in increasing order

WPresley commented 2 years ago

Hi Andre, I'm using the command: spladder test --conditionA /nfs/turbo/umms-lprasov/4942-WP/RNAseq_analysis_4942-WP/alignment/aligned_bams/Sample_4942-WP-1.genome.bam,/nfs/turbo/umms-lprasov/4942-WP/RNAseq_analysis_4942-WP/alignment/aligned_bams/Sample_4942-WP-4.genome.bam --conditionB /nfs/turbo/umms-lprasov/4942-WP/RNAseq_analysis_4942-WP/alignment/aligned_bams/Sample_4942-WP-3.genome.bam,/nfs/turbo/umms-lprasov/4942-WP/RNAseq_analysis_4942-WP/alignment/aligned_bams/Sample_4942-WP-5.genome.bam,/nfs/turbo/umms-lprasov/4942-WP/RNAseq_analysis_4942-WP/alignment/aligned_bams/Sample_4942-WP-6.genome.bam --outdir spladder_out -v It is perhaps also worth mentioning that the augmented graph I'm using was generated in 3.0.1. Thanks again!

OnkarMulay commented 2 years ago

Hi @akahles,

Any updates on how to solve the error of: File "/scratch/miniconda3/envs/Spladder/lib/python3.6/site-packages/h5py/_hl/selections.py", line 82, in select return selector.make_selection(args) File "h5py/_selector.pyx", line 272, in h5py._selector.Selector.make_selection File "h5py/_selector.pyx", line 201, in h5py._selector.Selector.apply_args TypeError: Indexing elements must be in increasing order

rvilloutreix commented 2 years ago

spladder version: ~30 days ago python: 3.9.7 gcc: 10.2.0

I ran:

load perl etc.

source ~/.bashrc

load gcc 10 and python 3

module load python/3.9.7; module load gcc/10.2.0;

running splADDER test

spladder test --labelA melanistic --labelB green --out-tag int-included --parallel 20 --confidence 2 \ --conditionA bams/19_0340.bam,bams/19_0344.bam,bams/19_0345.bam,bams/19_0347.bam,bams/19_0348.bam,bams/19_0351.bam,bams/19_0354.bam,bams/19_0355.bam,bams/19_0357.bam,bams/19_0363.bam,bams/19_0370.bam \ --conditionB bams/19_0343.bam,bams/19_0346.bam,bams/19_0347.bam,bams/19_0349.bam,bams/19_0350.bam,bams/19_0352.bam,bams/19_0353.bam,bams/19_0356.bam,bams/19_0358.bam,bams/19_0359.bam,bams/19_0360.bam,bams/19_0361.bam,bams/19_0362.bam,bams/19_0364.bam,bams/19_0365.bam,bams/19_0366.bam,bams/19_0367.bam,bams/19_0368.bam,bams/19_0369.bam \ --outdir output-relaxed;

and got the following error:

Traceback (most recent call last): File "/uufs/chpc.utah.edu/common/home/u6032583/.local/bin/spladder", line 8, in sys.exit(main()) File "/uufs/chpc.utah.edu/common/home/u6032583/.local/lib/python3.7/site-packages/spladder/spladder.py", line 229, in main options.func(options) File "/uufs/chpc.utah.edu/common/home/u6032583/.local/lib/python3.7/site-packages/spladder/spladder_test.py", line 554, in spladder_test gene_samples = np.array([x.split(':')[1] if ':' in x else x for x in gene_samples]) UnboundLocalError: local variable 'gene_samples' referenced before assignment

the -v made it work.

Best,

Romain

dzijlmans commented 2 years ago

Hi, I am having a similar issue. I got the same UnboundLocalError: local variable 'gene_samples' referenced before assignment error as @OnkarMulay when running spladder test. Tried to fix it by adding -v. My code then starts to run but quickly runs into a different error again.

spladder test --conditionA sisfrs2.txt --conditionB ctrl.txt --outdir spladder_output --labelA sisfrs2 --labelB ctrl --diagnose-plots --plot-format pdf --merge-strat merge_graphs --parallel 48 -v
Loading expression counts from spladder_output/spladder/genes_graph_conf3.merge_graphs.gene_exp.hdf5
Estimating size factors ...

... done.

Capped 9203/443312 outlier expression counts (2.08 percent)
Testing exon_skip events
Collecting intron confirmation values
Traceback (most recent call last):
  File "/vol/mbconda/dzijlmans/envs/spladder_env/bin/spladder", line 8, in <module>
    sys.exit(main())
  File "/vol/mbconda/dzijlmans/envs/spladder_env/lib/python3.6/site-packages/spladder/spladder.py", line 229, in main
    options.func(options)
  File "/vol/mbconda/dzijlmans/envs/spladder_env/lib/python3.6/site-packages/spladder/spladder_test.py", line 602, in spladder_test
    events = pickle.load(open(options.fname_events, 'rb'))[event_idx]
ValueError: unsupported pickle protocol: 5
zyh4482 commented 2 years ago

By adding -v parameter, the test module is working in my case.

akahles commented 2 years ago

Dear @OnkarMulay,

Can you please open a new issue with the error description? It seems unrelated to the one described initially here. I am still in the process of reproducing - so far I was not able to, but will try some more ideas.

Best,

Andre

akahles commented 2 years ago

Dear @WPresley ,

can you make a complete re-run using the latest release? Otherwise, the joint graph should be fine, but the event files extracted with prior versions will still generate the bug.

If the problem should persist, can you please open a new issue on the tracker? In the current thread different issues are discussed, which makes it hard for me to keep track.

Best,

Andre

Azura2652 commented 2 years ago

Adding the -v parameter is work for me while using the command as:

spladder test \ --conditionA 2H-1.bam,2H-2.bam \ --conditionB 2H-3.bam,2H-4.bam \ --outdir $outdir \ -v

However, when i change the input file to the comma-separated file lists which contain the absolute paths of the file , it went wrong again and here is the coomand and report:

spladder test \ --conditionA h1.txt \ --conditionB h2.txt \ --outdir $outdir \ -v

Traceback (most recent call last): File "/data/bio-tools/anaconda3/envs/spladder/bin/spladder", line 8, in sys.exit(main()) File "/data/bio-tools/anaconda3/envs/spladder/lib/python3.6/site-packages/spladder/spladder.py", line 229, in main options.func(options) File "/data/bio-tools/anaconda3/envs/spladder/lib/python3.6/site-packages/spladder/spladder_test.py", line 514, in spladder_test options = settings.parse_args(options, identity='test') File "/data/bio-tools/anaconda3/envs/spladder/lib/python3.6/site-packages/spladder/settings.py", line 156, in parse_args options.conditionA = [str(x) for x in np.loadtxt(options.conditionA[0], dtype='str')] TypeError: iteration over a 0-d array

Looking forward to your replys, thanks !