spladder icon indicating copy to clipboard operation
spladder copied to clipboard

UnboundLocalError: local variable 'gene_samples' referenced before assignment

Open OnkarMulay opened this issue 3 years ago • 17 comments

  • spladder version: Latest
  • Python version: version compatible with latest spladder
  • Operating System: Ubuntu
  • new environment was made and spladder installed via conda

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

OnkarMulay avatar Feb 10 '22 03:02 OnkarMulay

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

WPresley avatar Feb 11 '22 20:02 WPresley

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

akahles avatar Feb 11 '22 20:02 akahles

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 event_pos = np.array([.get_exon_coordinate_strings() for _ in events]) File "/home/wpresley/.local/lib/python3.9/site-packages/spladder/spladder_test.py", line 765, in event_pos = np.array([.get_exon_coordinate_strings() 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.

WPresley avatar Feb 11 '22 22:02 WPresley

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

akahles avatar Feb 12 '22 12:02 akahles

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

WPresley avatar Feb 13 '22 00:02 WPresley

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

akahles avatar Feb 13 '22 09:02 akahles

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

OnkarMulay avatar Feb 14 '22 09:02 OnkarMulay

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

akahles avatar Feb 14 '22 09:02 akahles

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

OnkarMulay avatar Feb 14 '22 10:02 OnkarMulay

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!

WPresley avatar Feb 14 '22 22:02 WPresley

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

OnkarMulay avatar Feb 20 '22 01:02 OnkarMulay

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

rvilloutreix avatar Feb 23 '22 16:02 rvilloutreix

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

dzijlmans avatar Feb 28 '22 11:02 dzijlmans

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

zyh4482 avatar Mar 02 '22 06:03 zyh4482

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 avatar Mar 02 '22 12:03 akahles

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

akahles avatar Mar 02 '22 12:03 akahles

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 !

Azura2652 avatar May 06 '22 09:05 Azura2652