Skip to content
PuckerLabPublic

About

This repository contains documentation and scripts used in the generation of the dataset BoGAPlant (Bonn Genome sequence Annotation of Plants).

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

8 Commits

Folders and files

Repository files navigation

GeMoMa annotation wrapper with BUSCO-guided filter optimization

DOI

A Bash pipeline that runs homology-based structural gene annotation with GeMoMa (Keilwagen et al., 2016; Keilwagen et al., 2018) on many genome sequences (assemblies) in one batch. For each assembly it picks the GeMoMa Annotation Filter (GAF) thresholds automatically. A grid search (optimize_filter.py) finds the strictest filter that keeps the loss of complete BUSCOs (Manni et al., 2021; Tegenfeldt et al., 2024) below a set limit.

The pipeline was written for angiosperm assemblies with references grouped by plant order, but any taxonomic grouping works (see Reference configuration).


Contents

File Description
gemoma_wrapper.sh Main pipeline script (Bash)
optimize_filter.py Grid search for GAF filter thresholds (Python + NumPy)
gemoma.yml Conda environment (Java, BLAST, MMseqs2, Python, NumPy)

Pipeline overview

For each assembly listed in the input table:

  1. GeMoMaPipeline. Runs with all references of the assembly's group, using a basic filter (start=='M' and stop=='*' and aa>=20). The predicted proteins are extracted. AnnotationFinalizer is skipped at this stage.
  2. BUSCO, first run. Runs in protein mode in a Docker container on predicted_proteins.fasta.
  3. optimize_filter.py. Tests every combination of minimum thresholds for score/aa, iAA, pAA and lpm, and returns the combination that removes the most genes while losing at most --max_busco_loss % (default 0.5 %) of complete single-copy BUSCOs.
  4. GeMoMa GAF. Runs again on the unfiltered per-reference predictions with the optimized thresholds plus fixed criteria (score>=100, start/stop codon, aa>=20), and with an alternative-transcript filter (atf=sumWeight>=…).
  5. AnnotationFinalizer. Renames genes and transcripts with a prefix built from the species initials (e.g. AT for Arabidopsis thaliana).
  6. Extractor. Writes the CDS and protein FASTA files.
  7. BUSCO, final run. Runs on the final protein set. The results are written to the run log.
  8. Documentation. Gene and transcript counts, plus an annotation_documentation.log per assembly that records all parameters.

Requirements

  • Conda (or mamba) for the environment in gemoma.yml
  • GeMoMa JAR (developed with GeMoMa 1.9), downloaded from http://www.jstacs.de/download.php?which=GeMoMa
  • Docker, accessible via sudo, with the BUSCO image pulled:
  • A BUSCO lineage dataset downloaded locally (the pipeline runs BUSCO with --offline), e.g. embryophyta_odb12. The lineage datasets are derived from OrthoDB (ODB) v12 (Tegenfeldt et al., 2024)
  • Enough memory: the default Java heap is -Xms32G -Xmx220G; adjust it to your machine. This also depends on the size of the genome sequence as well.

Installation

git clone https://github.com/PuckerLab/BoGAPlant
cd BoGAPlant

conda env create -f gemoma.yml
conda activate gemoma

The conda environment only provides the dependencies (Java, BLAST, MMseqs2, Python, NumPy). The gemoma conda package it contains was used only to pull these in; the pipeline does not use it.

Download the GeMoMa JAR (developed with version 1.9) separately from:

http://www.jstacs.de/download.php?which=GeMoMa

Unpack it and set GEMOMA_JAR in gemoma_wrapper.sh to the path of GeMoMa-<version>.jar.


Configuration

All settings are at the top of gemoma_wrapper.sh in the section DEFINE VARIABLES.

1. Target assemblies

TARGET_ASSEMBLIES points to a tab-separated file with one assembly per line:

<full path to assembly FASTA><TAB><group, e.g. plant order>

Example:

/vol/data/<path/to>/<assembly_dir_1>/<PREFIX>_<ACCESSION>_<Genus>_<species>.fna	<group_A>
/vol/data/<path/to>/<assembly_dir_2>/<PREFIX>_<ACCESSION>_<Genus>_<species>.fna	<group_B>

File naming convention. The accession, species name and gene ID prefix are parsed from the file name, which must follow this pattern:

<PREFIX>_<ACCESSION>_<Genus>_<species>.<extension>
e.g. GCA_000001735.2_Arabidopsis_thaliana.fna
     → accession: GCA_000001735.2
     → species:   Arabidopsis_thaliana
     → ID prefix: AT

The accession is everything up to the second underscore, and the species name is everything after it up to the first dot. As a regular expression: ^([^_]+_[^_]+)_([^.]+)\., where group 1 is the accession and group 2 the species name.

One assembly per directory. Every assembly must sit in its own directory, because all outputs (including the temporary gemoma_tmp/ directory) are written next to the assembly FASTA. If two assemblies share a directory, they overwrite each other's output.

2. Reference configuration

REFERENCE_CONFIG points to a tab-separated file that assigns reference annotations to groups. Add one line per reference; a group with several references gets several lines:

<group><TAB><reference basename>

Example:

<group_A>	<reference_basename_1>
<group_A>	<reference_basename_2>
<group_A>	<reference_basename_3>
<group_A>	<reference_basename_4>
<group_B>	<reference_basename_5>
...

The basename is relative to REFERENCE_DIR. For every basename, two files must exist:

${REFERENCE_DIR}/<basename>.fna.gz   # reference genome sequence
${REFERENCE_DIR}/<basename>.gff.gz   # reference annotation

The group names in this file must match the second column of the target table exactly (they are case-sensitive).

Number of references. Configure at least four references per group, preferably more. The alternative-transcript filter requires a prediction to be supported by floor(n_refs × perc_sumWeight / 100) references (30 % by default). With fewer than four references this rounds down to 0, and the filter then keeps every prediction. More references also improve the homology evidence for each gene model.

3. Paths and tools

Variable Meaning
RUN_LOG Run-wide log file (appended to, not overwritten)
REFERENCE_DIR Directory containing the reference .fna.gz / .gff.gz files
GEMOMA_JAR Path to the GeMoMa JAR
BUSCO_DATA Path to the local BUSCO lineage directory
BUSCO_IMAGE BUSCO Docker image (default ezlabgva/busco:v6.1.0_cv2)
OPTIMIZER_PATH Path to optimize_filter.py
THREADS Threads for GeMoMa and BUSCO
MIN_HEAP / MAX_HEAP Java heap size for all GeMoMa calls

Example configuration (replace the placeholders with your own paths):

TARGET_ASSEMBLIES="/<path/to>/target_assemblies.tsv"
RUN_LOG="/<path/to>/run.log"
REFERENCE_CONFIG="/<path/to>/reference_config.tsv"
REFERENCE_DIR="/<path/to>/<reference_dir>"
GEMOMA_JAR="/<path/to>/GeMoMa-<version>.jar"
BUSCO_DATA="/vol/data/<path/to>/<lineage>_odb<version>"
BUSCO_IMAGE="ezlabgva/busco:v6.1.0_cv2"
OPTIMIZER_PATH="/<path/to>/optimize_filter.py"

Only BUSCO_DATA and the target assemblies have to be below /vol/data/, because BUSCO reads them inside the container (see below). The other files are read on the host and can be anywhere.

Important

Docker volume mount /vol/data/ is hard-coded. BUSCO runs in a container started with -v /vol/data/:/vol/data/, so the container can only see files below /vol/data/. All target assemblies, the BUSCO lineage directory (BUSCO_DATA) and therefore all output directories must be inside /vol/data/. Otherwise BUSCO fails with "file not found" errors, and the assembly is skipped.

If your data is somewhere else, replace /vol/data/ with your data root in both docker run calls in gemoma_wrapper.sh (sections RUN BUSCO - PREFILTER and FINAL BUSCO), i.e. -v /<your/data/root>/:/<your/data/root>/. Host and container paths must be identical, because the wrapper passes host paths to BUSCO unchanged.

4. Filter settings

Variable Default Meaning
score 100 Minimum GeMoMa score (final GAF only)
aa 20 Minimum protein length in amino acids
start M Required start amino acid
stop * Required stop codon
perc_sumWeight 30 Percentage of references that must support a prediction for it to be kept as an alternative transcript. Converted to GAF.atf sumWeight>=floor(n_refs × perc_sumWeight / 100)

The thresholds for score/aa, iAA, pAA and lpm are set per assembly by the optimizer.


Running

conda activate gemoma
cd /<path/to>/<working_dir>
bash /<path/to>/gemoma_wrapper.sh

The pipeline calls sudo docker and sudo rm. Make sure sudo does not prompt for a password in the middle of a run: configure passwordless sudo for these commands or cache the credentials beforehand.

GeMoMa writes temporary files to ./GeMoMa_temp in the working directory. The wrapper empties this directory after each assembly, so start the script from a directory where that is safe.


Output

For an assembly at <assembly_dir>/<PREFIX>_<ACC>_<Genus>_<species>.fna, the following files are written to <assembly_dir>/:

File Content
<PREFIX>_<ACC>_<Genus>_<species>.genomic.gff Final annotation
<PREFIX>_<ACC>_<Genus>_<species>.genomic.cds.fasta Coding sequences
<PREFIX>_<ACC>_<Genus>_<species>.genomic.pep.fasta Peptide sequences
annotation_documentation.log Runtime, references, all filter thresholds, tool versions/paths
gemoma_tmp/ Intermediate files (see below)

Inside gemoma_tmp/:

Path Content
GeMoMa.log stdout/stderr of all GeMoMa and BUSCO calls for this assembly
filter.log Optimizer summary: search ranges, selected thresholds, removed/kept genes and transcripts
final_annotation.gff, predicted_proteins.fasta, unfiltered_predictions_from_species_*.gff Output of the initial GeMoMaPipeline run
filtered/filtered_predictions.gff Output of the optimized GAF run
busco/<ACC>/ BUSCO results before filtering
busco/<ACC>_final/ BUSCO results of the final protein set

When an assembly is run again, everything in gemoma_tmp/ except busco/ is deleted first, so that GeMoMa does not pick up old files.


Filter optimizer (optimize_filter.py)

The optimizer can also be run on its own:

python /<path/to>/optimize_filter.py \
    --gff <assembly_dir>/gemoma_tmp/final_annotation.gff \
    --busco <assembly_dir>/gemoma_tmp/busco/<ACC>/run_<lineage>/full_table.tsv \
    --log <assembly_dir>/gemoma_tmp/filter.log \
    --max_busco_loss 0.5 \
    --verbose

Method. A transcript is removed if it falls below at least one of the four thresholds. A gene is removed only when all of its transcripts are removed. A complete BUSCO counts as lost only when all transcripts that hit it are removed. Combinations above --max_busco_loss are discarded. Of the rest, the combination removing the most genes is selected; ties are broken by the lower BUSCO loss.

Only BUSCOs with status Complete (single-copy) are used. The sequence IDs in the BUSCO table must match the transcript IDs in the GFF, which is the case for GeMoMa's predicted_proteins.fasta.

Output. One line on stdout: score/aa iAA pAA lpm (rounded to two decimals), or null if no combination stays within the allowed BUSCO loss. On null, the wrapper logs an error and skips the assembly.

Search grid (defaults).

Parameter Options Default range Step
score/aa --spa_start/stop/step 0.2 – 5.0 0.2
iAA --iaa_start/stop/step 0.10 – 0.90 0.05
pAA --paa_start/stop/step 0.10 – 0.90 0.05
lpm --lpm_start/stop/step 0 – 100 5

With the defaults this is roughly 150,000 combinations. The search runs in parallel with one job per score/aa value, using all available CPU cores (independent of THREADS). To change the grid or the allowed BUSCO loss in a pipeline run, add the options to the python "$OPTIMIZER_PATH" call in gemoma_wrapper.sh.


Notes and limitations

  • With fewer than four references per group, sumWeight is rounded down to 0 (at the default 30 %), so the alternative-transcript filter keeps every prediction. Use at least four references, preferably more (see Reference configuration).
  • BUSCO can only access data below /vol/data/ unless the Docker mount is changed (see Paths and tools).
  • Transcripts in the GFF that lack one of the attributes score, aa, iAA, pAA or lpm are ignored by the optimizer and can never be filtered out there.
  • The optimizer measures BUSCO loss on the output of the initial GeMoMaPipeline run, while the final GAF run additionally applies score>=100 and the atf filter. The final BUSCO completeness can therefore differ slightly from the optimizer's estimate; check it in the run log.

Use in BoGAPlant

The GeMoMa annotations in the BoGAPlant dataset were created with this pipeline. Before publication, the outputs were processed further, so the published files differ from the direct pipeline output:

  • Failed Optimizer runs. Assemblies for which the optimizer did not find any filtering parameters under the default busco loss of 0.5 %, were rerun with the relaxed busco loss values 1 %, 2 % and 5 %.
  • Renaming. Files were renamed to the scheme <Taxon>__<ACCESSION>__v1.*. All gene, transcript and protein IDs were prefixed with the taxon name (e.g. AT12345.1 became Arabidopsis_thaliana_AT12345.1).
  • Exon features were added to the gff using gffread with the flags -F, --keep-genes and --force-exons
  • CDS. The coding sequences were extracted from the genome sequence and the annotation with get_cds_from_assembly.py (https://github.com/ShakNat/Genomic_file_wrangler), not with GeMoMa Extractor.
  • Proteins. The protein sequences were translated from these CDSs with transeq.py (https://github.com/bpucker/PBBtools/tree/main/transeq).

References

If you use this pipeline, please cite this repository as well as the underlying tools:

  • Keilwagen J, Wenk M, Erickson JL, Schattat MH, Grau J, Hartung F (2016). Using intron position conservation for homology-based gene prediction. Nucleic Acids Research 44(9):e89. https://doi.org/10.1093/nar/gkw092
  • Keilwagen J, Hartung F, Paulini M, Twardziok SO, Grau J (2018). Combining RNA-seq data and homology-based gene prediction for plants, animals and fungi. BMC Bioinformatics 19:189. https://doi.org/10.1186/s12859-018-2203-5
  • Manni M, Berkeley MR, Seppey M, Simão FA, Zdobnov EM (2021). BUSCO Update: Novel and Streamlined Workflows along with Broader and Deeper Phylogenetic Coverage for Scoring of Eukaryotic, Prokaryotic, and Viral Genomes. Molecular Biology and Evolution 38(10):4647–4654. https://doi.org/10.1093/molbev/msab199
  • Tegenfeldt F, Kuznetsov D, Manni M, Berkeley M, Zdobnov EM, Kriventseva EV (2024). OrthoDB and BUSCO update: annotation of orthologs with wider sampling of genomes. Nucleic Acids Research. https://doi.org/10.1093/nar/gkae987

About

This repository contains documentation and scripts used in the generation of the dataset BoGAPlant (Bonn Genome sequence Annotation of Plants).

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages