Kuanhao-Chao / LiftOn

🚀 LiftOn: Accurate annotation mapping for GFF/GTF across assemblies
http://ccb.jhu.edu/lifton
GNU General Public License v3.0
59 stars 3 forks source link

KeyError: 'gene_biotype' #2

Closed wanru0 closed 4 months ago

wanru0 commented 5 months ago

Hello,

Thanks for the tools. I am trying to do the alignment between two Fragaria species, and I got this error from the output:

>> Reading target genome ...
>> Reading reference genome ...

>> Creating reference annotation database :  Fragaria_vesca_v4.0.a2.genes.gff3
2024-05-07 18:15:24,810 - INFO - Populating features
2024-05-07 18:16:11,172 - INFO - Populating features table and first-order relations: 1051757 features
2024-05-07 18:16:11,172 - INFO - Updating relations
2024-05-07 18:16:20,583 - INFO - Creating relations(parent) index
2024-05-07 18:16:21,354 - INFO - Creating relations(child) index
2024-05-07 18:16:22,240 - INFO - Creating features(featuretype) index
2024-05-07 18:16:22,763 - INFO - Creating features (seqid, start, end) index
2024-05-07 18:16:23,468 - INFO - Creating features (seqid, start, end, strand) index
2024-05-07 18:16:24,193 - INFO - Running ANALYZE features
Traceback (most recent call last):
  File "/home/wlin2345/miniconda3/bin/lifton", line 33, in <module>
    sys.exit(load_entry_point('lifton==1.0.1', 'console_scripts', 'lifton')())
  File "/home/wlin2345/miniconda3/lib/python3.10/site-packages/lifton/lifton.py", line 352, in main
    run_all_lifton_steps(args)
  File "/home/wlin2345/miniconda3/lib/python3.10/site-packages/lifton/lifton.py", line 212, in run_all_lifton_steps
    ref_features_dict, ref_features_len_dict, ref_features_reverse_dict, ref_trans_exon_num_dict = lifton_utils.get_ref_liffover_features(features, ref_db, intermediate_dir, args)
  File "/home/wlin2345/miniconda3/lib/python3.10/site-packages/lifton/lifton_utils.py", line 336, in get_ref_liffover_features
    if locus.attributes[gene_type_key][0] == "protein_coding" and len(CDS_children) > 0:
  File "/home/wlin2345/miniconda3/lib/python3.10/site-packages/gffutils/attributes.py", line 62, in __getitem__
    v = self._d[k]
KeyError: 'gene_biotype'

So I checked my gff3 file and compared it with the gff3 file provided in the test folder and found that it doesn't have the gene_biotype attribute. Now I'm not very sure if I can still use your tools to do my job. It would be really helpful to get your feedback on this!

Thanks, Wanru

Kuanhao-Chao commented 5 months ago

Hi @wanru0,

Thank you for trying LiftOn and bringing this issue to our attention. I have fixed this error. The gene_biotype is used solely for gene counting, so you can run LiftOn with gff files without the gene_biotype attribute key.

Please install the new version through: v1.0.2

The updated example script can be found here: https://github.com/Kuanhao-Chao/LiftOn/blob/main/test/lifton_chr22_example_no_biotype.sh

Feel free to contact me if you have any issues running LiftOn!

Best, Kuan-Hao

wanru0 commented 5 months ago

Thanks for the response, @Kuanhao-Chao ! I met a new problem when I ran the LiftOn after you fixed this bug.

I got this error from the output:

*********************
** Running Liftoff **
*********************
extracting features
2024-05-09 12:24:28,539 - INFO - Populating features
2024-05-09 12:24:35,819 - INFO - Populating features table and first-order relations: 85360 features
2024-05-09 12:24:35,819 - INFO - Updating relations
2024-05-09 12:24:36,587 - INFO - Creating relations(parent) index
2024-05-09 12:24:36,640 - INFO - Creating relations(child) index
2024-05-09 12:24:36,706 - INFO - Creating features(featuretype) index
2024-05-09 12:24:36,745 - INFO - Creating features (seqid, start, end) index
2024-05-09 12:24:36,797 - INFO - Creating features (seqid, start, end, strand) index
2024-05-09 12:24:36,855 - INFO - Running ANALYZE features
aligning features
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/Users/wanrulin/anaconda3/lib/python3.11/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
                    ^^^^^^^^^^^^^^^^^^^
  File "/Users/wanrulin/anaconda3/lib/python3.11/site-packages/lifton/liftoff/align_features.py", line 61, in align_single_chroms
    minimap2_index = build_minimap2_index(target_file, args, threads_arg, minimap2_path)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/wanrulin/anaconda3/lib/python3.11/site-packages/lifton/liftoff/align_features.py", line 109, in build_minimap2_index
    subprocess.run(
  File "/Users/wanrulin/anaconda3/lib/python3.11/subprocess.py", line 548, in run
    with Popen(*popenargs, **kwargs) as process:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/wanrulin/anaconda3/lib/python3.11/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Users/wanrulin/anaconda3/lib/python3.11/subprocess.py", line 1950, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'minimap2'
"""

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

Traceback (most recent call last):
  File "/Users/wanrulin/anaconda3/bin/lifton", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/wanrulin/anaconda3/lib/python3.11/site-packages/lifton/lifton.py", line 352, in main
    run_all_lifton_steps(args)
  File "/Users/wanrulin/anaconda3/lib/python3.11/site-packages/lifton/lifton.py", line 267, in run_all_lifton_steps
    liftoff_annotation = lifton_utils.exec_liftoff(lifton_outdir, args)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/wanrulin/anaconda3/lib/python3.11/site-packages/lifton/lifton_utils.py", line 113, in exec_liftoff
    liftoff_annotation = run_liftoff.run_liftoff(outdir, args)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/wanrulin/anaconda3/lib/python3.11/site-packages/lifton/run_liftoff.py", line 25, in run_liftoff
    liftoff_main.run_all_liftoff_steps(liftoff_args)
  File "/Users/wanrulin/anaconda3/lib/python3.11/site-packages/lifton/liftoff/liftoff_main.py", line 19, in run_all_liftoff_steps
    feature_db, feature_hierarchy, ref_parent_order = liftover_types.lift_original_annotation(ref_chroms, target_chroms,
                                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/wanrulin/anaconda3/lib/python3.11/site-packages/lifton/liftoff/liftover_types.py", line 15, in lift_original_annotation
    align_and_lift_features(ref_chroms, target_chroms, args, feature_hierarchy, liftover_type, unmapped_features,
  File "/Users/wanrulin/anaconda3/lib/python3.11/site-packages/lifton/liftoff/liftover_types.py", line 23, in align_and_lift_features
    aligned_segments= align_features.align_features_to_target(ref_chroms, target_chroms, args,
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/wanrulin/anaconda3/lib/python3.11/site-packages/lifton/liftoff/align_features.py", line 24, in align_features_to_target
    for result in pool.imap_unordered(func, np.arange(0, len(target_chroms))):
  File "/Users/wanrulin/anaconda3/lib/python3.11/multiprocessing/pool.py", line 873, in next
    raise value
FileNotFoundError: [Errno 2] No such file or directory: 'minimap2'

I got this error when I ran LiftOn for my own data and ran lifton_chr22_example_no_biotype.sh or lifton_chr22_example.sh. It would be really helpful to get your feedback on this!

Thanks a lot, Wanru

Kuanhao-Chao commented 5 months ago

Hi @wanru0,

LiftOn depends on Liftoff (https://github.com/agshumate/Liftoff), which requires minimap2. I assume the problem you encountered is because minimap2 is not installed on your workstation.

Please follow the installation guide for minimap2: https://github.com/lh3/minimap2 And let me know if it solves your problem!

Kuan-Hao

wanru0 commented 4 months ago

Thanks for the response, @Kuanhao-Chao ! I installed minimap2 and now I can run LiftOn smoothly!