tapestry icon indicating copy to clipboard operation
tapestry copied to clipboard

KeyError: 'depth'

Open CaroZ655 opened this issue 3 months ago • 7 comments

In installed Tapestry in a Conda environment on our HPC and am trying to run :

weave -a /path/M17.racon3.medaka.pilon.fasta -r /path/ancestor.17.nanopore.nanofilt.fastq.gz  -t TTAGGG \
-o /path/pilon_rounds/tapestry_output -c 10 -l 5000

But I keep getting the following error :

2025-11-06 15:06:14 WARNING	Output directory /path/tapestry_output found, will use existing analysis files if present and up-to-date, but overwrite reports
2025-11-06 15:06:14 INFO	Loading genome assembly
2025-11-06 15:06:14 INFO	Loaded 53 contigs from /path/M17.racon3.medaka.pilon.fasta
2025-11-06 15:06:14 INFO	Ploidy window size set to 100000 based on assembly N50 length 2359087
2025-11-06 15:06:14 INFO	Sampling 50 times coverage of 40.0 Mb assembly from >5000bp reads in /path/ancestor.17.nanopore.nanofilt.fastq.gz

  0%|          | 0/50 [00:00<?, ?it/s]
  2%|▏         | 1/50 [00:06<05:23,  6.60s/it]
  4%|▍         | 2/50 [00:19<06:47,  8.49s/it]
  6%|▌         | 3/50 [00:32<07:41,  9.82s/it]
  8%|▊         | 4/50 [00:45<08:16, 10.80s/it]
 10%|█         | 5/50 [00:58<08:36, 11.47s/it]
 12%|█▏        | 6/50 [01:11<08:46, 11.96s/it]
 14%|█▍        | 7/50 [01:24<08:46, 12.25s/it]
 16%|█▌        | 8/50 [01:37<08:43, 12.46s/it]
 18%|█▊        | 9/50 [01:50<08:37, 12.62s/it]
 20%|██        | 10/50 [02:03<08:29, 12.73s/it]
 22%|██▏       | 11/50 [02:16<08:18, 12.78s/it]
 24%|██▍       | 12/50 [02:29<08:06, 12.79s/it]
 26%|██▌       | 13/50 [02:42<07:54, 12.83s/it]
 28%|██▊       | 14/50 [02:55<07:42, 12.84s/it]
 30%|███       | 15/50 [03:07<07:29, 12.84s/it]
 32%|███▏      | 16/50 [03:20<07:15, 12.81s/it]
 34%|███▍      | 17/50 [03:30<06:34, 11.94s/it]
                                               
2025-11-06 15:09:48 INFO	Wrote 89969 reads (671822300 bases, 17 times coverage) to /path/tapestry_output/reads.fastq.gz
2025-11-06 15:09:48 WARNING	Only found 17 times coverage in reads longer than 5000, not 50 times; consider reducing minimum read length (-l)
2025-11-06 15:09:48 INFO	Aligning reads /path/tapestry_output/reads.fastq.gz to assembly
2025-11-06 15:11:38 INFO	Indexing /path/tapestry_output/reads_assembly.bam
2025-11-06 15:11:41 INFO	Aligning contigs /path/tapestry_output/assembly.fasta to assembly
2025-11-06 15:11:47 INFO	Indexing /path/tapestry_output/contigs_assembly.bam
2025-11-06 15:13:33 INFO	Building alignments database /path/tapestry_output/alignments.db
2025-11-06 15:16:12 INFO	Loading contig alignments into database
2025-11-06 15:16:14 INFO	Loading read alignments into database
2025-11-06 15:16:29 INFO	Finding neighbouring alignments

  0%|          | 0/7158 [00:00<?, ? alignments/s]
 14%|█▍        | 1000/7158 [00:09<00:59, 104.15 alignments/s]
 28%|██▊       | 2000/7158 [00:20<00:50, 101.18 alignments/s]
 42%|████▏     | 3000/7158 [00:29<00:40, 102.99 alignments/s]
 56%|█████▌    | 4000/7158 [00:37<00:29, 108.16 alignments/s]
 70%|██████▉   | 5000/7158 [01:02<00:30, 71.23 alignments/s] 
 84%|████████▍ | 6000/7158 [01:11<00:14, 80.54 alignments/s]
 98%|█████████▊| 7000/7158 [01:19<00:01, 89.47 alignments/s]
                                                            
2025-11-06 15:18:03 INFO	Processing 53 contigs
Tapestry version 1.0.1
Dependencies
minimap2       2.24-r1122     /home/caroz/mambaforge/envs/tapestry_env/bin/minimap2
samtools       1.15.1         /home/caroz/mambaforge/envs/tapestry_env/bin/samtools


Welcome to Tapestry!

Assembly to validate	/path/M17.racon3.medaka.pilon.fasta
Reads to sample from	/path/ancestor.17.nanopore.nanofilt.fastq.gz
Coverage to sample	50
Minimum read length	5000
Telomere sequence(s)	TTAGGG
Minimum contig alignment	2000
Output directory	/path/pilon_rounds/tapestry_output


Processing contigs:   0%|          | 0/53 [00:00<?, ? contig/s]multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/home/caroz/mambaforge/envs/tapestry_env/lib/python3.6/site-packages/pandas/core/indexes/base.py", line 2657, in get_loc
    return self._engine.get_loc(key)
  File "pandas/_libs/index.pyx", line 108, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/index.pyx", line 132, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/hashtable_class_helper.pxi", line 1601, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas/_libs/hashtable_class_helper.pxi", line 1608, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'depth'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/caroz/mambaforge/envs/tapestry_env/lib/python3.6/multiprocessing/pool.py", line 119, in worker
    result = (True, func(*args, **kwds))
  File "/home/caroz/mambaforge/envs/tapestry_env/lib/python3.6/site-packages/tapestry/contig.py", line 40, in process_contig
    contig.process()
  File "/home/caroz/mambaforge/envs/tapestry_env/lib/python3.6/site-packages/tapestry/contig.py", line 114, in process
    self.median_read_depth = self.median_depth(self.read_depths)
  File "/home/caroz/mambaforge/envs/tapestry_env/lib/python3.6/site-packages/tapestry/contig.py", line 152, in median_depth
    return depths['depth'].median() if depths is not None else 0
  File "/home/caroz/mambaforge/envs/tapestry_env/lib/python3.6/site-packages/pandas/core/frame.py", line 2927, in __getitem__
    indexer = self.columns.get_loc(key)
  File "/home/caroz/mambaforge/envs/tapestry_env/lib/python3.6/site-packages/pandas/core/indexes/base.py", line 2659, in get_loc
    return self._engine.get_loc(self._maybe_cast_indexer(key))
  File "pandas/_libs/index.pyx", line 108, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/index.pyx", line 132, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/hashtable_class_helper.pxi", line 1601, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas/_libs/hashtable_class_helper.pxi", line 1608, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'depth'
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/caroz/mambaforge/envs/tapestry_env/bin/weave", line 45, in <module>
    assembly = Assembly(args.assembly, args.reads, args.telomere, args.output, args.cores, args.depth, args.length, args.windowsize, args.forcereadoutput, args.mincontigalignment)
  File "/home/caroz/mambaforge/envs/tapestry_env/lib/python3.6/site-packages/tapestry/assembly.py", line 109, in __init__
    self.process_contigs()
  File "/home/caroz/mambaforge/envs/tapestry_env/lib/python3.6/site-packages/tapestry/assembly.py", line 316, in process_contigs
    for contig in tapestry_tqdm(p.imap(process_contig, self.contigs.values()), total=len(self.contigs), desc="Processing contigs"):
  File "/home/caroz/mambaforge/envs/tapestry_env/lib/python3.6/site-packages/tqdm-4.7.2-py3.6.egg/tqdm/_tqdm.py", line 594, in __iter__
  File "/home/caroz/mambaforge/envs/tapestry_env/lib/python3.6/multiprocessing/pool.py", line 735, in next
    raise value
KeyError: 'depth'

I changed the depth to -d 17, but it gave the same error.

CaroZ655 avatar Nov 06 '25 16:11 CaroZ655