# GraffiTE documentation, all pages Source: https://cgroza.github.io/GraffiTE/ (built from docs/ on the main branch).

GraffiTE

Pangenomic toolbox for the analysis of transposable element insertion polymorphisms.

!!! info "Applies to GraffiTE v1.1" Verified against `v1.1.0.0` at commit `bf51777`. The [2024 paper](https://www.nature.com/articles/s41467-024-53294-2) describes v1.0, which differs in places; see [v1.0 vs v1.1](getting-started/v1.0-vs-v1.1.md). GraffiTE takes genome assemblies or long-read datasets, finds the structural variants that are transposable element (TE) insertions or deletions relative to a reference genome, annotates what those elements are, and then genotypes the polymorphisms in as many read sets as you like by building a pangenome graph with the TEs as bubbles. It handles both **non-reference** insertions (a TE present in your sample, absent from the reference) and **reference** insertions (a TE present in the reference, absent from your sample). You can also use it only as an annotator: hand it a VCF of structural variants and it reports which of them are TEs. --- ## GraffiTE workflow A GraffiTE run covers some or all of three stages in series. The third has two parts: genotyping, and an optional epigenetic mapping. Which stages run depends on the inputs you supply. ```mermaid %%{init: {"flowchart": {"nodeSpacing": 22, "rankSpacing": 24, "padding": 10}}}%% flowchart TB subgraph S1["Stage 1 · SV search"] direction TB i_lr(["Long reads
FASTQ or BAM"]) i_asm(["Genome assemblies"]) i_svs(["Your SV calls,
one VCF per sample"]) snf["Map reads,
call SVs
Sniffles2"] svim["Align assemblies,
call SVs
svim-asm"] pavc["Call SVs per
haplotype pair
PAV"] mrg["Merge and collapse
redundant calls
truvari collapse"] i_lr -->|"--longreads
--bams"| snf i_asm -->|"--assemblies"| svim i_asm -->|"--pav"| pavc i_svs -->|"--svs"| mrg snf --> mrg svim --> mrg pavc --> mrg end subgraph S2["Stage 2 · TE annotation"] direction TB i_vcf(["One merged
SV VCF"]) rmk["Annotate each SV
RepeatMasker, ULTRA"] filt["Keep SVs mostly
covered by repeats"] hall["Look for hallmarks
of transposition
TSD, polyA tail"] f_sub[/"pangenome.trusted.vcf, or
pangenome.human.vcf with --human"/] i_vcf -.->|"--vcf skips Stage 1"| rmk rmk --> filt --> hall --> f_sub end subgraph S3["Stage 3 · Graph mapping"] direction TB bld["Build a variation graph
each TE polymorphism
is a bubble
"] i_rd(["Reads to genotype"]) subgraph S31["3.1 · Genotyping"] gt["Genotype each sample
vg giraffe or GraphAligner,
then vg call; or PanGenie
"] gm["Merge the samples
into one VCF"] hk["Consolidate HERV-K
loci --human"] gt --> gm -.-> hk end subgraph S32["3.2 · Epigenetic mapping"] lift["Lift methylation
onto the graph
panmethyl"] end bld --> gt i_rd -->|"--genotype_with"| gt gt -.->|"alignments"| lift lift -.-> gm end out[/"GraffiTE.merged.genotypes.vcf.gz"/] S1 -->|"SVs.vcf"| S2 S2 -->|"pangenome.vcf"| S3 S3 --> out classDef inp fill:#8888881a,stroke:#888888; classDef file fill:none,stroke:#888888; classDef s1 fill:#f5851f2e,stroke:#f5851f; classDef s2 fill:#f2523f2e,stroke:#f2523f; classDef s3 fill:#3d63c92e,stroke:#3d63c9; classDef s32 fill:#2fb3b32e,stroke:#2fb3b3; classDef opt stroke-dasharray:4 3; class i_lr,i_asm,i_svs,i_vcf,i_rd inp; class out,f_sub file; class snf,svim,pavc,mrg s1; class rmk,filt,hall s2; class bld,gt,gm,hk s3; class lift s32; class hk,lift opt; style S1 fill:#f5851f0d,stroke:#f5851f; style S2 fill:#f2523f0d,stroke:#f2523f; style S3 fill:#3d63c908,stroke:#3d63c9; style S31 fill:#3d63c90d,stroke:#3d63c9; style S32 fill:#2fb3b30d,stroke:#2fb3b3,stroke-dasharray:4 3; ```

Rounded: your input. Slanted: a file GraffiTE writes. Dashed: optional, or a shortcut. Every stage also reads the reference genome (--reference), and Stage 2 reads a TE library in RepeatMasker format (--TE_library).

**Stage 1, SV search.** GraffiTE aligns each assembly or read set to the reference, calls structural variants, and keeps only insertions and deletions. You can mix callers and input types in one run; GraffiTE merges everything into a single non-redundant SV set. **Stage 2, TE annotation.** RepeatMasker scans every candidate SV allele against your TE library, and ULTRA scans it for tandem repeats. GraffiTE discards variants that are not mostly repeat and annotates the rest with their repeat identity, target site duplications and polyA tails. **Stage 3.1, genotyping.** GraffiTE builds a pangenome graph with the annotated polymorphisms as bubbles and genotypes each sample at those in the graph. The default back end, `--graph_method pangenie`, counts k-mers against a PanGenie index and never aligns; `giraffe` and `graphaligner` map the reads onto the graph and call genotypes with `vg call`. **Stage 3.2, epigenetic mapping, optional.** With `--epigenomes`, on the `giraffe`, `graphaligner` and `precomputed` graph methods (every method but `pangenie`), the `panmethyl` submodule lifts the base modifications carried by the genotyping BAMs onto the graph and summarizes them per polymorphism. See [Epigenetic mapping](guides/methylation.md). Stage 3 is optional (`--genotype false`). Stages 1 and 2 can each be skipped by supplying their outputs directly; see [Resuming and skipping work](guides/skipping-work.md). --- ## Reference and non-reference insertions GraffiTE reports variants **relative to the reference genome**. Read the direction off the allele lengths: ALT longer than REF is a non-reference insertion, REF longer than ALT is a reference insertion. `SVLEN` is positive for the first and negative for the second. Do not use `SVTYPE` for this. On any run with two or more caller VCFs, `truvari_merge` strips every upstream INFO field before the collapse and adds back only `SVLEN`, so `pangenome.vcf` has no `SVTYPE`. It survives only on the single-input paths, `--vcf` and a single caller VCF.
[figure: ref-vs-nonref-insertion]
ALT longer than REF means the element is absent from the reference and present in the sample. REF longer than ALT means the element is present in the reference and absent from the sample. The SVTYPE values shown appear only on the single-input paths. In both cases GraffiTE annotates the element itself.
**An ALT allele does not mean "TE present"**. For a reference insertion the relationship is inverted. `vcf_to_pa_tsv.py` writes the presence-absence TSVs and does that conversion for you: a `1` always means the TE is in that sample, whichever way the record points. It reads the direction from `INFO/SVTYPE` where there is one and from the allele lengths where there is not, which is what a run with two or more caller VCFs produces. It writes `NA` where neither gives a direction: on a symbolic or multi-allelic ALT, or when REF and ALT are the same length. See [Output files](reference/outputs.md). --- ## Glossary Where the codebase uses a term loosely, this table states the meaning that applies here. | Term | Meaning | |---|---| | **MEI** | Mobile element insertion; on these pages, one that is present in some haplotypes and absent from others. The v1.0 README calls them pMEs, polymorphic mobile elements. We use MEI, the more common term. | | **Non-reference insertion** | TE present in the sample, absent from the reference. ALT longer than REF, `SVLEN` positive. | | **Reference insertion** | TE present in the reference, absent from the sample. REF longer than ALT, `SVLEN` negative. | | **Hit** | One RepeatMasker match after fragment grouping, a single element. Counted by the `n_hits` INFO field. | | **Fragment** | One raw line of RepeatMasker output. Several fragments may be grouped into one hit. Counted by `fragmts`. | | **Repeat span** | The fraction of a variant's sequence covered by the non-redundant union of RepeatMasker TE hits and ULTRA tandem repeats. The `total_repeat_span` INFO field; the main quality filter. | | **Trusted subset** | A conservative subset of `pangenome.vcf`: single-hit, at least 250 bp, and not dominated by tandem repeat. Written to `pangenome.trusted.vcf`. | | **Human MEI subset** | With `--human`, a subset filtered to recent human mobile element subfamilies (AluY, L1HS, SVA_D/E/F, HML-2). Written to `pangenome.human.vcf`, **instead of** the trusted subset. | | **TSD** | Target site duplication. A short direct repeat flanking a genuine mobile element insertion, created by the integration mechanism. | | **Locus** (HERV-K) | With `--human`, the set of records that describe the same HML-2 element. Two records share a locus when they touch the same reference HML-2 element, or when their footprints lie within `--hervk_locus_window` (`1200` bp) of each other. Named by the `HERVK_LOCUS` INFO field. | | **Consolidated VCF** | With `--human`, a VCF in which each HERV-K locus is one record with per-allele states (`pangenome.human.consolidated.vcf`, and `GraffiTE.merged.genotypes.human.vcf.gz` after genotyping). | | **Precomputed** | The `--graph_method precomputed` mode: no graph is built and no reads are mapped; the run reuses a `--graph` directory with `--vcfs` or `--graph_alignments` from an earlier run. | | **Stage 1 / 2 / 3** | SV search / TE annotation / graph mapping (3.1 genotyping, 3.2 epigenetic mapping), as above. | --- ## Where to go next
- :material-download: **[Installation](getting-started/installation.md)** Prerequisites, cloning with submodules, and the container image. - :material-rocket-launch: **[Quickstart](getting-started/quickstart.md)** Run the bundled human chromosome-22 test dataset end to end. - :material-sign-direction: **[Choosing your inputs](getting-started/choosing-your-inputs.md)** A decision tree from "what data do I have" to "which flags do I pass". - :material-tune: **[Parameters](reference/parameters.md)** Every parameter, its default, and what it controls. - :material-file-tree: **[Output files](reference/outputs.md)** What GraffiTE writes and where. - :material-dna: **[Human MEIs](guides/human-mei.md)** The `--human` filter and the HERV-K classifier. - :material-flask-outline: **[Epigenetic mapping](guides/methylation.md)** Lift base modifications from the genotyping BAMs onto the graph with `--epigenomes`. - :material-compare: **[v1.0 vs v1.1](getting-started/v1.0-vs-v1.1.md)** What changed since the paper, flag by flag and field by field.
--- ## Citing GraffiTE > Groza, C., Chen, X., Wheeler, T.J. et al. A unified framework to analyze transposable element > insertion polymorphisms using graph genomes. *Nature Communications* **15**, 8915 (2024). > [doi:10.1038/s41467-024-53294-2](https://doi.org/10.1038/s41467-024-53294-2) GraffiTE was developed by **Cristian Groza** and **Clément Goubert** in [Guillaume Bourque's group](https://computationalgenomics.ca/BourqueLab/) at the [McGill Genome Centre](https://www.mcgillgenomecentre.ca/), Montréal, Canada. It builds on the concept described in [Groza et al., 2022](https://link.springer.com/protocol/10.1007/978-1-0716-2883-6_5). Bugs, comments and suggestions are welcome in the [issue tracker](https://github.com/cgroza/GraffiTE/issues). # Installation !!! info "Applies to GraffiTE v1.1" Verified against `v1.1.0.0` at commit `bf51777`. The [2024 paper](https://www.nature.com/articles/s41467-024-53294-2) describes v1.0, which differs in places; see [v1.0 vs v1.1](v1.0-vs-v1.1.md). GraffiTE is a Nextflow pipeline. Every tool it calls lives in a container image, so the host needs Nextflow, a Java runtime for it, and a container engine. It runs on any Linux machine or cluster; the `cluster` profile targets SLURM. --- ## Prerequisites | Requirement | Notes | |---|---| | Java 17 or newer | Nextflow's own requirement. | | [Nextflow](https://www.nextflow.io/docs/latest/install.html) | See the note below on the parser. | | [Apptainer](https://apptainer.org/docs/admin/main/installation.html) or Singularity | The container engine the config enables by default. Docker works with a config change. | !!! note "Nextflow 26" Nextflow 26.04 parses scripts with its strict syntax by default. `main.nf` compiles under it since commit `4605630` (2026-09-10, merged into `v1.1dev` on 2026-09-15 in PR #101); previewed here with 26.04.6 under both parsers. Checkouts older than that commit need `export NXF_SYNTAX_PARSER=v1`. !!! note "Apptainer through Conda" Users have reported problems with Apptainer installed through Conda. Install it from the Apptainer packages instead. --- ## Get GraffiTE Two ways, depending on whether you want a local copy of the code. === "Let Nextflow fetch it" Nextflow downloads and caches the pipeline the first time you run it, and initializes the `panmethyl` submodule for you: ```bash nextflow pull cgroza/GraffiTE -r v1.1.0.0 ``` The cached copy lives under `~/.nextflow/assets/cgroza/GraffiTE/`. Later runs use `nextflow run cgroza/GraffiTE -r v1.1.0.0 ...`. === "Clone the repository" ```bash git clone --branch v1.1.0.0 --recurse-submodules https://github.com/cgroza/GraffiTE.git cd GraffiTE ``` `main.nf` includes the `panmethyl` submodule unconditionally `main.nf:12`, and a clone made without `--recurse-submodules` leaves that directory empty, so Nextflow stops at compile time with: ``` Error main.nf:12:1: Invalid include source: '/panmethyl/module.nf' ``` Run `git submodule update --init` in the clone and start again. `nextflow pull` fetches the submodule itself. --- ## Get the container image The config points every process but `pav_asm` at `docker://cgroza/graffite:1.1.0.0` `nextflow.config:10,15`, and Nextflow pulls it on first use. Each release has its own image tag; `latest` follows the newest release. Apptainer converts the Docker image to a SIF itself, so you have nothing else to register. The image is `linux/amd64` only. On an arm64 machine it runs under emulation, slowly. If the compute nodes have no internet access, pull the image once on a node that does and point the run at the file: ```bash apptainer pull graffite_1.1.0.0.sif docker://cgroza/graffite:1.1.0.0 nextflow run cgroza/GraffiTE -r v1.1.0.0 -with-singularity /abs/path/graffite_1.1.0.0.sif ... ``` `-with-singularity` overrides the image path in `nextflow.config`. The PAV entry point (`--pav`) uses a second image, `library://becklab/pav/pav:latest` `nextflow.config:345`, pulled the same way. [Container contents](../reference/container.md) lists what the image contains and which recipe it is built from. ### Paths and `/tmp` Nextflow runs every container with `--contain --bind :/tmp` `nextflow.config:181`. Two consequences: - The host filesystem is hidden from the container except for what Nextflow mounts: the work directory and the files it stages (`singularity.autoMounts = true` `nextflow.config:4`). Give input files, including the paths inside samplesheets, as absolute paths. - `/tmp` inside the container is the directory the task runs in, unless you say otherwise: its directory under `work/`, or, under `-profile cluster`, its scratch directory in `$SLURM_TMPDIR` on the node. Where that filesystem is small, slow, or not writable from inside the container, point `--container_tmp` at one that is: ```bash nextflow run cgroza/GraffiTE -r v1.1.0.0 --container_tmp /scratch/you/tmp ... ``` The directory must exist before the run starts. On SLURM sites that set a per-job scratch variable, `--container_tmp $SLURM_TMPDIR` works too. !!! warning "Do not edit the cached config to do this" Before v1.1 the README's fix was to edit `singularity.runOptions` in `~/.nextflow/assets/cgroza/GraffiTE/nextflow.config`. That works once and then makes `nextflow pull` and `-latest` fail with `contains uncommitted changes` [#93](https://github.com/cgroza/GraffiTE/issues/93). Use `--container_tmp`, or `-c` with a config file of your own. A container that cannot write `/tmp` does not always fail. The run can finish having skipped `tsd_search` and `tsd_report`, leaving no `3_TSD_search/pangenome.vcf`. --- ## Verify the installation Without inputs the workflow prints its banner and stops with the input message, which shows that Nextflow and the submodule are in order: ```bash nextflow run cgroza/GraffiTE -r v1.1.0.0 -preview ``` ``` V. 1.1.0.0 - v1.1.0.0 ... No input given. Pass one of --longreads, --bams, --assemblies, --pav, --svs (discovery), --vcf (a merged SV VCF), --RM_dir (RepeatMasker output of an earlier run) or --graffite_vcf (a pangenome.vcf from an earlier run). ``` `main.nf:151`. Nextflow pulls the container only when a process runs, so the quick install test below is the first check of the image. ### Quick install test `test/quick_test.tar.gz` holds the inputs of a small run that uses the container: a 195 kb synthetic genome in 8 contigs, 4 haploid assemblies and 2 short-read samples. The run goes through discovery, annotation and genotyping, and `check.sh` compares the output with what GraffiTE 1.1 writes for this data set: ```bash nextflow pull cgroza/GraffiTE -r v1.1.0.0 tar xzf ~/.nextflow/assets/cgroza/GraffiTE/test/quick_test.tar.gz && cd graffite_quick_test nextflow run cgroza/GraffiTE -r v1.1.0.0 -params-file quick_test.yaml bash check.sh ``` The last line it prints is `GraffiTE quick test: PASS`. Where Nextflow could use 4 CPUs and 12 GB of memory, the run took about 70 seconds once the image was downloaded. The test genotypes with giraffe, because GraffiTE requests 32 GB for each task of PanGenie, the default back end. --- ## Updating ```bash nextflow pull cgroza/GraffiTE -r v1.1.0.0 ``` or add `-latest` to any `nextflow run` command. If Nextflow prints ``` cgroza/GraffiTE contains uncommitted changes -- cannot pull from repository ``` the cached copy was edited in place (usually `nextflow.config`). Remove it and pull again: ```bash rm -rf ~/.nextflow/assets/cgroza/GraffiTE/ nextflow pull cgroza/GraffiTE -r v1.1.0.0 ``` Each release names its own image tag in `nextflow.config`, so the first run of a new release pulls the image built for it. Nextflow does not check for a rebuilt image. Its Singularity cache is keyed on the image **name**, so it reuses a `cgroza-graffite-1.1.0.0.img` left by an earlier run. A new release names a new tag, and Nextflow pulls that one. If you point a run at `:latest` yourself, the cached `cgroza-graffite-latest.img` stays whatever `:latest` was on the day you first pulled it, and nothing in the log says the file is old. Delete it to force a fresh pull: ```bash rm -f "${NXF_SINGULARITY_CACHEDIR:-$NXF_HOME/singularity}"/cgroza-graffite-latest.img ``` `NXF_HOME` is `~/.nextflow` unless you set it. To see which image you are running, read the digest out of the cached file and compare it with the registry: ```bash apptainer inspect /path/to/cgroza-graffite-latest.img | grep base.digest ``` Do not compare checksums of the `.img` files themselves: Apptainer's conversion from the Docker image is not byte-reproducible, so two conversions of one image have different checksums. --- ## Execution profiles `-profile standard` runs everything on the local machine and `-profile cluster` submits each process to SLURM with the per-process CPU, memory and time parameters. `-profile cloud` submits each process to AWS Batch (`process.executor = 'awsbatch'`) with Docker in place of Singularity, because AWS Batch runs Docker images only `nextflow.config:7-29`. It needs your own AWS settings in a config passed with `-c`: at least a Batch queue (`process.queue`), a region (`aws.region`) and a work directory on S3 (`-w s3://...`); see Nextflow's [AWS Batch documentation](https://www.nextflow.io/docs/latest/aws.html). `pav_asm` cannot run there, since its image is a Sylabs library image. We have not tested this profile. [Resources and scaling](../guides/resources.md) covers how to size the requests. # Quickstart !!! info "Applies to GraffiTE v1.1" Verified against `v1.1.0.0` at commit `bf51777`. The [2024 paper](https://www.nature.com/articles/s41467-024-53294-2) describes v1.0, which differs in places; see [v1.0 vs v1.1](v1.0-vs-v1.1.md). The repository ships a small human dataset that exercises every stage: one haplotype assembly of chromosome 22, the matching reference, a Dfam library, and a short-read set to genotype. --- ## Test dataset ```bash tar xzf test/human_test_set.tar.gz cd GraffiTE_testset ``` | File | Role | |---|---| | `HG002.mat.cur.20211005_chr22.fasta.gz` | The maternal HG002 assembly, chromosome 22 only. Stage 1 input. | | `hs37d5.chr22.fa` | Reference, chromosome 22 of hs37d5. | | `human_DFAM3.6.fasta` | TE consensus library for RepeatMasker. | | `HG002.100k.set1.Illumina.fastq.gz` | 100 k Illumina reads from HG002. Stage 3 input. | | `assemblies.csv` | `path,sample` samplesheet naming the assembly `HG002.mat`. | | `reads.csv` | `path,sample` samplesheet naming the read set `short_test1`. | | `out/` | The output of the command below, made with GraffiTE 1.1.0.0, to compare with yours. | `reads.csv` has no `type` column. The workflow reads `row.type`, finds nothing, and falls to the `default` preset `main.nf:190`; PanGenie, the default genotyper, does not use the preset. !!! note "Compare your run with the bundled `out/`" `out/` holds the output of the command below, made with GraffiTE 1.1.0.0 on 2026-10-16. Your `out_v1.1/` should hold the same records; the `##fileDate` header lines differ. --- ## Run it ```bash nextflow run cgroza/GraffiTE -r v1.1.0.0 \ --assemblies assemblies.csv \ --reference hs37d5.chr22.fa \ --TE_library human_DFAM3.6.fasta \ --genotype_with reads.csv \ --out out_v1.1 ``` Pass the four data arguments as shown; the defaults for `--reference` and `--TE_library` are placeholder filenames that do not exist `nextflow.config:50-52`. `--genotype_with` is the parameter name as declared `nextflow.config:43`. The hyphenated form does nothing: Nextflow turns `--genotype-with` into a parameter named `genotypeWith`, and the pipeline reads the default `reads.csv` instead (checked with Nextflow 26.04.6). Add `-profile cluster` on SLURM, and `-with-singularity /abs/path/graffite_1.1.0.0.sif` if you pulled the image by hand ([Installation](installation.md)). `--out out_v1.1` keeps the results apart from the bundled `out/`. --- ## What you should see When the run completes, `out_v1.1/` holds the files below. With GraffiTE 1.1.0.0, `1_SV_search/SVs.vcf` has 263 records, `pangenome.vcf` 221, `pangenome.trusted.vcf` 25 and `GraffiTE.merged.genotypes.vcf.gz` 218. The run took 152 seconds with `--cores 8`. ``` out_v1.1/ ├── 1_SV_search/ │ ├── svim-asm_individual_VCFs/HG002.mat.vcf.gz │ └── SVs.vcf ├── 2_Repeat_Filtering/ │ └── 1/ one directory per contig, here only chr22 │ ├── genotypes_repmasked_filtered.vcf │ ├── repeatmasker_dir/ │ └── ultra_out.bed ... ├── 3_TSD_search/ │ ├── pangenome.vcf │ ├── pangenome.trusted.vcf │ ├── pangenome.presence-absence.tsv │ ├── pangenome.presence-absence_trusted.tsv │ ├── TSD_summary.txt │ └── TSD_full_log.txt └── 4_Genotyping/ ├── pangenie_graph_variants.tsv ├── short_test1_genotyping.vcf.gz ├── short_test1_genotyping.vcf.gz.tbi ├── genotyping_record_audit.tsv ├── GraffiTE.merged.genotypes.vcf.gz ├── GraffiTE.merged.genotypes.trusted.vcf.gz ├── GraffiTE.merged.genotypes.trusted.vcf.gz.tbi └── GraffiTE.merged.genotypes.presence-absence_trusted.tsv ``` `pangenome.vcf` is the annotated callset, `pangenome.trusted.vcf` its conservative subset, and `GraffiTE.merged.genotypes.vcf.gz` the genotypes of `short_test1`. That last file does not carry every `pangenome.vcf` allele: on the default `--graph_method pangenie`, `merge_vcfs.py` leaves out alleles that overlap another at the same site, all but two ALT alleles at one position, and alleles holding a base other than A, C, G or T. Those alleles get no genotype `bin/pangenie_graph_vcf.py:119-124`. `pangenie_graph_variants.tsv` says which alleles reached the graph `module/main.nf:715`, and `genotyping_record_audit.tsv` lists what became of each one `module/main.nf:909-929`. `GraffiTE.merged.genotypes.trusted.vcf.gz` is that conservative subset carried through to the genotypes, written whenever `--human` is off `module/main.nf:931-961`. The presence-absence TSVs say, per sample, whether the TE is present, whichever way the VCF record points. Every file is described on [Output files](../reference/outputs.md), and every INFO field on [VCF fields](../reference/vcf-fields.md). Nextflow also leaves a `work/` directory in the launch directory with every intermediate file. It is safe to delete once you have what you need, and it is what `-resume` reads. --- ## Next steps - [Choosing your inputs](choosing-your-inputs.md) maps your own data to the entry flags. - [Stage 1: SV search](../guides/discovery.md) explains what happened to the assembly. - [Resources and scaling](../guides/resources.md) covers whole genomes and clusters. - [Human MEIs](../guides/human-mei.md) covers the `--human` filter for human data. # Choosing your inputs !!! info "Applies to GraffiTE v1.1" Verified against `v1.1.0.0` at commit `bf51777`. The [2024 paper](https://www.nature.com/articles/s41467-024-53294-2) describes v1.0, which differs in places; see [v1.0 vs v1.1](v1.0-vs-v1.1.md). GraffiTE is three stages in series, and every input flag is a way of entering that series at a given point. Choose the flag by asking what you already have. --- ## Stages and entry flags | Stage | What it finds | Enters with | Produces | |---|---|---|---| | **1, SV search** | Where the sequence-resolved insertions and deletions sit relative to the reference | `--assemblies`, `--pav`, `--longreads`, `--bams`, `--svs` | `1_SV_search/SVs.vcf` | | **2, TE annotation** | Which of those SVs are transposable elements, and what they are | `--vcf`, `--RM_dir` | `3_TSD_search/pangenome.vcf` and its subsets | | **3.1, genotyping** | Which samples carry each polymorphism | `--graffite_vcf`, `--graph`, `--graph_alignments`, `--vcfs` | `4_Genotyping/GraffiTE.merged.genotypes.vcf.gz` | The optional Stage 3.2 lifts methylation onto the graph (`--epigenomes`), only on the `giraffe`, `graphaligner` and `precomputed` methods `main.nf:206,234`. See [Epigenetic mapping](../guides/methylation.md). --- ## What data do you have? ```mermaid %%{init: {"flowchart": {"nodeSpacing": 14, "rankSpacing": 26, "padding": 8}}}%% flowchart LR Q0("What do you
start from?") Q0 -->|"Genome
assemblies"| Q1("Call them
with PAV?") Q1 -->|No| SA["--assemblies"] Q1 -->|Yes| PV["--pav"] Q0 -->|"Long reads"| Q2("Already aligned?") Q2 -->|No| LR["--longreads"] Q2 -->|Yes| BM["--bams"] Q0 -->|"SV calls with
REF and ALT
sequences"| Q3("One VCF per sample,
or one merged VCF?") Q3 -->|"Per sample"| SV["--svs"] Q3 -->|"Merged"| VC["--vcf"] Q0 -->|"An earlier
GraffiTE run"| Q4("What did
it finish?") Q4 -->|"RepeatMasker"| RM["--RM_dir"] Q4 -->|"pangenome.vcf"| GV["--graffite_vcf"] Q4 -->|"Graph, alignments
or vg call VCFs"| PC["--graph
--graph_alignments
--vcfs"] classDef q fill:#8888881a,stroke:#888888; classDef s1 fill:#f5851f2e,stroke:#f5851f; classDef s2 fill:#f2523f2e,stroke:#f2523f; classDef s3 fill:#3d63c92e,stroke:#3d63c9; class Q0,Q1,Q2,Q3,Q4 q; class SA,PV,LR,BM,SV s1; class VC,RM s2; class GV,PC s3; ```

enters at Stage 1 at Stage 2 at Stage 3

Every discovery input needs `--reference` and `--TE_library`. Genotyping needs `--genotype_with` unless you pass `--genotype false`. --- ## Command builder Answer the questions to get a starting command. Its file names are those of the examples on [Samplesheet formats](../reference/samplesheets.md); replace them with your own paths.

The command builder needs JavaScript; without it, use the diagram above and the tables below.

[Samplesheet formats](../reference/samplesheets.md){ data-key="sheets" hidden } [Resuming and skipping work](../guides/skipping-work.md){ data-key="skipping" hidden } [Stage 1: SV search](../guides/discovery.md){ data-key="discovery" hidden } [Human mobile element insertions](../guides/human-mei.md){ data-key="human" hidden } [Stage 3.2: epigenetic mapping](../guides/methylation.md){ data-key="methylation" hidden } [Installation](installation.md){ data-key="install" hidden }
--- ## What each flag runs and skips | Flag | Takes | Runs | Skips | |---|---|---|---| | `--assemblies` | CSV `sample,path` of haploid assemblies | minimap2 or winnowmap under `--aligner`, svim-asm, then Stages 2 and 3 | nothing | | `--pav` | CSV read by position, first line skipped as a header, `sample,hap1[,hap2...]` | PAV in its own container, then Stages 2 and 3 | nothing | | `--longreads` | CSV `sample,path,type` | minimap2 or winnowmap, Sniffles2, then Stages 2 and 3 | nothing | | `--bams` | CSV `sample,path` of long-read alignments | Sniffles2, then Stages 2 and 3 | read alignment | | `--svs` | CSV `sample,path` of per-sample VCFs | the truvari merge, then Stages 2 and 3 | all callers | | `--vcf` | one sequence-resolved VCF | Stages 2 and 3 | the callers and the truvari collapse | | `--RM_dir` | a `2_Repeat_Filtering` directory | TSD search onwards, then Stage 3 | Stage 1 and RepeatMasker | | `--graffite_vcf` | a `pangenome.vcf` | Stage 3 only | Stages 1 and 2 | | `--graph` | a `GraffiTE_graph/index` directory | read alignment and calling | graph construction | | `--graph_alignments` | CSV `sample,gaf,pack` | `vg call` and the merge | graph alignment | | `--vcfs` | CSV `sample,path` of per-sample `vg call` VCFs | the merge | alignment and calling | | `--hervk_reconcile_vcf` | a genotyped VCF from an earlier run, with `--human --genotype false` | Stages 1 and 2, then HERV-K consolidation against that VCF | Stage 3 | | `--genotype false` | | Stages 1 and 2 | Stage 3 | Lines in `main.nf`: the discovery block `main.nf:76-126`, the annotation entry points `main.nf:129-156`, `--graffite_vcf` `main.nf:183-186`, the genotyping block `main.nf:188-294`. Samplesheet columns are on [Samplesheet formats](../reference/samplesheets.md). --- ## Combining flags **Discovery flags add up.** You can pass `--assemblies`, `--pav`, `--longreads`, `--bams` and `--svs` together in any combination; every caller's output goes into one truvari merge `main.nf:125`. The paper's `GT-svsn` mode is one such combination. **`--vcf` stands alone.** It replaces the merge, so GraffiTE refuses any discovery flag beside it before anything runs: ``` --vcf cannot be combined with --assemblies. Pass --vcf alone, or drop it and use --svs to add your own per-sample VCFs to the discovery merge. ``` `main.nf:46-49`. **`--graffite_vcf` skips the HERV-K annotation.** With `--human`, the consolidation step needs files that only the annotation stage writes, so with `--graffite_vcf --human` pass `--hervk_reconcile false`, or start from `--RM_dir` instead `main.nf:61-63`. **`--graph_method precomputed` needs its inputs.** It builds nothing, so it requires `--graph` and one of `--vcfs` or `--graph_alignments` `main.nf:53-56`. **`-resume`** is Nextflow's own restart and covers the common case of a crashed run; the entry flags are for runs whose work directory is gone. See [Resuming and skipping work](../guides/skipping-work.md). --- ## Where to read next - [Stage 1: SV search](../guides/discovery.md) for the callers and the merge. - [Stage 2: TE annotation](../guides/annotation.md) for RepeatMasker, ULTRA, TSDs and the filters. - [Stage 3.1: genotyping](../guides/genotyping.md) for PanGenie, Giraffe and GraphAligner. - [Parameters](../reference/parameters.md) for every flag and its default. # v1.0 vs v1.1 !!! info "Applies to GraffiTE v1.1" Verified against `v1.1.0.0` at commit `bf51777`. The [2024 paper](https://www.nature.com/articles/s41467-024-53294-2) describes the code at the `publication` tag, which predates v1.0. The paper (Groza, Chen, Wheeler et al., *Nature Communications* 2024) describes the code at the [`publication`](https://github.com/cgroza/GraffiTE/tree/publication) tag, commit `8f44c22` of 2024-05-29. `main` has 111 more commits after the tag, up to `f37674b` of 2026-01-15, and that last commit before v1.1 is v1.0, tagged `v1.0.0.0`. If you read the README on `main` before the v1.1 release, you read about v1.0. To run v1.0, pass `-r v1.0.0.0` to `nextflow run`. This site documents v1.1. Each table below has a column for the paper, one for v1.0 and one for v1.1. The READMEs of the first two are at the [`publication`](https://github.com/cgroza/GraffiTE/blob/publication/README.md) and [`v1.0.0.0`](https://github.com/cgroza/GraffiTE/blob/v1.0.0.0/README.md) tags. **New in** names the version that brought a change: **v1.0** for a change made after the paper, which v1.1 keeps; **v1.1** for a change in this release; **v1.0, v1.1** for a row that changed twice. **none** marks a row that is the same in all three. Citations without a prefix point to the v1.1 code, and those prefixed `publication:` or `f37674b:` to the paper or v1.0 code. --- ## Command line | | New in | Paper | v1.0 | v1.1 | |---|---|---|---|---| | Read sets to genotype | v1.1 | `--reads reads.csv` `publication:main.nf:8` | Same as the paper `f37674b:nextflow.config:33` | `--genotype_with reads.csv` `nextflow.config:43`. A command line with `--reads` is not an error: Nextflow stores the parameter, the v1.1 code never reads it, and the pipeline looks for the default `reads.csv` instead. The hyphenated `--genotype-with` behaves the same way: Nextflow stores it as `genotypeWith` and `genotype_with` keeps its default (checked with Nextflow 24.10.5 and 26.04.6). | | `--mammal` | v1.1 | Turns on the L1 5′ inversion and SVA VNTR checks `publication:main.nf:313-315` | Same as the paper `f37674b:main.nf:319-321` | Accepted and inert. Both checks run on every dataset; the script only prints a notice `bin/repmask_vcf.sh:165-169`. | | Discovery inputs | v1.0, v1.1 | `--assemblies` (svim-asm), `--longreads` (Sniffles2), `--vcf` (an SV VCF you already have) | Adds `--bams`, long reads already aligned to the reference `f37674b:main.nf:563-566`, and the `lr:hq` read type in `--longreads` `f37674b:main.nf:117-120` | Adds `--pav` (the PAV caller) and `--svs` (per-sample VCFs merged with the callers' output) `main.nf:114-123` | | Restarting from earlier output | v1.0, v1.1 | `--RM_vcf` with `--RM_dir` (the filtered VCF and its `repeatmasker_dir`) start a run at the TSD search, and `--graffite_vcf` at genotyping `publication:main.nf:571-573,605` | `--RM_vcf` removed. `--RM_dir` takes a whole `2_Repeat_Filtering` directory, one subdirectory per contig `f37674b:main.nf:591-599` | `--RM_dir` as in v1.0. Genotyping can also start from a graph, from alignments or from `vg call` VCFs: `--graph`, `--graph_alignments`, `--vcfs` with `--graph_method precomputed` `main.nf:206-232`. See [Resuming and skipping work](../guides/skipping-work.md). | | Aligner | none | minimap2, or winnowmap with `--aligner winnowmap`, for assemblies and long reads `publication:main.nf:22,131-137,157-164` | Same as the paper | Same as the paper `module/main.nf:57-64,86-94` | | `--break_scaffolds` | v1.0, v1.1 | not available | Splits each assembly at every run of `N` before alignment `f37674b:bin/breakgaps.py:12` | Splits only at runs of at least `--break_scaffolds_min_gap` `N`, default 10 `nextflow.config:49`, `bin/breakgaps.py:14-15` | | Human data | v1.1 | none | none | `--human`, its subfamily whitelists and thresholds, and the HERV-K classifier parameters `nextflow.config:65-122`. See [Human mobile element insertions](../guides/human-mei.md). | | Methylation | v1.1 | none | none | `--epigenomes`, `--code`, `--motif`, `--lifted`, `--bed` `nextflow.config:33,169-172`. See [Stage 3.2: epigenetic mapping](../guides/methylation.md). | | `--vcf` with a discovery flag | v1.1 | Not checked. Nextflow stopped with an error naming a discovery process that `--vcf` had skipped `publication:main.nf:545,577-582` | Same as the paper `f37674b:main.nf:551,603-608` | Refused at launch with a message `main.nf:46-49` | Every current parameter is on [Parameters](../reference/parameters.md). --- ## SV search | | New in | Paper | v1.0 | v1.1 | |---|---|---|---|---| | Merging the calls | v1.1 | SURVIVOR merges the svim-asm calls, then merges them with the Sniffles2 calls when both inputs are given `publication:main.nf:244,265` | Same as the paper `f37674b:main.nf:214,235` | truvari: `bcftools merge` of every caller's VCFs, then `truvari collapse`; a single VCF goes through unchanged `module/main.nf:222-223,246,260-261`. v1.1 has no `--merge_svim_sniffles2_*` parameters. | | Merged call set | v1.1 | `1_SV_search/svim-asm_variants.vcf` (assemblies) or `sniffles2_variants.vcf` (long reads), and `svim-sniffles_merged_variants.vcf` when both ran `publication:main.nf:204,244,290` | Same as the paper | One file, `1_SV_search/SVs.vcf` `module/main.nf:201` | | Sniffles2 and short contigs | v1.1 | Run without `--all-contigs` `publication:main.nf:184,203` | Same as the paper | `--all-contigs`: without it, Sniffles 2.8 and later skip every contig shorter than 1 Mb `module/main.nf:108-113,131` | --- ## Annotation | | New in | Paper | v1.0 | v1.1 | |---|---|---|---|---| | Grouping RepeatMasker hits | v1.0, v1.1 | OneCodeToFindThemAll joins RepeatMasker fragments into elements and keeps only hits classed LINE, SINE, LTR, DNA, RC, Retroposon or Unknown `publication:bin/repmask_vcf.sh:35-41`, `publication:bin/one_code_to_find_them_all.pl:440` | OneCode as in the paper, with TIR, MITE and IS added to the classes it keeps and RC dropped from them, so OneCode skips hits classed `RC/Helitron` `f37674b:bin/one_code_to_find_them_all.pl:443` | OneCode removed. `annotate_vcf.R` groups hits by RepeatMasker's own ID and counts every class except `Simple_repeat` and `Low_complexity`, satellites included `bin/repmask_vcf.sh:108`, `bin/annotate_vcf.R:96-114`. `n_hits` is the number of these groups and `fragmts` the number of fragments in each. | | Repeat-span filter | v1.1 | `total_match_span` > 0.80, fixed `publication:main.nf:320` | Same as the paper `f37674b:main.nf:326` | `total_repeat_span` (RepeatMasker hits plus ULTRA tandem repeats, non-redundant) against `--repeat_span_cutoff`, default `0.80` `nextflow.config:61`, `module/main.nf:661` | | Tandem repeats | v1.1 | not annotated | not annotated | ULTRA runs on every variant sequence; `ULTRA_TR` and `ULTRA_TR_span` fields `bin/repmask_vcf.sh:31-32,92` | | polyA tails | v1.1 | not annotated | not annotated | `polyA=TRUE` or `FALSE` on records with at most one hit, `NA` on records with more `bin/add_polyA.py:103-116` | | L1 5′ inversion | v1.1 | `mam_filter_1=5P_INV:plus` or `5P_INV:minus`, only with `--mammal` `publication:bin/repmask_vcf.sh:91-99` | Same as the paper `f37674b:bin/repmask_vcf.sh:95-113` | `L1_5PINV` on every record, holding the RepeatMasker ID of the inverted hit or `None` `bin/annotate_vcf.R:119,177` | | SVA VNTR-only polymorphisms | v1.1 | `mam_filter_2=VNTR_ONLY:::`, only with `--mammal` `publication:bin/repmask_vcf.sh:101-116` | Same as the paper `f37674b:bin/repmask_vcf.sh:115-131` | The hit gets a `(VNTR_only)` suffix in `repeat_ids` and the class `Simple_repeat`; no separate field `bin/annotate_vcf.R:151-156` | | RepeatMasker `-nolow` | v1.0 | On `publication:bin/repmask_vcf.sh:30` | Removed on 2025-10-01 (`1cbebbf`); the README gives the reason as spurious hits on low-complexity stretches of some TE consensus sequences `f37674b:bin/repmask_vcf.sh:30`, `f37674b:README.md:35-36` | As in v1.0 `bin/repmask_vcf.sh:75` | | RepeatMasker coordinates | v1.0 | 1-based starts used as 0-based, so `match_lengths` came out 1 bp short per hit and `total_match_length` 1 bp short per merged interval `publication:bin/annotate_vcf.R:64`, `publication:bin/repmask_vcf.sh:73` | 0-based (`bd2f1de`, 2024-10-21); the SVA VNTR check followed the next day (`af729bc`) `f37674b:bin/annotate_vcf.R:24`, `f37674b:bin/repmask_vcf.sh:73,119,122` | 0-based for `total_match_length` and the spans `bin/repmask_vcf.sh:114` | | Subsets | v1.1 | none | none | `pangenome.trusted.vcf` (or `pangenome.human.vcf` with `--human`) and presence-absence TSVs beside `pangenome.vcf` `module/main.nf:519-525` | --- ## Target site duplications | | New in | Paper | v1.0 | v1.1 | |---|---|---|---|---| | Records searched | v1.1 | `n_hits=1`, plus two-hit L1s flagged `5P_INV` (which needs `--mammal`), minus SVA VNTR-only records `publication:bin/prepTSD.sh:21-24` | Same as the paper | Every record that passes the repeat-span filter `bin/prepTSD.sh:43-44,51-52` | | Window, `--tsd_win` | v1.1 | Sets how much of each end of the variant is compared. The reference flanks have a fixed width that `--tsd_win` does not change `publication:bin/prepTSD.sh:27-29,42` | Same as the paper `f37674b:bin/prepTSD.sh:27-29,42` | Sets the reference flanks, the variant ends, and the junction column the score is measured from `bin/prepTSD.sh:43-44,56`, `bin/TSD_Match_v2.sh:9,69` | | Method | v1.1 | blastn, word size 4, between the 5′ fragment (flank and start of the variant) and the 3′ fragment (end of the variant and flank), with the masked element cut out and poly(A) or poly(T) runs shortened `publication:bin/TSD_Match_v2.sh:43-44,51-86,140` | Same as the paper | Exact matches of 4 to 20 bp, found by `exact_match.py` `bin/TSD_Match_v2.sh:48-49,69` | | Pass rule | v1.1 | Both copies within 5 bp of the junction, with at most one mismatch or gap, or a mismatch rate no higher than the element's RepeatMasker divergence `publication:bin/TSD_Match_v2.sh:172` | Same as the paper | `score = min(a, b) ≤ 5`, the distance of the copies from the junction; a candidate under 6 bp passes only with a score of 0.5 or less `bin/TSD_Match_v2.sh:69,142` | | Output | v1.1 | `TSD=<5′ copy>,<3′ copy>` on records whose search passed `publication:main.nf:397,401` | Same as the paper `f37674b:main.nf:397,401` | The same field, declared `Number=2`, in upper case `bin/tsd_annotate_vcf.sh:23,32` | The scoring is on [Target site duplications](../background/tsd.md). --- ## Genotyping | | New in | Paper | v1.0 | v1.1 | |---|---|---|---|---| | Read files | v1.1 | FASTQ `publication:main.nf:609` | FASTQ | FASTQ or BAM; GraffiTE converts a BAM to FASTQ first `main.nf:192-197` | | Giraffe | v1.0, v1.1 | Short reads, passed as interleaved pairs (`-i`) with no preset `publication:main.nf:484` | A preset comes from the `type` column of the read CSV: `pb` and `hifi` give `hifi`, `ont` gives `r10`, anything else the default preset with `-i` `f37674b:main.nf:480-488,634-651` | Same presets `main.nf:190`; `make_graph` indexes the graph for both short-read and long-read Giraffe `module/main.nf:790` | | `vg call` | v1.1 | `vg call -a` `publication:main.nf:507` | Same as the paper `f37674b:main.nf:512` | `vg call -a -A`, then `bcftools norm -m-` to one ALT per record `module/main.nf:874-875` | | Sex chromosomes | v1.1 | no ploidy setting | no ploidy setting | `-R chrX:1,chrY:1`: haploid calls on `chrX` and `chrY` by contig name `module/main.nf:874`. See [Stage 3.1: genotyping](../guides/genotyping.md). | | PanGenie | v1.1 | Run on `pangenome.vcf` directly; genotypes merged as written `publication:main.nf:423` | Same as the paper `f37674b:main.nf:423` | `PanGenie-index` built from a `bcftools norm -m+` VCF, and the genotypes split back to one ALT per record before the merge `module/main.nf:728,732,768` | --- ## Output files | | New in | Paper | v1.0 | v1.1 | |---|---|---|---|---| | `2_Repeat_Filtering/` | v1.0 | One directory `publication:main.nf:299` | One numbered subdirectory per contig `f37674b:main.nf:309` | As in v1.0 `module/main.nf:638` | | Graph | v1.0, v1.1 | Not published | `GraffiTE_graph/` with giraffe or graphaligner `f37674b:main.nf:433` | `GraffiTE_graph/`, now with `index.gfa` `module/main.nf:774,791,799` | | Graph alignments | v1.1 | Not published | Not published | `GraffiTE_alignments/`, a GAF and a pack file per sample `module/main.nf:827,833` | | `4_Genotyping/` | v1.1 | Per-sample VCFs and `GraffiTE.merged.genotypes.vcf.gz` | Same as the paper | Also `GraffiTE.merged.genotypes.trusted.vcf.gz` and its presence-absence table (not with `--human`), `genotyping_record_audit.tsv`, and `pangenie_graph_variants.tsv` on PanGenie runs `module/main.nf:715,918,939-941` | | Version in VCF headers | v1.1 | none | none | `##GraffiTE_version=1.1.0.0` `module/main.nf:630-633,903` | [Output files](../reference/outputs.md) describes every file. --- ## Running | | New in | Paper | v1.0 | v1.1 | |---|---|---|---|---| | Container image | v1.1 | `library://cgroza/collection/graffite:latest` (Sylabs) in every profile; `-profile cloud` names the executor `aws` `publication:nextflow.config:9,14,19-20` | Same as the paper `f37674b:nextflow.config:9,14,19-20` | `docker://cgroza/graffite:1.1.0.0` from Docker Hub; `-profile cloud` runs on AWS Batch with Docker `nextflow.config:10,15,21-26`. See [Container](../reference/container.md). | | `/tmp` in the container | v1.1 | `$(pwd)` bound to `/tmp`; changing it meant editing `nextflow.config` `publication:nextflow.config:4` | Same as the paper | `--container_tmp` names the directory, `$(pwd)` by default `nextflow.config:51,181` | | Resource parameters | v1.0, v1.1 | `*_memory`, `*_threads` and `*_time` per process | Adds `--tsd_time`, `--merge_vcf_time` and `--vg_call_time`, and defaults for `--make_graph_time` (6h), `--make_graph_memory` (40G) and `--repeatmasker_memory` (10G) `f37674b:nextflow.config:52-86` | Drops `--merge_svim_sniffles2_*`; adds `--pav_memory`, `--pav_time` and the `--hervk_*` resources; `--pangenie_memory` defaults to 32G `nextflow.config:148`. See [Resources and scaling](../guides/resources.md). | --- ## Modes from the paper The README at the `publication` tag lists the nine modes the paper refers to `publication:README.md:322-334`. This is that table with v1.1 arguments. With the paper code or v1.0, write `--reads` where the table has `--genotype_with`. | Mode | v1.1 arguments | Discovery from | Genotyped with | |---|---|---|---| | GT-sv | `--assemblies a.csv --genotype false` | assemblies | nothing | | GT-sn | `--longreads lr.csv --genotype false` | long reads | nothing | | GT-svsn | `--assemblies a.csv --longreads lr.csv --genotype false` | both | nothing | | GT-sv-PG | `--assemblies a.csv --genotype_with sr.csv` | assemblies | short reads, PanGenie | | GT-sn-PG | `--longreads lr.csv --genotype_with sr.csv` | long reads | short reads, PanGenie | | GT-svsn-PG | `--assemblies a.csv --longreads lr.csv --genotype_with sr.csv` | both | short reads, PanGenie | | GT-sv-GA | `--assemblies a.csv --genotype_with lr.csv --graph_method graphaligner` | assemblies | long reads, GraphAligner | | GT-sn-GA | `--longreads lr.csv --genotype_with lr.csv --graph_method graphaligner` | long reads | long reads, GraphAligner | | GT-svsn-GA | `--assemblies a.csv --longreads lr.csv --genotype_with lr.csv --graph_method graphaligner` | both | long reads, GraphAligner | `--graph_method pangenie` is the default in all three versions, so the PG rows leave it out. --- ## Resource figures We added a table of measured resources (human, *Cannabis sativa* and *Zea mays*) to the README on `main` on 2024-09-06 (`d833ca9`), after the paper release. Read it in the [v1.0 README](https://github.com/cgroza/GraffiTE/blob/v1.0.0.0/README.md#resource-usage-examples); this page does not repeat it. The README at the `publication` tag gives only rough figures for human chromosome 1 and *Drosophila melanogaster*. The table went into the README before we split RepeatMasker by contig (v1.0) and before we added ULTRA to that step and an index to PanGenie (v1.1), so its RepeatMasker and PanGenie rows may not hold for either version. For v1.1, see [Resources and scaling](../guides/resources.md). # Stage 1: SV search !!! info "Applies to GraffiTE v1.1" Verified against `v1.1.0.0` at commit `bf51777`. The [2024 paper](https://www.nature.com/articles/s41467-024-53294-2) describes v1.0, which differs in places; see [v1.0 vs v1.1](../getting-started/v1.0-vs-v1.1.md). Stage 1 turns your input data into **one non-redundant set of insertion and deletion calls relative to the reference genome**. Everything downstream operates on that set. Four backends can produce those calls, plus two ways to supply calls you already have. All but `--vcf` are **additive**: pass several and GraffiTE merges their output in one run. --- ## Which entry point do you want? ```mermaid %%{init: {"flowchart": {"nodeSpacing": 14, "rankSpacing": 26, "padding": 8}}}%% flowchart LR Q0("What do you
start from?") Q0 -->|"Genome
assemblies"| Q1("Call them
with PAV?") Q1 -->|"No"| SA["--assemblies
minimap2, svim-asm"] Q1 -->|"Yes"| PV["--pav
PAV, own container"] Q0 -->|"Unaligned
long reads"| LR["--longreads
minimap2, Sniffles2"] Q0 -->|"Aligned
long reads"| BM["--bams
Sniffles2 only"] Q0 -->|"Your own
SV calls"| Q2("One VCF per sample,
or one merged VCF?") Q2 -->|"Per sample"| SV["--svs
straight to the merge"] Q2 -->|"Merged"| VC["--vcf
skips Stage 1"] SA --> M["truvari merge
SVs.vcf"] PV --> M LR --> M BM --> M SV --> M M --> B["Stage 2 ·
TE annotation"] VC --> B classDef q fill:#8888881a,stroke:#888888; classDef s1 fill:#f5851f2e,stroke:#f5851f; classDef s2 fill:#f2523f2e,stroke:#f2523f; classDef s3 fill:#3d63c92e,stroke:#3d63c9; class Q0,Q1,Q2 q; class SA,PV,LR,BM,SV,M s1; class VC,B s2; ``` !!! warning "`--vcf` is not additive" Every other entry point above can be combined freely. `--vcf` cannot: it bypasses Stage 1, so the workflow refuses it beside any discovery flag before anything runs `main.nf:46-49`: ```text --vcf cannot be combined with --assemblies. Pass --vcf alone, or drop it and use --svs to add your own per-sample VCFs to the discovery merge. ``` If you want your own VCF *merged with* other discovery output, use `--svs` instead. The samplesheets below are examples. The column each flag reads, and what happens to a column it does not read, are in [Samplesheets](../reference/samplesheets.md). --- ## From assemblies: `--assemblies` The most common entry point, and the one the pipeline was designed around. **Samplesheet** (`sample,path`; columns are matched by header, in any order): ```csv title="assemblies.csv" path,sample /data/HG002.mat.fa.gz,HG002_mat /data/HG002.pat.fa.gz,HG002_pat ``` Each row is treated as one haploid assembly. For a diploid sample, give each haplotype its own row and its own sample name. **What runs:** 1. *(optional)* `break_scaffold`: if `--break_scaffolds` is set, `breakgaps.py` splits scaffolds into contigs at runs of at least `--break_scaffolds_min_gap` `N` (10 by default); a shorter run stays inside its contig. Use this when your input is scaffolded rather than a contig assembly. `module/main.nf:28-41` 2. `map_asm`: aligns to the reference with `minimap2 -a -x asm5 --cs -r2k -K 500M`, piped into `samtools sort -m 4G -@ 4`. The `-x` preset is `--asm_divergence`; raise it to `asm10` or `asm20` for assemblies more divergent from the reference. `-K` is `--mini_K`, and the sort memory and threads are `--stSort_m` and `--stSort_t`. With `--aligner winnowmap`, winnowmap is used instead, with a `meryl` k=19 repetitive-kmer set built at `distinct=0.9998`. `module/main.nf:51-64` 3. `svim_asm`: `svim-asm haploid --min_sv_size 100 --types INS,DEL`. **Only insertions and deletions of at least 100 bp are kept**; inversions, duplications and translocations are discarded here and never reach the rest of the pipeline. Variant IDs are prefixed with the sample name. `module/main.nf:187-188` **Published:** `out/1_SV_search/svim-asm_individual_VCFs/.vcf.gz` --- ## From assemblies with PAV: `--pav` An alternative assembly-based caller that takes all haplotypes of a sample together, rather than one haploid assembly at a time. Runs in its own container (`library://becklab/pav/pav:latest`), not the GraffiTE image. !!! note "PAV 2 is slow" `pav_asm` runs PAV 2 through its `files/docker/run` script `module/main.nf:169`, and PAV 2 is slow. We are working to add PAV 3, which is much faster, as soon as we can. !!! note "Positional samplesheet" Unlike every other GraffiTE samplesheet, the `--pav` sheet is parsed **positionally**. The first line is skipped as a header regardless of what it says; column 1 is the sample name and every remaining column is a haplotype FASTA. Column *names* are ignored. ```csv title="pav.csv" sample,hap1,hap2 HG002,/data/HG002.hap1.fa.gz,/data/HG002.hap2.fa.gz HG005,/data/HG005.hap1.fa.gz,/data/HG005.hap2.fa.gz ``` **What runs:** `pav_asm` writes a `config.json` and a tab-delimited `assemblies.tsv` with `NAME`/`HAP1`...`HAPn` columns, invokes PAV's own run script, then filters to \|SVLEN\| > 50 bp. `module/main.nf:150-171` **Published:** `out/1_SV_search/pav_individual_VCFs/sv_.vcf.gz` **Resources:** `pav_asm` defaults to **32 CPUs, 120 GB and 12 h**, more CPUs and memory than any other process. Only `--cores` overrides the CPU count; there is no `--pav_threads`. `nextflow.config:344-349` --- ## From long reads: `--longreads` **Samplesheet** (`sample,path,type`): ```csv title="longreads.csv" path,sample,type /data/HG002.hifi.fq.gz,HG002,hifi /data/HG005.ont.fq.gz,HG005,ont ``` The `type` column becomes the minimap2 preset as `map-`, so `pb`, `ont` and `hifi` give `map-pb`, `map-ont` and `map-hifi`. The one special case is `lr:hq`, which is passed through unchanged. !!! warning "`type` is not validated" Anything you write is pasted into the preset string. A typo like `hifi ` or `HiFi` produces `map-hifi ` / `map-HiFi` and minimap2 fails with an unhelpful error. Use exactly `pb`, `ont`, `hifi` or `lr:hq`. **What runs:** 1. `map_longreads`: `minimap2 -ax ` into `samtools sort`. With `--aligner winnowmap`, winnowmap with a `meryl` k=15 set. `module/main.nf:75-94` 2. `sniffles_sample_call`: per sample, `sniffles --minsvlen 100`, producing both a `.vcf` and a `.snf`. `module/main.nf:107-113` 3. `sniffles_population_call`: calls the `.snf` files from **all** samples jointly, filters to `SVTYPE` of `INS` or `DEL`, drops symbolic ``/`` alleles, and splits the result back into one VCF per sample with `bcftools +split`. `module/main.nf:129-135` **Published:** `out/1_SV_search/sniffles2_individual_VCFs/*.vcf.gz` --- ## From aligned BAMs: `--bams` Identical to `--longreads` from step 2 onward. It skips the alignment. ```csv title="bams.csv" path,sample /data/HG002.sorted.bam,HG002 ``` No `type` column: the preset only mattered for alignment, which has already happened. `--bams` and `--longreads` can be used together; both feed the same joint Sniffles2 call. --- ## From existing SV calls: `--svs` For calls you produced yourself, per sample, that you want merged with everything else. ```csv title="svs.csv" path,sample /data/HG002.manta.vcf.gz,HG002 /data/HG005.manta.vcf.gz,HG005 ``` No process runs: the VCFs go straight into the merge. GraffiTE does not re-filter them by size or type, so **filter to `INS`/`DEL` yourself** if your caller emits other SV classes; anything else will be carried into Stage 2 and annotated as if it were an indel. --- ## From a single merged VCF: `--vcf` Skips Stage 1. The VCF goes through `truvari_merge` in pass-through mode (no collapsing, IDs preserved), then directly to annotation. This is the "use GraffiTE purely as a TE annotator" entry point. ```bash nextflow run cgroza/GraffiTE -r v1.1.0.0 -latest \ --reference ref.fa --TE_library TEs.fa \ --vcf my_svs.vcf.gz --genotype false ``` --- ## Merging calls with truvari Whatever the sources, all calls converge on `truvari_merge`, which behaves in one of three ways: | Situation | Behavior | Source | |---|---|---| | `--vcf` was used | Pass-through. Decompress only; original IDs preserved. | `module/main.nf:205-212` | | Exactly one VCF reached the merge | No collapse. Original IDs preserved. | `module/main.nf:220-223` | | Two or more VCFs | Full merge and collapse, described below. | `module/main.nf:226-280` | For the multi-sample case: 1. `bcftools annotate -x INFO` strips caller-specific INFO from each input, then `bcftools merge -m none` combines them. 2. `truvari divide` shards the merged VCF, and `truvari collapse --chain -P 0.5 -p 0.5 -S -1 -k common` runs **in parallel across `task.cpus` shards**. `-P 0.5` is truvari's size-similarity threshold and `-p 0.5` its sequence-similarity threshold, so two calls collapse when their lengths are within 50 % of each other and their sequences are at least 50 % similar; `-S -1` lifts the size ceiling and `-k common` keeps the most frequently observed representative. Truvari's reference-distance default is left in place. 3. Shards are concatenated and sorted; missing genotypes are set to reference (`bcftools +setGT -t . -n 0`); `SVLEN` is recomputed as `strlen(ALT)-strlen(REF)`. 4. `shorten_ids.py` appends an incrementing integer to truvari's long IDs. **Published:** `out/1_SV_search/SVs.vcf` !!! note "Genotypes at this stage are discovery genotypes" `SVs.vcf` carries per-sample genotypes derived from *which assembly or read set the call came from*, with missing calls set to `0`. They are not the product of read-level genotyping, which happens in Stage 3. Absence in this VCF means "not called in that sample", which is not the same as "confidently absent". !!! note "Merge resources come from the svim-asm parameters" `truvari_merge` has no parameters of its own; it uses `--svim_asm_threads`, `--svim_asm_memory` and `--svim_asm_time` `nextflow.config:213-217`. Since the collapse is internally parallel, raising the svim-asm thread count speeds up the merge as well. --- ## What Stage 1 does not do - Stage 1 sets no upper size limit. The 100 bp floor comes from svim-asm and Sniffles2; on the PAV path the floor is GraffiTE's own \|SVLEN\| > 50 filter. - Stage 1 is a plain SV caller pipeline with no TE logic; all TE annotation happens in [Stage 2](annotation.md). - Only the svim-asm and Sniffles2 paths restrict calls to INS and DEL. `svim_asm` runs svim-asm with `--types INS,DEL` `module/main.nf:187`, and `sniffles_population_call` keeps only `SVTYPE == INS` or `SVTYPE == DEL` `module/main.nf:132`. `pav_asm` filters on size alone, \|SVLEN\| > 50 `module/main.nf:170`, and VCFs given with `--svs` go to the merge unfiltered, so records of any other SV type reaching the merge by those two routes end up in `SVs.vcf`. --- ## Next - [Stage 2: TE annotation](annotation.md), what happens to these calls next - [Samplesheet formats](../reference/samplesheets.md), the exact column schemas - [Parameters](../reference/parameters.md), every discovery parameter # Stage 2: TE annotation !!! info "Applies to GraffiTE v1.1" Verified against `v1.1.0.0` at commit `bf51777`. The [2024 paper](https://www.nature.com/articles/s41467-024-53294-2) describes v1.0, which differs in places; see [v1.0 vs v1.1](../getting-started/v1.0-vs-v1.1.md). Stage 2 takes the merged SV set from [Stage 1](discovery.md) (or the VCF you gave it), measures how much of each variant's sequence is repeat, and names the repeat. Variants that are not mostly repeat are discarded. The rest come out as `pangenome.vcf` with the annotation fields described in [VCF fields](../reference/vcf-fields.md), plus a filtered subset. ## What Stage 2 does ```mermaid flowchart TD IN["SVs.vcf
all INS/DEL from Stage 1"] RM["RepeatMasker
vs --TE_library"] UL["ULTRA
tandem repeats"] UN["Union of intervals
non-redundant, per variant"] F1{"total_repeat_span
> --repeat_span_cutoff
default 0.80"} DROP["discarded"] TSD["TSD search
flanking windows"] PA["polyA detection"] PG["pangenome.vcf
every surviving variant"] T{"--human ?"} TR["pangenome.trusted.vcf
conservative subset"] HU["pangenome.human.vcf
recent human MEI subset"] HK["HERV-K classifier"] IN --> RM --> UN IN --> UL --> UN UN --> F1 F1 -->|no| DROP F1 -->|yes| TSD --> PA --> PG PG --> T T -->|"no (default)"| TR T -->|yes| HU --> HK classDef out fill:#f2523f2e,stroke:#f2523f; classDef bad fill:none,stroke:#888888,stroke-dasharray:4 3; class PG,TR,HU out; class DROP bad; ``` !!! important "`--human` replaces the trusted subset" With `--human`, `pangenome.trusted.vcf` and `pangenome.presence-absence_trusted.tsv` are not written at all. The human filter is applied to `pangenome.vcf` directly, not on top of the trusted subset. This changed in v1.1; earlier versions produced `pangenome.trusted.human.vcf` as a subset of the trusted set. `module/main.nf:597-608` ## TE library `--TE_library` is a FASTA of repeat consensus sequences passed to RepeatMasker as `-lib`. It alone determines what a variant is called, so the names and classes in it are the names and classes you get back in `repeat_ids` and `matching_classes`. Two things in it matter to the annotation: - **The class in the header.** RepeatMasker reads `#class/family` after the name (`AluYa5#SINE/Alu`, `L1HS#LINE/L1`, `LTR5_Hs#LTR/ERVK`). That string is `matching_classes`. The filters test it literally, so a library that says `SINE/Alu` works with `--human` and one that says `Alu` does not. Sequences whose class is `Simple_repeat` or `Low_complexity` are ignored by the annotation, and do not count toward the TE span. `bin/annotate_vcf.R:98`, `bin/repmask_vcf.sh:114` - **The names.** `--human` matches its whitelists against `repeat_ids` with anchored prefixes (`^AluY`, `^L1HS`, `^SVA_[DEF]`, `^HERVK-int`), and the L1 and SVA rules key on the classes `LINE/L1` and `Retroposon/SVA` and on the subfamily names `SVA_A` to `SVA_F`. A library with other conventions still works for annotation, but those rules will not fire. `nextflow.config:70-81`, `bin/annotate_vcf.R:119,132-140` The Dfam human library the test set ships (`human_DFAM3.6.fasta`) follows these conventions. For another species, use a RepeatModeler or Dfam library in RepeatMasker format; see [Choosing your inputs](../getting-started/choosing-your-inputs.md). ## RepeatMasker and ULTRA `repeatmask_VCF` runs once per contig of the merged VCF. It writes each indel's sequence (the ALT of an insertion, the REF of a deletion) to `indels.fa`, named by variant ID, and runs two tools on that file. `bin/repmask_vcf.sh:38-39` **RepeatMasker**, in sensitive mode against your library, with a quarter of the task's cores as parallel jobs (RepeatMasker uses four threads per job): `bin/repmask_vcf.sh:67-75` ```bash RepeatMasker -lib ${TE_library} -s -dir repeatmasker_dir -pa $(( $(nproc) / 4 )) indels.fa ``` The paper version passed `-nolow` here. v1.0 dropped it on 2025-10-01 (`1cbebbf`) because it could produce spurious TE hits on tandem repeats; simple repeats are still masked, then set aside by the annotation. **ULTRA**, on every core, to find tandem repeats whether or not RepeatMasker called them something: `bin/repmask_vcf.sh:92` ```bash ultra --bed -t $(nproc) -o ultra_temp/ultra_out indels.fa ``` `annotate_vcf.R` then parses RepeatMasker's `.out` table. It groups fragments that share a RepeatMasker link ID into one **hit**, named after the highest-scoring fragment; that is where `n_hits`, `fragmts`, `repeat_ids`, `matching_classes`, `RM_hit_strands` and `RM_hit_IDs` come from. v1.0 used OneCodeToFindThemAll for this grouping; v1.1 reads the `.out` file directly. `bin/repmask_vcf.sh:108`, `bin/annotate_vcf.R:97-114` Two rules run on the grouped hits before they are written out: the L1 twin-priming rule that sets `L1_5PINV`, and the SVA VNTR rule that renames a hit lying inside the VNTR and moves it to `Simple_repeat`. Both are described on their own pages, [L1 5' inversions](../background/l1-5prime-inversion.md) and [SVA VNTR polymorphisms](../background/sva-vntr.md). ## Repeat-span filter Each variant gets one number, `total_repeat_span`: the fraction of its sequence covered by the union of RepeatMasker TE intervals (simple repeats and low complexity excluded) and ULTRA tandem-repeat intervals, overlaps counted once, capped at 1. `bin/repmask_vcf.sh:139-147` A variant is kept when `total_repeat_span` is strictly greater than `--repeat_span_cutoff` (default `0.80`, a fraction of the variant length). The test is applied twice with the same cutoff: once per contig, which produces `genotypes_repmasked_filtered.vcf`, and once more when the contigs are concatenated. `module/main.nf:661`, `module/main.nf:579`, `nextflow.config:61` Because the filter uses the union rather than the TE span alone, a polyA-rich Alu with a long tandem stretch passes: ULTRA covers what RepeatMasker did not. A variant that is nothing but a tandem repeat also passes the span filter, with `n_hits=0`; it is the trusted and human subsets, downstream, that require a TE hit. `total_match_span`, the v1.0 metric (TE intervals only, no ULTRA), is still written but no longer tested. ## Target site duplications For every variant that passed the filter, GraffiTE takes `--tsd_win` bp (default 30) of reference on each side of the breakpoint and the same width from each end of the variant sequence, and looks for an exact duplication of 4 to 20 bp that sits close to the junctions. A duplication that passes is written as `INFO/TSD`, as its two copies. The search runs on every variant, whatever its `n_hits`. The procedure, the scoring and the log format are in [Target site duplications](../background/tsd.md). `module/main.nf:665-709`, `nextflow.config:54` ## polyA annotation `add_polyA.py` runs on the concatenated VCF after `fix_vcf.py` has re-read the reference alleles. For a variant with exactly one hit it scans the 3' end of the variant sequence for an A-rich tail when the hit is on the `+` strand, or the 5' end for a T-rich tail when it is on `C`. It scans that end twice, with the matching copy of `TSD` trimmed off and with it left on, and calls a tail if either scan finds a window of at least 8 bp with at least 80% A (or T) ending within 5 bp of the terminus. The trim exposes a tail that sits behind the copy; the untrimmed scan keeps a tail that the TSD search reported as part of the duplication. The result is `polyA=TRUE` or `FALSE`; a variant with more than one hit gets `NA` and is not scanned. The three constants are fixed in the script. `bin/add_polyA.py:24-26,71-95,109-158`, `module/main.nf:589` ## Trusted subset Without `--human`, `concat_repeatmask` also writes `pangenome.trusted.vcf`, the records that pass this `bcftools view -i` expression, with the defaults filled in: `module/main.nf:16-18,23-26,600` ```text n_hits==1 & abs(SVLEN)>=250 & (ULTRA_TR_span<0.6 | matching_classes="Simple_repeat") & FILTER="PASS" ``` Read as three criteria: | Criterion | Parameter | Default | |---|---|---| | One RepeatMasker hit, so the variant is one element and not a nested or composite one. | none | | | Long enough to be a full-length element rather than a fragment. | `--trusted_min_svlen` | `250` bp | | Not dominated by tandem repeat, unless the SVA VNTR rule moved its hit to `Simple_repeat`. | `--trusted_max_ultra_span` | `0.6` (fraction of variant length) | The `FILTER="PASS"` clause is dropped with `--trusted_ignore_filter`, for callers that leave `FILTER` empty. `nextflow.config:62-64` !!! note "No polyA requirement" The trusted subset has no polyA requirement: with an uncurated library, an element filed under the wrong class would lose its record. The `--human` filter requires a polyA tail of Alu, L1 and SVA records, and is written with positive matches because bcftools `!~` does not negate reliably on these fields; see [VCF fields](../reference/vcf-fields.md). `module/main.nf:10-18,546-550` For human data, `--human` replaces this subset with a filter on recent subfamilies; see [Human MEIs](human-mei.md). ## Parallelism and batching Stage 2 parallelizes twice. - **By contig.** `split_repeatmask` writes one VCF per contig of the merged set and `repeatmask_VCF` runs on each, with the `repeatmasker_*` resource parameters. With variants on thousands of small scaffolds, that is thousands of tasks; `--cores` and `--repeatmasker_threads` set what each gets. RepeatMasker's own `-pa` is a quarter of that. `module/main.nf:495-508`, `nextflow.config:228-232` - **By batch of variants for the TSD search.** Each contig's variant list is split into batches of `--tsd_batch_size` (default 100 variants) and `tsd_search` runs on each batch with the `tsd_*` parameters, so a contig with 5,000 variants is 50 tasks. `tsd_report` gathers the batches back per contig. `main.nf:157-162`, `nextflow.config:60` `concat_repeatmask` then joins every contig into `pangenome.vcf`. Everything in this stage is recoverable with `-resume`, and a finished Stage 2 can be re-entered with `--RM_dir` or `--graffite_vcf`; see [Resuming and skipping work](skipping-work.md). # Stage 3.1: genotyping !!! info "Applies to GraffiTE v1.1" Verified against `v1.1.0.0` at commit `bf51777`. The [2024 paper](https://www.nature.com/articles/s41467-024-53294-2) describes v1.0, which differs in places; see [v1.0 vs v1.1](../getting-started/v1.0-vs-v1.1.md). Stage 3 takes `pangenome.vcf` from [Stage 2](annotation.md) and the read sets listed in `--genotype_with`, builds a graph with the polymorphisms as bubbles, and genotypes each sample at each bubble. On the PanGenie path some alleles never reach the graph; see [PanGenie](#pangenie). It runs by default; `--genotype false` stops after Stage 2 `main.nf:188`. --- ## What a bubble is
[figure: graph-bubble]
Each polymorphism becomes two paths between the same flanks. For an INS record the reference path skips the element and the ALT path runs through it. For a DEL record it is the other way round. Each read counts for whichever path it traverses, so reads through the TE node come from haplotypes that carry the element, whichever allele that is.
As the [home page](../index.md) says, the ALT allele means *TE present* for `INS` records and *TE absent* for `DEL` records. --- ## Read sets `--genotype_with` is a samplesheet with `sample`, `path` and `type` columns (see [Samplesheets](../reference/samplesheets.md)). The `type` column selects a Giraffe parameter preset `main.nf:189-191`: | `type` | preset | used by | |---|---|---| | `pb`, `hifi` | `hifi` | `vg giraffe --parameter-preset hifi` | | `ont` | `r10` | `vg giraffe --parameter-preset r10` | | anything else, including an empty column | `default` | `vg giraffe --parameter-preset default -i` | Two details follow from that table: - With the `default` preset, `vg giraffe` is given `-i`, so the FASTQ is read as **interleaved paired-end** `module/main.nf:837-839,844`. Supply short-read samples as a single interleaved file, not as two mate files. - PanGenie ignores the preset: it counts k-mers and never aligns `module/main.nf:748`. A `path` ending in `.bam` goes through `bam_to_fastq` first, which strips the alignment tags, name-sorts the file and converts it back to FASTQ with `samtools fastq` `main.nf:192-197`, `module/main.nf:808-824`. The alignments in the BAM are not used; only the reads are. Methylation tags in such a BAM are read separately, see [Epigenetic mapping](methylation.md). --- ## Choosing a graph method | `--graph_method` | Graph | Reads are | Genotyper | When | |---|---|---|---|---| | `pangenie` (default) | `PanGenie-index` on a merged VCF | counted as k-mers | PanGenie | k-mer counting, no alignment step; stops at launch with `--human` unless `--hervk_reconcile false` | | `giraffe` | `vg autoindex` (GBZ) | aligned with `vg giraffe` | `vg call` | short or long reads; the back end the HERV-K consolidation is validated on | | `graphaligner` | `vg construct` (GFA) | aligned with `GraphAligner` | `vg call` | long reads | | `precomputed` | supplied with `--graph` | supplied with `--graph_alignments`, or skipped with `--vcfs` | `vg call`, or none | re-genotyping an existing graph | Source: `main.nf:200-264`, `nextflow.config:38`. Anything else stops the run: ```text Unsupported --graph_method. --graph_method must be pangenie, giraffe, graphaligner or precomputed. ``` `precomputed` builds nothing itself. Without `--graph` and one of `--vcfs` or `--graph_alignments` the run stops before any process starts `main.nf:51-56`: ```text --graph_method precomputed builds nothing itself: it needs --graph (an index directory holding index.gfa and index.pb, as make_graph writes) and either --vcfs (per-sample vg call VCFs) or --graph_alignments (per-sample gaf,pack). ``` See [Resuming and skipping work](skipping-work.md) for what each of those inputs looks like. --- ## PanGenie Two processes `module/main.nf:714-771`. **`pangenie_index`**, once per run: 1. `bcftools view -G` drops the genotype columns from `pangenome.vcf`. 2. `pangenie_graph_vcf.py prepare` writes the one-sample VCF the graph is built from (a pseudo-sample `ref` carrying `1|0` at every record) and starts a table with one row per ALT allele. It gives one graph variant to records that share `CHROM`, `POS`, `REF` and `ALT`, and replaces an ID that is missing, already used, or contains a character PanGenie splits on (`;`, `,`, `:`, `=`, `|`, space). Without this, `merge_vcfs.py` stopped on such records ([issue #93](https://github.com/cgroza/GraffiTE/issues/93)) `bin/pangenie_graph_vcf.py:8-16`. 3. `bcftools sort` and `bcftools norm -m+` join records at the same position into multi-allelic sites. 4. `merge_vcfs.py merge -ploidy 2` (PanGenie's own helper, shipped in `bin/`) turns the file into the multi-sample graph VCF PanGenie reads, with an `INFO/ID` field naming the graph variant behind each ALT allele. Three kinds of allele never reach the graph, so PanGenie gives them no genotype ([issue #102](https://github.com/cgroza/GraffiTE/issues/102)): - an allele that overlaps another at the same site, because the pseudo-sample carries every allele on one haplotype `bin/merge_vcfs.py:425-430`; - the third and later alleles at one position, because step 3 joins them into one site and a diploid genotype holds two; - every allele of a site whose REF or ALT holds a base other than A, C, G or T, such as `N` `bin/merge_vcfs.py:468-470`. On the synthetic test set PanGenie genotyped 15 of 29 alleles, and the 14 it missed all held a base other than A, C, G or T; giraffe and GraphAligner genotyped all 29. 5. `pangenie_graph_vcf.py report` fills the table's `in_graph` column from that output. 6. `PanGenie-index` builds the k-mer index. The table is published as `4_Genotyping/pangenie_graph_variants.tsv`, columns `record`, `CHROM`, `POS`, `pangenome_ID`, `allele`, `graph_ID`, `in_graph`, `note`. PanGenie writes each allele's `graph_ID` to `INFO/ID` of the genotyped VCFs, so you use the table to find a `pangenome.vcf` record in them `bin/pangenie_graph_vcf.py:18-21,25`. **`pangenie`**, once per sample: `PanGenie -s -i <(zcat -f reads) -f pangenie_index`. PanGenie writes no `##contig` lines, so `samtools faidx ` and `bcftools reheader -f .fai` add the reference contigs to its header first. Without them, `bcftools norm` stops on the first record and leaves a zero-byte `.vcf.gz`. Then `bcftools norm -f ref -N -m-` splits the multi-allelic genotypes back into one record per GraffiTE variant, so that they match `pangenome.vcf` one for one when the merge transfers INFO. `-N` keeps the position, since `-f` turns on left-alignment as well as splitting and a realigned insertion matches nothing at the merge `module/main.nf:748-769`. The result is published as `4_Genotyping/_genotyping.vcf.gz` with its index. The reference is passed as a value channel; as a queue channel it held one item, and PanGenie ran for one sample and stopped `main.nf:202-205`. **Resources:** `--pangenie_threads`, `--pangenie_memory`, `--pangenie_time` for both processes `nextflow.config:248-257`. `--pangenie_memory` defaults to `32G`, so Nextflow starts only as many PanGenie tasks at once as the memory allows. Each task peaked at about 23 GB on the synthetic test set and on the chr22 example. --- ## Giraffe and GraphAligner Three processes, plus `bam_to_fastq` when needed. ### `make_graph` `module/main.nf:773-806`. `bcftools +setGT -- -t a -n u` unphases every genotype in `pangenome.vcf`, then: | method | commands | `index/` holds | |---|---|---| | `giraffe` | `vg autoindex -w sr-giraffe -w lr-giraffe`, `vg convert --vg-algorithm -f`, `vg snarls` | `index.giraffe.gbz` and its companions, `index.gfa`, `index.pb` | | `graphaligner` | `vg construct -a -m 1024`, `vg convert --vg-algorithm -f`, `vg snarls` | `index.vg`, `index.gfa`, `index.pb` | `index.gfa` is the graph as GFA, `index.pb` the snarl (bubble) decomposition `vg call` needs. The directory is published as `GraffiTE_graph/index/` and is what `--graph` takes on a later run. With `--graph`, `make_graph` does not run `main.nf:210-214`. **Resources:** `--make_graph_threads`, `--make_graph_memory` (default `40G`), `--make_graph_time` (default `6h`) `nextflow.config:258-262`. ### `graph_align_reads` `module/main.nf:826-861`, once per sample: | method | aligner | then | |---|---|---| | `giraffe` | `vg giraffe --parameter-preset -o gam --index-basename index/index [-i] -f reads` | `vg pack -Q ` and `vg convert -G` to GAF | | `graphaligner` | `GraphAligner -x vg -g index/index.gfa -f reads -a sample.gam` | same | `vg pack` builds the per-node coverage `vg call` reads, dropping alignments below `--min_mapq` (default `0`) `nextflow.config:125`. The GAF is passed through `subset_gaf.py`, which keeps the twelve standard columns plus the `cs`/`cg` difference string, then sorted by read name and gzipped. The GAM is deleted. Published as `GraffiTE_alignments/.gaf.gz` and `.pack`, which is the pair `--graph_alignments` takes on a later run. This process runs with `errorStrategy = 'finish'`: when a sample fails, the tasks already submitted or running finish before the run stops `nextflow.config:268-273`. **Resources:** `--graph_align_threads`, `--graph_align_memory`, `--graph_align_time` (default `12h`); `bam_to_fastq` uses the same three. ### `vg_call` `module/main.nf:863-879`, once per sample: ```bash vg call -a -A --threads N -R chrX:1,chrY:1 -m 2,4 -r index/index.pb -s -k .pack index/ \ | bcftools norm -m- | bcftools sort -Oz -o .vcf.gz ``` - `` is `index.giraffe.gbz` for `giraffe` and `index.gfa` otherwise, `precomputed` included. - `-a` and `-A` request a call at every snarl, reference calls and nested snarls included, so that every sample has a genotype at every bubble and the merge lines up. Check `vg call --help` for the exact wording in your vg version; the container ships vg 1.77.0. - `-m 2,4` is `--min_support`, passed to vg as its minimum allele and site support `nextflow.config:126`. - `-R chrX:1,chrY:1` sets ploidy 1 on the contigs named **exactly** `chrX` and `chrY`. Every other contig is called diploid, so a reference that names them `X` and `Y`, or `NC_000023.11`, gets diploid calls on the sex chromosomes. GraffiTE passes no other ploidy option to `vg call`. - `bcftools norm -m-` splits multi-allelic calls into one record per ALT. **Resources:** `--vg_call_threads`, `--vg_call_memory`, `--vg_call_time` (default `2h`) `nextflow.config:274-278`. --- ## Merged genotypes `merge_VCFs` `module/main.nf:881-907` takes every per-sample VCF and: 1. `bcftools merge -m none` joins them into one multi-sample VCF without creating multi-allelic records. 2. `bcftools annotate -a pangenome.vcf -c CHROM,POS,ID,REF,ALT,INFO` copies every INFO field of the matching `pangenome.vcf` record, so the genotyped records carry the repeat annotation, TSD and polyA fields. The match is on `CHROM`, `POS`, `REF` and at least one shared `ALT`; `ID` is one of the columns being *copied*, not part of the key (matching on it would need `~ID`). Allele comparison ignores case, which matters because `pangenome.vcf` carries soft-masked lowercase bases and the graph upper-cases them. A record that matches nothing keeps whatever the genotyper gave it and arrives with no annotation `module/main.nf:902`. 3. The `##GraffiTE_version` header line is added. Published as `4_Genotyping/GraffiTE.merged.genotypes.vcf.gz`. No `.tbi` is published for it: the index written earlier in the script belongs to the pre-annotation file, which is deleted. Run `tabix -p vcf` on it yourself. **Resources:** `--merge_vcf_memory` (default `10G`), `--merge_vcf_time` (default `1h`) `nextflow.config:279-283`. ## Trusted subset of the genotypes `trusted_genotypes` `module/main.nf:931-961` writes the counterpart of `pangenome.trusted.vcf` for the genotyped calls: - `4_Genotyping/GraffiTE.merged.genotypes.trusted.vcf.gz` and its `.tbi` - `4_Genotyping/GraffiTE.merged.genotypes.presence-absence_trusted.tsv`, the same schema as the discovery tables in `3_TSD_search/` Every record in it has `n_hits=1`, so every record has one repeat class. See [The trusted subset](annotation.md) for the full expression and the parameters (`--trusted_min_svlen`, `--trusted_max_ultra_span`, `--trusted_ignore_filter`), which govern both files. The expression is evaluated on `pangenome.vcf` and the genotyped calls are subset by the IDs it returns. It tests `FILTER`, and step 2 above copies `INFO` without `FILTER`, so on the merged VCF it would test the genotyper's `FILTER` instead. Not written under `--human`. There the subset of interest is the human MEI one, and [`hervk_reconcile`](human-mei.md) writes `GraffiTE.merged.genotypes.human.vcf.gz` instead. --- ## What happened to each record `genotyping_audit` writes `4_Genotyping/genotyping_record_audit.tsv`, one row per ALT allele of `pangenome.vcf`, with a `lost_at` column naming the first stage that dropped it and the counts summarized at the top of the file. | `lost_at` | meaning | |---|---| | `genotyped` | in the merged VCF under its own ID, with its annotation | | `not_in_graph` | the allele never entered the graph; see [PanGenie](#pangenie) | | `duplicate_of_record_N` | it shared `CHROM`, `POS`, `REF` and `ALT` with record `N`, which carries the call | | `no_match_in_merge` | the graph genotyped it, and the annotate step in `merge_VCFs` could not find it | | `not_genotyped` | absent from the merged VCF | `genotyped` and `annotated` are separate columns. On the PanGenie path `INFO/ID` names the graph variant behind each record, so a record that was genotyped and then missed by the annotate step is visible as `genotyped=yes, annotated=no`. The vg back ends carry no such field, the audit joins on the ID column instead, and the report says which key it used. --- With `--human`, the human subset of the merged genotypes goes through one more step, [`hervk_reconcile`](human-mei.md), which writes `GraffiTE.merged.genotypes.human.vcf.gz`. --- ## Reading a genotype | Record | `GT` | The TE is | |---|---|---| | `SVTYPE=INS` | `0/0` | absent from this sample | | `SVTYPE=INS` | `0/1`, `1/1` | present on one or both haplotypes | | `SVTYPE=DEL` | `0/0` | present (the reference carries it) | | `SVTYPE=DEL` | `0/1`, `1/1` | absent from one or both haplotypes | FORMAT fields beyond `GT` are whatever `vg call` or PanGenie wrote; see [VCF fields](../reference/vcf-fields.md). --- ## Next - [Human MEIs](human-mei.md): the HERV-K consolidation that follows genotyping under `--human` - [Epigenetic mapping](methylation.md): lifting base-modification calls onto the graph - [Resuming and skipping work](skipping-work.md): `--graph`, `--graph_alignments`, `--vcfs` - [Output files](../reference/outputs.md) # Stage 3.2: epigenetic mapping !!! info "Applies to GraffiTE v1.1" Verified against `v1.1.0.0` at commit `bf51777`. The [2024 paper](https://www.nature.com/articles/s41467-024-53294-2) describes v1.0, which differs in places; see [v1.0 vs v1.1](../getting-started/v1.0-vs-v1.1.md). !!! warning "Documented from the wiring, not from a run" This page describes what `main.nf` and the panmethyl module do when `--epigenomes` is set. It was written without a methylation run. Process behavior was read from `panmethyl/module/main.nf` at submodule commit `f0aa2c0`. With `--epigenomes`, GraffiTE reads the base-modification tags (`MM`/`ML`) of the BAMs it is genotyping, lifts each modified base onto the graph node it maps to, and reports per-allele methylation levels in the genotyped VCF. The processes come from [panmethyl](https://github.com/cgroza/panmethyl), a git submodule that must be present for `main.nf` to parse at all; see [Installation](../getting-started/installation.md). --- ## Requirements | Requirement | Why | Source | |---|---|---| | `--graph_method giraffe`, `graphaligner` or `precomputed` | the methylation branch sits inside the vg genotyping block; PanGenie has no graph alignments to lift onto | `main.nf:206,234` | | `--epigenomes` | switches the branch on | `nextflow.config:33` | | BAM entries in `--genotype_with` | `bamtags_to_BED` reads the modifications from BAM tags, and `annotate_VCF` runs only for samples that have a mods CSV; a FASTQ sample is aligned and genotyped, then dropped by the join, so its calls never reach `GraffiTE.merged.genotypes.vcf.gz` | `main.nf:244,251` | | `MM`/`ML` tags in those BAMs | what `tagtobed` extracts | `panmethyl/module/main.nf:146` | The reads of a BAM sample are also extracted to FASTQ and aligned to the graph as for any other sample ([Stage 3.1](genotyping.md)). The alignment inside the BAM is not used; `lift_epigenome` lifts the modifications through the graph alignment (`.gaf.gz`). --- ## How it works `main.nf:234-257` 1. **`index_graph`** reads `index.gfa` and lists every position of `--motif` (default `CG`) on every node, writing `node_sizes.csv`, `nodes_list.csv` and `index.csv.gz` to `out/index/` `panmethyl/module/main.nf:67-83`. 2. **`bamtags_to_BED`** runs `tagtobed` on each BAM, extracting the modification calls for `--code` (default `C+m`, 5-methylcytosine on the forward strand) into `.mods.gz` `panmethyl/module/main.nf:136-148`. 3. **`lift_epigenome`** joins the modification calls with the sample's graph alignment by read name and projects each modified base onto graph node coordinates with `lift_mods`, writing `out/lifted/.csv.gz` `panmethyl/module/main.nf:150-166`. 4. **`merge_CSV`** aggregates the per-read calls into per-node levels at the indexed motif positions, writing `out/levels/.csv.gz` `panmethyl/module/main.nf:168-187`. 5. **`annotate_VCF`** walks each allele's path (`INFO/AT`) in the sample's `vg call` VCF, averages the levels on the nodes of that path, and writes `out/annotation/.mods.vcf.gz` plus a long-format `.mods.tsv` with one row per allele `panmethyl/module/main.nf:1-15`, `panmethyl/module/resources/usr/bin/annotate_vcf.py:44-46`. It leaves a record whose genotype is missing altogether (`GT` is `.`) out of both files `panmethyl/module/resources/usr/bin/annotate_vcf.py:54-55`. The annotated per-sample VCFs replace the plain `vg call` VCFs going into `merge_VCFs`, so the merged genotypes carry the methylation FORMAT fields `main.nf:251`. `merge_VCFs` writes a missing genotype for a sample whose VCF lacks a record, and a record left out for every sample does not reach `GraffiTE.merged.genotypes.vcf.gz`. Without `--epigenomes` that record stays, with no genotype in any column `main.nf:260`, `module/main.nf:894`. ### FORMAT fields Added by `annotate_vcf.py` `panmethyl/module/resources/usr/bin/annotate_vcf.py:44-46`, one value per allele of the genotype: | Field | Type | Meaning | |---|---|---| | `PMN` | Float, `Number=.` | number of modified nucleotides with coverage on the allele's path | | `PML` | Float, `Number=.` | average modification level across the path | | `PMD` | Float, `Number=.` | average depth across the modified nucleotides | With `PML` per allele, you can compare a TE insertion's methylation against the empty site, or one haplotype's copy against the other's. --- ## Inputs | Parameter | Default | Effect | Source | |---|---|---|---| | `--epigenomes` | `false` | run the branch | `nextflow.config:33` | | `--motif` | `"CG"` | motif indexed on the graph | `nextflow.config:170` | | `--code` | `"C+m"` | modification code passed to `tagtobed` (`-T C -B C+m`) | `nextflow.config:169`, `panmethyl/module/main.nf:146` | | `--lifted` | `false` | samplesheet (`sample,path`) of already-lifted `.csv.gz` files; skips steps 2 and 3 | `main.nf:239-242` | | `--bed` | `false` | a BED of regions to project onto the graph and annotate with methylation | `main.nf:253-257` | With `--bed`, three more processes run: `BED_to_graph` projects the regions with `vg annotate`, `annotate_BED` averages levels over each region per sample into `out/annotation/.bed`, and `merge_BED` joins the samples into `out/annotation/merged_epiannoation.bed` (the filename is spelled that way in the module) `panmethyl/module/main.nf:17-65`. --- ## Outputs All relative to `--out`, and beside GraffiTE's numbered directories: | Path | Written by | |---|---| | `index/node_sizes.csv`, `nodes_list.csv`, `index.csv.gz` | `index_graph` | | `lifted/.csv.gz` | `lift_epigenome` | | `levels/.csv.gz` | `merge_CSV` | | `annotation/.mods.vcf.gz`, `.mods.tsv` | `annotate_VCF` | | `annotation/.bed`, `merged_epiannoation.bed` | `annotate_BED`, `merge_BED` (with `--bed`) | | `4_Genotyping/GraffiTE.merged.genotypes.vcf.gz` | `merge_VCFs`, now carrying `PMN`, `PML`, `PMD` | --- ## Resources The panmethyl processes have fixed allocations in `nextflow.config` rather than parameters `nextflow.config:304-343`: | Process | CPUs | Memory | Time | |---|---|---|---| | `bamtags_to_BED` | 2 | 50 GB | 6 h | | `lift_epigenome`, `merge_CSV` | 1 | 60 GB | 6 h | | `index_graph`, `annotate_VCF`, `annotate_BED`, `BED_to_graph`, `merge_BED` | 1 | 40 GB | 6 h | Change them with a `-c` config file that overrides the `withName` blocks. --- ## Limitations - PanGenie runs get no methylation: the branch needs graph alignments. - One modification code per run. - Under `--epigenomes`, every entry in `--genotype_with` must be a BAM or be listed in `--lifted`. A FASTQ entry is aligned and genotyped, then left out of the merged genotype VCF with no warning `main.nf:251,266`. - GraffiTE does not call panmethyl's own aligners (`align_giraffe`, `align_graphaligner`, `align_minigraph`) or its `lift_nucleotides` process; the alignment comes from `graph_align_reads`. # Human mobile element insertions !!! info "Applies to GraffiTE v1.1" Verified against `v1.1.0.0` at commit `bf51777`. The [2024 paper](https://www.nature.com/articles/s41467-024-53294-2) describes v1.0, which differs in places; see [v1.0 vs v1.1](../getting-started/v1.0-vs-v1.1.md). In Stage 2, `--human` writes `pangenome.human.vcf`, a subset of `pangenome.vcf` restricted to the mobile element subfamilies still active in humans, **instead of** `pangenome.trusted.vcf` `module/main.nf:597-608`. Then it runs the HERV-K (HML-2) classifier over the callset, and after genotyping it consolidates the HERV-K loci in the genotyped calls. The filter reads `pangenome.vcf` directly; none of the `--trusted_*` parameters affect it. Class-level filtering would not be enough: `SINE/Alu` alone admits AluJ and AluS elements that have not been mobile for tens of millions of years, so every class carries a subfamily whitelist. --- ## What `--human` changes
[figure: human-funnel]
Every record of pangenome.vcf goes through five gates in one bcftools view -i expression. The carve-out on the right admits HML-2 proviral records that RepeatMasker split into more than one hit.
The whole filter is one expression, assembled in Groovy and written verbatim into `3_TSD_search/human_filter_summary.txt` together with record counts and the kept and dropped `(matching_classes, repeat_ids)` combinations `module/main.nf:610-625`. Read that file first when a record you expected is missing. --- ## Subfamily whitelists A record of a class passes only when one of its `repeat_ids` matches that class's whitelist regex. The whitelists are comma-separated lists of bcftools regexes; each list is expanded into an `OR` of `repeat_ids~""` clauses `module/main.nf:538-544`. | `matching_classes` | Parameter | Default | Keeps | Source | |---|---|---|---|---| | `SINE/Alu` | `--human_alu_ids` | `^AluY` | AluY and its subfamilies (AluYa5, AluYb8, ...); drops AluS and AluJ | `nextflow.config:70` | | `LINE/L1` | `--human_l1_ids` | `^L1HS` | L1HS only; add `^L1PA2` to relax | `nextflow.config:71` | | `Retroposon/SVA` | `--human_sva_ids` | `^SVA_[DEF]` | SVA_D, SVA_E, SVA_F | `nextflow.config:72` | | `Simple_repeat` | `--human_sva_ids` | `^SVA_[DEF]` | the `SVA_*(VNTR_only)` records that Stage 2 reclassified as `Simple_repeat`; see [SVA VNTR polymorphisms](../background/sva-vntr.md) | `module/main.nf:543` | | `LTR/ERVK` | `--human_hervk_ids` | `^HERVK-int,^HERVK$,^LTR5_Hs,^LTR5A,^LTR5B` | the HML-2 internal region under either library name, and the LTR5 family; `^HERVK$` is anchored at both ends so that HERVK9-int, HERVK11-int and HERVK14-int, which are other lineages, stay out | `nextflow.config:73-81` | An empty string keeps the whole class `module/main.nf:539`. !!! warning "Two bcftools behaviors the filter depends on" `repeat_ids` and `matching_classes` are `Number=.` fields. bcftools evaluates `~` on them **element by element**, with `^` anchoring each element, which is why `repeat_ids~"^LTR5_Hs"` matches the record `SVA_A,LTR5_Hs`. bcftools regexes have **no alternation**, so each whitelist is a list rather than one `a|b` pattern. Negation with `!~` is not reliable on these fields either, which is why every clause below is phrased positively `module/main.nf:532-549`. Details in [VCF fields](../reference/vcf-fields.md). --- ## Length and tandem-repeat gates `module/main.nf:545` ```text abs(SVLEN) >= 250 and (ULTRA_TR_span < 0.6 or matching_classes = "Simple_repeat") ``` | Parameter | Default | Effect | |---|---|---| | `--human_min_svlen` | `250` bp | drops records shorter than a truncated Alu | | `--human_max_ultra_span` | `0.6` (fraction of the variant covered by ULTRA tandem repeats) | drops VNTR-dominated records, except the `Simple_repeat` ones that are VNTR by construction | Source: `nextflow.config:82-83`. The 250 bp threshold is sized for insertions and is wrong for the `SVA_*(VNTR_only)` records, whose unit is about 49 bp. On the 20-genome HPRC set it keeps 102 of 1,141, and `--human_sva_ids` removes most of the rest, so do not read the VNTR content of `pangenome.human.vcf` as a catalog. See [SVA VNTR polymorphisms](../background/sva-vntr.md#vntr-records-in-the-subsets). --- ## One element, or the HERVK + SVA carve-out `module/main.nf:550-571`. A record passes the structure gate in one of two ways. **One hit.** `n_hits == 1`, and the record is `LTR/ERVK`, `Simple_repeat`, or carries `polyA = TRUE`. Alu, L1 and SVA insertions arrive by target-primed reverse transcription and carry a polyA tail; HML-2 elements and VNTR expansions do not, so the filter requires the tail only where the mechanism leaves one. **The carve-out.** RepeatMasker often reports a small `SVA_*` hit at the end of an HML-2 provirus. That is homology, not a second element: SVA's SINE-R domain derives from the HERV-K LTR (see [HERV-K biology](../background/hervk-hml2.md)). Such records have two hits and would fail the one-hit rule, so the carve-out admits them when all of these hold: ```text n_hits <= 3 and LTR/ERVK and Retroposon/SVA and repeat_ids ~ "^HERVK-int" and abs(SVLEN) <= 10500 ``` | Parameter | Default | Source | |---|---|---| | `--hervk_sva_pair` | `true`; `false` removes the carve-out | `nextflow.config:85` | | `--hervk_pair_max_svlen` | `10500` bp, a 9,472 bp provirus plus tolerance | `nextflow.config:86` | | `--hervk_pair_max_hits` | `3`; `2` restores the pre-1.1 rule | `nextflow.config:87` | The hit count is a cap rather than an equality because RepeatMasker also splits the internal region of a degraded or rearranged provirus. In a cohort of 20 diploid human genomes, two of the three records at chr7:4,699,714 came back with three hits (`LTR5_Hs,SVA_A,HERVK-int` and `HERVK-int,SVA_A,HERVK-int`), where the third hit is that split. At `n_hits == 2` the filter kept one record of the locus and dropped the two carrying its common allele, so the locus came out as a two-unit against three-unit difference where the assemblies show three states. The other three clauses restrict the cap to HML-2 proviral records: relaxing `n_hits` on its own in the one-hit rule admits records that are an LTR5 fragment beside something else, alpha satellite and HERVK9 among them `module/main.nf:555-569`. !!! note "Carve-out matches the name `HERVK-int` only" The clause matches `repeat_ids~"^HERVK-int"` literally, not the `--human_hervk_ids` list. A library that names the internal region `HERVK`, as Dfam does, satisfies the whitelist but not the carve-out, so its split proviral records fall back on the one-hit rule. Finally, unless `--human_ignore_filter` is set, the record must carry `FILTER = PASS` from the SV caller `module/main.nf:573`. --- ## HERV-K classifier Alu, L1 and SVA records are done once they pass the filter. HML-2 records are not: a solo LTR and a full provirus at the same site are two different alleles of one locus, and a structural variant call only ever describes the difference between two of a locus's states. `hervk_annotate` works out which two, for each `LTR/ERVK` candidate in `pangenome.vcf`, and writes the result into `pangenome.human.vcf` `main.nf:171-182`, `module/main.nf:300-414`. The biology is on the [HERV-K background page](../background/hervk-hml2.md); this is the procedure. 1. **Candidates.** Every record with `LTR/ERVK` among its classes and `|SVLEN|` at most `--hervk_max_svlen` (`25000` bp). This runs over the whole of `pangenome.vcf`, not only the human subset, so that a locus split by the filter is still seen whole `module/main.nf:348-349`. 2. **Architecture.** `hervk_arch.py` re-reads the raw RepeatMasker tables (`repeat_ids` holds one name per link group, which erases the LTR-INT-LTR order), tiles the hits along the SV allele, reassigns SINE-R hits to the LTR class, and reports a signature: `ARCH_2LTR` (two complete terminal LTRs), `ARCH_PERM` (one LTR split across the two ends at permutation point `k`), `ARCH_INT_PERM` (the same split inside the internal region, point `j`), `ARCH_SOLO` (one LTR, no internal region) or `ARCH_NONE`. Written to `hervk_arch.tsv` `module/main.nf:351`, `bin/hervk_arch.py:254-356`. 3. **Reference state.** `hervk_ref_state.py` cuts a window of the reference around each candidate (`--hervk_ref_flank`, `1500` bp each side), masks it with RepeatMasker against the TE library on `task.cpus` threads, and reads off what the reference holds: `null`, `solo`, `provirus`, `partial`, or `unknown`. An element that runs into the window edge is re-masked with a 12,000 bp flank, then 24,000 and 48,000 bp if it still does. For a proviral reference it counts the units and measures their period. With `--hervk_ref_annotation` (a RepeatMasker `.out` or a BED of the reference) the classifier skips the masking step. Written to `hervk_refstate.tsv` `module/main.nf:353-362`, `bin/hervk_ref_state.py:46-72`. 4. **Classification.** `hervk_classify.py` combines the two tables and `SVLEN` into `HERVK_ALLELE_REF`, `HERVK_ALLELE`, `HERVK_EVIDENCE` and `HERVK_CLASS`. Copy-number arithmetic runs first: when `|SVLEN|` is a whole number of the reference element's period and one side has two or more units, the states are `prov_xN`. Otherwise the pair comes from the architecture, or from the reference state where the architecture is degenerate. Size alone never determines a class; `HERVK_PMAP` is a confidence under a size model, reported for information. It runs twice: over the full candidate set, writing `hervk_candidates.vcf`, `hervk_calls.tsv` and `hervk_polymorphism_summary.md`; and over the human subset, annotating its records and its presence-absence TSV `module/main.nf:371-382`, `bin/hervk_classify.py:290-391`. 5. **Loci.** `hervk_reconcile.py flag` groups records whose footprints lie within `--hervk_locus_window` (`1200` bp, one LTR plus tolerance) into loci and writes `HERVK_LOCUS`, `HERVK_LOCUS_N`, the flags `HERVK_MEI`, `HERVK_SOLO_PROV`, `HERVK_CNV`, `HERVK_MERGE_FLAG`, `HERVK_POLARITY_CONFLICT`, and the summary `HERVK_LOCUS_TYPE`. The flag step marks records and never merges them, because `pangenome.human.vcf` must keep its record structure. The locus table is `hervk_loci.tsv` `module/main.nf:384-388`, `bin/hervk_reconcile.py:95-170`. 6. **Consolidated discovery VCF.** The same loci collapsed to one multi-allelic record each, with the allele set and the counts from the assemblies, as a separate file `pangenome.human.consolidated.vcf` and a report `module/main.nf:401-407`. `pangenome.vcf` itself is read and never rewritten here: it induces the graph and must stay byte-identical `module/main.nf:295-296`. `pangenome.human.vcf` and its TSV, first written by `concat_repeatmask`, are overwritten by this process's annotated versions `module/main.nf:301`. The field-by-field definitions are in [VCF fields](../reference/vcf-fields.md). --- ## After genotyping: `hervk_reconcile` Genotyping does not preserve the HERV-K annotation, because `merge_VCFs` copies INFO from the un-annotated `pangenome.vcf`. `hervk_reconcile` restores it and consolidates the loci in the genotyped calls `main.nf:286-293`, `module/main.nf:422-493`: 1. `GraffiTE.merged.genotypes.vcf.gz` is subset to the IDs in `pangenome.human.vcf`. 2. Every `HERVK_*` INFO field is copied across from the discovery VCF with `bcftools annotate`. 3. `hervk_reconcile.py consolidate` writes one record per locus, with `HERVK_AC`/`HERVK_AN` from the graph genotypes beside `HERVK_AC_DISC`/`HERVK_AN_DISC` from the assemblies, and withholds the graph genotypes at copy-number loci (`HERVK_GT_MASKED`). At those loci the ALT path repeats sequence the reference already carries, so reads from the pre-existing copy traverse it and non-carriers acquire ALT support; the discovery genotypes come from haplotype-resolved alignments and do not have this problem `nextflow.config:103-111`. Outputs: `4_Genotyping/GraffiTE.merged.genotypes.human.vcf.gz` (indexed), `hervk_unconsolidated_records.vcf` (the member records, archived) and `hervk_reconciliation_report.md`. The full `GraffiTE.merged.genotypes.vcf.gz` is never rewritten. !!! warning "vg call genotypes only" The reconciler reads genotypes from `vg call`, which the giraffe, graphaligner and precomputed methods all use `bin/hervk_reconcile.py:431-434,772-776`. We validated it on giraffe genotypes from a cohort of 20 diploid human genomes; the synthetic test suite checks graphaligner and precomputed against giraffe. The pipeline refuses PanGenie genotypes: a `--human` run that genotypes with `--graph_method pangenie` stops at launch unless you pass `--hervk_reconcile false` `main.nf:65-71`. When the VCF comes in through `--hervk_reconcile_vcf`, `hervk_reconcile` reads the back end from the header and accepts any `vg call` VCF. ### Re-running the HERV-K stages without genotyping Graph genotyping is the expensive stage, and the HERV-K work does not depend on which run made the calls. To repeat steps 1 to 6 and the consolidation against a genotyped VCF from an earlier run `main.nf:296-314`: ```bash nextflow run cgroza/GraffiTE -r v1.1.0.0 -latest \ --RM_dir earlier/out/2_Repeat_Filtering \ --reference ref.fa --TE_library TEs.fa --human \ --genotype false \ --hervk_reconcile_vcf earlier/out/4_Genotyping/GraffiTE.merged.genotypes.vcf.gz ``` `--RM_dir` is the entry point to use here, not `--graffite_vcf`: the classifier needs the raw RepeatMasker tables, and `--graffite_vcf` skips the stage that provides them. The workflow refuses `--graffite_vcf --human` unless `--hervk_reconcile false` is also given `main.nf:58-63`. --- ## Tuning | Parameter | Default | Effect | Source | |---|---|---|---| | `--hervk_config` | `null` | JSON file of overrides for `hervk_classify.py`; keys present replace the script's `DEFAULTS`, nested dictionaries are merged key by key | `nextflow.config:66`, `bin/hervk_classify.py:58-97` | | `--hervk_strict` | `false` | drop candidates classed `other` or below `pmap_min` (`0.90`); off because dropping records hid a failure in the previous classifier | `nextflow.config:120` | | `--hervk_max_svlen` | `25000` bp | candidacy cap; a complete provirus is 9,472 bp and a 25 Mb artifact once dominated the masking cost | `nextflow.config:89` | | `--hervk_ref_flank` | `1500` bp | reference masked either side of each candidate footprint | `nextflow.config:113` | | `--hervk_locus_window` | `1200` bp | maximum footprint gap within one locus | `nextflow.config:114` | | `--hervk_ref_annotation` | `null` | precomputed reference repeat track; skips the in-pipeline masking | `nextflow.config:118` | | `--hervk_mask_graph_gt_at_cnv` | `true` | withhold graph genotypes at copy-number loci; `--hervk_mask_tandem` is the deprecated name | `nextflow.config:103-112` | | `--hervk_reconcile` | `true` | run the consolidation after genotyping | `nextflow.config:99` | | `--hervk_annotate_threads`, `_memory`, `_time` | `1`, `10G`, `12h` | resources for the masking step | `nextflow.config:132-134` | The keys `--hervk_config` can override, with their defaults, are the `DEFAULTS` dictionary at the top of `bin/hervk_classify.py`: `sigmas`, `priors`, `t_min`, `t_max`, `s_range`, `int_full_frac`, `pmap_min`, `min_hml2_bp`, `hml2_frac_min`, `cnv_period_tol`, `cnv_period_frac`, `max_svlen`, `min_solo_bp` and `min_prov_int_bp`. Unknown keys are accepted and ignored. !!! warning "`utils/HERVK.config.json` predates this classifier" The template in `utils/` carries keys from the previous, size-based classifier (`s_C`, priors named `C`/`T`/`B`/`A`/`X`, `sva_mimic_*`). None of them is read by the current script. Write your JSON against the `DEFAULTS` names above. --- ## Outputs specific to `--human` All in `3_TSD_search/` unless stated; see [Output files](../reference/outputs.md) for the directory tree and [VCF fields](../reference/vcf-fields.md) for the fields. | File | Written by | Contents | |---|---|---| | `pangenome.human.vcf` | `concat_repeatmask`, then overwritten by `hervk_annotate` | the filtered subset, with HERV-K allele states and locus flags; not an input to graph construction | | `pangenome.presence-absence_human.tsv` | same | its presence-absence table | | `human_filter_summary.txt` | `concat_repeatmask` | the filter expression, counts, kept and dropped combinations | | `hervk_candidates.vcf` | `hervk_annotate` | every HERV-K candidate in `pangenome.vcf`, annotated, whether or not the filter kept it | | `hervk_calls.tsv`, `hervk_loci.tsv` | `hervk_annotate` | the per-record calls and the locus table | | `hervk_arch.tsv`, `hervk_refstate.tsv` | `hervk_annotate` | the architecture and reference-state tables the calls rest on | | `hervk_polymorphism_summary.md` | `hervk_annotate` | counts per class and evidence | | `pangenome.human.consolidated.vcf`, `hervk_discovery_consolidation_report.md` | `hervk_annotate` | one record per locus, discovery genotypes | | `4_Genotyping/GraffiTE.merged.genotypes.human.vcf.gz` | `hervk_reconcile` | the genotyped human subset, loci consolidated | | `4_Genotyping/hervk_unconsolidated_records.vcf`, `hervk_reconciliation_report.md` | `hervk_reconcile` | the archived member records and the report | `pangenome.trusted.vcf` and its TSV are **not** written under `--human` `module/main.nf:597-601`. # Resuming and skipping work !!! info "Applies to GraffiTE v1.1" Verified against `v1.1.0.0` at commit `bf51777`. The [2024 paper](https://www.nature.com/articles/s41467-024-53294-2) describes v1.0, which differs in places; see [v1.0 vs v1.1](../getting-started/v1.0-vs-v1.1.md). Two mechanisms avoid recomputing. Nextflow's `-resume` reuses cached tasks from the same launch directory when nothing upstream changed. GraffiTE's own entry-point flags go further: they take a file an earlier run published, or that you produced elsewhere, and skip the processes that would have produced it. The flags form a ladder, from the earliest stage to the latest. --- ## Nextflow `-resume` ```bash nextflow run cgroza/GraffiTE -r v1.1.0.0 -latest -resume --assemblies assemblies.csv ... ``` Nextflow keys each task on its inputs and script, so a task reruns only when one of those changed. This works only from the directory holding the `work/` tree and `.nextflow/` of the earlier run, and only as long as `work/` has not been deleted. It is the right tool for a run that stopped part-way. The flags below are for reusing results across directories, across machines, or with different downstream parameters. --- ## Entry points | Flag | What you supply | Skips | Source | |---|---|---|---| | `--svs` | per-sample SV VCFs | the callers, not the merge | `main.nf:120-125` | | `--vcf` | one merged SV VCF | all of Stage 1 | `main.nf:148-149` | | `--RM_dir` | the `2_Repeat_Filtering/` directory of an earlier run | RepeatMasker and ULTRA | `main.nf:133-142` | | `--graffite_vcf` | a `pangenome.vcf` | all of Stages 1 and 2 | `main.nf:129,183-186` | | `--graph` | a `GraffiTE_graph/index/` directory | `make_graph` | `main.nf:210-214` | | `--graph_alignments` | per-sample GAF and pack files | `graph_align_reads` | `main.nf:223-229` | | `--vcfs` | per-sample `vg call` VCFs | alignment and `vg_call` | `main.nf:218-220` | | `--hervk_reconcile_vcf` | a genotyped VCF | genotyping, with `--genotype false` | `main.nf:296-314` | | `--genotype false` | nothing | all of Stage 3 | `main.nf:188` | ### `--svs`: your own per-sample calls **On disk:** a samplesheet with `sample` and `path` columns, one VCF per row; see [Samplesheets](../reference/samplesheets.md). **Runs:** the merge (`truvari_merge`) and everything after it. Combines with `--assemblies`, `--longreads`, `--bams` and `--pav`; the VCFs are mixed into the same merge. GraffiTE does not filter what you supply by size or type, so restrict to `INS` and `DEL` yourself `main.nf:120-125`. ### `--vcf`: one merged VCF **On disk:** one VCF or `.vcf.gz` of insertions and deletions, with sequence-resolved alleles. Split multi-allelic records first (`bcftools norm -m-`). **Runs:** `truvari_merge` in pass-through mode (decompress only, IDs preserved), then all of Stages 2 and 3 `module/main.nf:205-212`. **Cannot be combined** with any discovery flag; the run stops with a message naming the discovery flags you passed `main.nf:46-49`. Use `--svs` when you want your VCF merged with GraffiTE's own calls. ### `--RM_dir`: RepeatMasker output of an earlier run **On disk:** a directory holding one subdirectory per Stage 2 batch, each with `genotypes_repmasked_filtered.vcf` and a `repeatmasker_dir/`. That is the layout of `out/2_Repeat_Filtering/`, where the subdirectories are numbered by task `main.nf:134-136`, `module/main.nf:638-644`. ```text out/2_Repeat_Filtering/ ├── 1/ │ ├── genotypes_repmasked_filtered.vcf │ └── repeatmasker_dir/ ├── 2/ │ ... ``` **Runs:** the TSD search, polyA annotation, the repeat-span filter, the trusted or human subset, and, with `--human`, the HERV-K classifier, which reads the raw RepeatMasker tables from `repeatmasker_dir/`. `--TE_library` is still required under `--human`, because the classifier masks reference windows with it `main.nf:172-175`. This is the entry point for changing anything downstream of RepeatMasker: `--tsd_win`, a higher `--repeat_span_cutoff`, the `--trusted_*` and `--human*` parameters, or the HERV-K parameters. ### `--graffite_vcf`: a finished `pangenome.vcf` **On disk:** a `pangenome.vcf` from `3_TSD_search/`, or any VCF carrying the GraffiTE INFO fields. **Runs:** Stage 3 only, which builds the graph from the VCF as-is `main.nf:183-186`. **Cannot be combined** with `--human` unless `--hervk_reconcile false` is also given: the HERV-K consolidation after genotyping needs tables that only the skipped stage writes `main.nf:58-63`. To re-run the HERV-K steps, enter with `--RM_dir` instead. ### `--graph`: a built graph **On disk:** the `GraffiTE_graph/index/` directory of an earlier run, or any directory holding what `make_graph` writes: `index.gfa` and `index.pb`, plus `index.giraffe.gbz` and its companions for the `giraffe` method `module/main.nf:788-801`. **Runs:** alignment and calling for every sample in `--genotype_with`. Requires `--graph_method giraffe`, `graphaligner` or `precomputed`; the PanGenie path has its own index and ignores `--graph` `main.nf:206-214`. ### `--graph_alignments`: aligned reads **On disk:** a samplesheet with `sample`, `gaf` and `pack` columns pointing at the `.gaf.gz` and `.pack` files from `GraffiTE_alignments/` `main.nf:223-225`. **Runs:** `vg_call` for each row, against the graph from `--graph` or a fresh `make_graph`. Only the samples listed here are called; `--genotype_with` is still read, and every path in it must exist, but its samples are not aligned. ### `--vcfs`: called samples **On disk:** a samplesheet with `sample` and `path` columns pointing at per-sample `vg call` VCFs (`.vcf.gz` with index), as `vg_call` writes them `main.nf:218-220`. **Runs:** `merge_VCFs`, then `genotyping_audit` `main.nf:271-273`, and `trusted_genotypes` unless `--human` `main.nf:279-280`; `hervk_reconcile` under `--human`. No sample is aligned or called, but `--genotype_with` is still read, its paths must exist, and any BAM row in it still goes through `bam_to_fastq` `main.nf:197`. Pass `--graph` alongside `--vcfs`: the `make_graph` call sits outside the `--vcfs` test `main.nf:209-214`, so without it the run still builds an index at 40G for up to 6h `nextflow.config:137-139`, and unless `--epigenomes` is on nothing consumes it. `precomputed` requires `--graph` in any case `main.nf:53-56`. ### `--hervk_reconcile_vcf` with `--genotype false` **On disk:** a `GraffiTE.merged.genotypes.vcf.gz` from an earlier run, and the inputs for `--RM_dir` and `--human`. **Runs:** Stage 2 from the RepeatMasker output, `hervk_annotate`, then `hervk_reconcile` against the supplied VCF, whose back end is read from its header `main.nf:302-314`. See [Human MEIs](human-mei.md) for the command line. ### `--genotype false` Stops after Stage 2. `--genotype_with` is not read and need not exist `main.nf:188`. --- ## Combining rungs Rungs at different stages combine: `--RM_dir` with `--graph`, or `--graffite_vcf` with `--graph_alignments`. The rule is that each flag replaces the processes that would have produced its input and leaves the rest running, so any combination that leaves a connected pipeline works. The one refusal is `--vcf` beside a discovery flag. Rungs that replace the same process do not stack: `--graph_alignments` and `--vcfs` together means `--vcfs` wins, because the alignment branch is inside the `else` of the `--vcfs` test `main.nf:218-232`. # Resources and scaling !!! info "Applies to GraffiTE v1.1" Verified against `v1.1.0.0` at commit `bf51777`. The [2024 paper](https://www.nature.com/articles/s41467-024-53294-2) describes v1.0, which differs in places; see [v1.0 vs v1.1](../getting-started/v1.0-vs-v1.1.md). ## Execution profiles Pass one with `-profile` (single dash). All three run the same image, `cgroza/graffite:1.1.0.0`: `standard` and `cluster` with Apptainer, `cloud` with Docker. `nextflow.config:7-29` | Profile | Executor | Notes | |---|---|---| | `standard` | `local` | The default. Every task runs on the machine you launched from. | | `cluster` | `slurm` | One SLURM job per task. Tasks run in `$SLURM_TMPDIR` and copy results back. | | `cloud` | `awsbatch` | One AWS Batch job per task, with Docker. Needs your AWS settings in a config passed with `-c`: a Batch queue, a region and an S3 work directory. `pav_asm` cannot run. Not tested. | ```bash nextflow run cgroza/GraffiTE -r v1.1.0.0 -profile cluster ... ``` Site-specific settings (a partition, an account, a container cache) go in a config file of your own, passed with `-c site.config`. The `cluster` profile sets the executor, the container and `process.scratch`, and nothing else. It sets no queue and no retry policy, and most SLURM sites need at least a queue, plus an account where the site bills one. ```groovy title="site.config" process { queue = 'nocona' // your partition clusterOptions = '--nodes=1 --ntasks=1' // add --account=... if your site bills one errorStrategy = { task.exitStatus in [137, 140, 143] ? 'retry' : 'terminate' } maxRetries = 3 } ``` ```bash nextflow run cgroza/GraffiTE -r v1.1.0.0 -profile cluster -c site.config ... ``` 137 and 143 are SIGKILL and SIGTERM, which is how SLURM ends a job that ran past its time or memory limit, and some sites report the time limit as 140. Retrying anything else spends an allocation on a failure that will repeat. Two defaults to check against your site: - `process.scratch = '$SLURM_TMPDIR'` `nextflow.config:16` names a variable that many sites do not define. Where it is unset, set `process.scratch` to a path of your own or to `false`. - Several `*_memory` parameters default to `null`, so the pipeline requests no `--mem`. On a scheduler that needs one, set them; see [Per-process allocation](#per-process-allocation). If the container cannot write to `/tmp` on your nodes, point `--container_tmp` at a directory it can; see [Paths and `/tmp`](../getting-started/installation.md#paths-and-tmp). See also the [Nextflow executor documentation](https://www.nextflow.io/docs/latest/executor.html). ## `--cores` shortcut `--cores N` sets `cpus` to `N` for every process whose CPU count is configurable, in place of all the `*_threads` parameters, and replaces `pav_asm`'s default of `32`. Set it for a quick run on one machine; set the individual parameters for a cluster, where a lone `bcftools` step does not need the 40 CPUs an alignment does. `nextflow.config:55,184-350` Processes with a hardcoded `cpus` ignore it: `break_scaffold`, `tsd_prep`, `tsd_search`, `tsd_report`, `merge_VCFs`, `trusted_genotypes`, `genotyping_audit`, `hervk_reconcile`, and the eight methylation processes. Each gets one CPU except `bamtags_to_BED`, which gets two. `nextflow.config:185-187,233-247,279-293,299-343` ## Per-process allocation The `withName` blocks in `nextflow.config` read the `*_threads`, `*_memory` and `*_time` parameters. Memory and time are Nextflow strings such as `"40G"` and `"12h"`. A memory default of `null` means the process declares no memory requirement at all; on a scheduler that needs one, set it. `nextflow.config:128-166,184-350` | Process | CPUs | Memory | Time | Source | |---|---|---|---|---| | `break_scaffold` | `1` | none | none | `nextflow.config:185-187` | | `map_asm` | `--map_asm_threads` `1` | `--map_asm_memory` `null` | `--map_asm_time` `"3h"` | `nextflow.config:140-142,188-192` | | `map_longreads` | `--map_longreads_threads` `1` | `--map_longreads_memory` `null` | `--map_longreads_time` `"12h"` | `nextflow.config:143-145,193-197` | | `sniffles_sample_call`, `sniffles_population_call` | `--sniffles_threads` `1` | `--sniffles_memory` `null` | `--sniffles_time` `"12h"` | `nextflow.config:154-156,198-207` | | `svim_asm`, `truvari_merge` | `--svim_asm_threads` `1` | `--svim_asm_memory` `null` | `--svim_asm_time` `"12h"` | `nextflow.config:159-161,208-217` | | `pav_asm` | `32` | `--pav_memory` `"120G"` | `--pav_time` `"12h"` | `nextflow.config:157-158,344-349` | | `split_repeatmask`, `repeatmask_VCF`, `concat_repeatmask` | `--repeatmasker_threads` `1` | `--repeatmasker_memory` `"10G"` | `--repeatmasker_time` `"12h"` | `nextflow.config:151-153,218-232` | | `tsd_prep`, `tsd_search`, `tsd_report` | `1` | `--tsd_memory` `"10G"` | `--tsd_time` `"1h"` | `nextflow.config:162-163,233-247` | | `hervk_annotate` | `--hervk_annotate_threads` `1` | `--hervk_annotate_memory` `"10G"` | `--hervk_annotate_time` `"12h"` | `nextflow.config:132-134,294-298` | | `hervk_reconcile` | `1` | `--hervk_reconcile_memory` `"10G"` | `--hervk_reconcile_time` `"1h"` | `nextflow.config:135-136,299-303` | | `pangenie_index`, `pangenie` | `--pangenie_threads` `1` | `--pangenie_memory` `"32G"` | `--pangenie_time` `"12h"` | `nextflow.config:148-150,248-257` | | `make_graph` | `--make_graph_threads` `1` | `--make_graph_memory` `"40G"` | `--make_graph_time` `"6h"` | `nextflow.config:137-139,258-262` | | `bam_to_fastq`, `graph_align_reads` | `--graph_align_threads` `1` | `--graph_align_memory` `null` | `--graph_align_time` `"12h"` | `nextflow.config:129-131,263-273` | | `vg_call` | `--vg_call_threads` `1` | `--vg_call_memory` `null` | `--vg_call_time` `"2h"` | `nextflow.config:164-166,274-278` | | `merge_VCFs` | `1` | `--merge_vcf_memory` `"10G"` | `--merge_vcf_time` `"1h"` | `nextflow.config:146-147,279-283` | | `bamtags_to_BED` | `2` | `50 GB` | `6 h` | `nextflow.config:304-308` | | `lift_epigenome`, `merge_CSV` | `1` | `60 GB` | `6 h` | `nextflow.config:309-318` | | `index_graph`, `annotate_VCF`, `annotate_BED`, `BED_to_graph`, `merge_BED` | `1` | `40 GB` | `6 h` | `nextflow.config:319-343` | Three things the table does not show: - `graph_align_reads` has `errorStrategy = 'finish'`: when one sample's alignment fails, the samples already running finish and the run then stops, instead of being killed at once. `nextflow.config:272` - Every `*_threads` parameter defaults to `1`. A run with defaults aligns each assembly on one CPU. Raise `--map_asm_threads`, `--map_longreads_threads`, `--pangenie_threads` and `--graph_align_threads` first; those are the steps that scale with CPUs. - `repmask_vcf.sh` sizes RepeatMasker and ULTRA from `nproc`, not from the `cpus` you allocate. On a shared node that reports every core, request a whole node for `repeatmask_VCF` or accept the oversubscription. `bin/repmask_vcf.sh:67,92` As the v1.0 README put it, discovery scales with genome size, the merge with the number of assemblies, and genotyping with genome size and the size of the read sets. We have no measurements for RepeatMasker or the graph steps. `-with-report` writes an HTML report with the peak CPU and memory of every task. Run once with generous values, read the report, then trim. ## Large, complex and highly repetitive genomes The defaults, in particular for memory and wall time, can be too small for large, repeat-rich genomes such as maize. Nextflow's error message for a job that ran out of memory or time is often about something else, so if a run on a large genome fails with a confusing message, retry it with more of both before looking for another cause. The v1.0 README reports maize runs that completed with requests of the order of 120 h and 400 GB per process, the long-read alignment being the most demanding step; those are requested values, not measured peaks. ## Measured resource usage The measured table from the paper (human, *Cannabis sativa* and *Zea mays*, on v1.0) lives in the [README on the `main` branch](https://github.com/cgroza/GraffiTE/blob/main/README.md#resource-usage-examples). It was not re-run for v1.1. # Parameters !!! info "Applies to GraffiTE v1.1" Verified against `v1.1.0.0` at commit `bf51777`. The [2024 paper](https://www.nature.com/articles/s41467-024-53294-2) describes v1.0, which differs in places; see [v1.0 vs v1.1](../getting-started/v1.0-vs-v1.1.md). Every default on this page was read from `nextflow.config` or from the code that consumes it. The **Source** column gives the file and line so you can check. ## How to pass parameters Nextflow distinguishes two kinds of option by the number of leading dashes: | Form | Belongs to | Example | |---|---|---| | `--name value` | GraffiTE, anything on this page | `--assemblies assemblies.csv` | | `-name value` | Nextflow itself | `-resume`, `-profile cluster`, `-with-report` | ```bash nextflow run cgroza/GraffiTE -r v1.1.0.0 -latest \ -profile cluster \ --reference hs37d5.fa \ --assemblies assemblies.csv \ --TE_library human_DFAM3.6.fasta \ --genotype_with reads.csv ``` Defaults live in [`nextflow.config`](https://github.com/cgroza/GraffiTE/blob/v1.1.0.0/nextflow.config). Override them on the command line, in a local copy of the config passed with `-c`, or in a `-params-file`. !!! warning "Use underscores, not hyphens" `--genotype-with x.csv` sets a parameter named `genotypeWith` and leaves `genotype_with` at its default, `reads.csv`; `--genotype_with x.csv` sets `genotype_with`. The pipeline ignores the hyphenated form without a message and reads the default samplesheet instead, or stops because `reads.csv` is missing from the launch directory. Older versions of the README showed the hyphenated form. Verified with Nextflow 26.04.6. --- ## Required inputs Almost every run needs three parameters, and all three default to a filename rather than to `false`. If you do not set them, GraffiTE looks for `reference.fa` and `TE_library.fa` in the launch directory and stops if they are absent. | Parameter | Default | Effect | Source | |---|---|---|---| | `--reference` | `"reference.fa"` | Reference genome FASTA. Everything is called relative to it. Its existence is checked at launch. Plain or BGZF-compressed; Stage 2 re-compresses a plain gzip with bgzip. | `nextflow.config:50`, `module/main.nf:580-587` | | `--TE_library` | `"TE_library.fa"` | FASTA of repeat consensus sequences, passed to RepeatMasker as `-lib`. Needed for Stage 2, and again by the HERV-K step under `--human`, even with `--RM_dir`. | `nextflow.config:52`, `main.nf:144,175` | | `--genotype_with` | `"reads.csv"` | Samplesheet of the read sets to genotype. Read when `--genotype` is true (the default). See [Samplesheets](samplesheets.md). | `nextflow.config:43`, `main.nf:189` | --- ## Stage 1: SV search inputs Supply at least one of these unless you enter further downstream with `--vcf`, `--RM_dir` or `--graffite_vcf`. They add up: pass several and all of their calls go into one truvari merge. | Parameter | Default | Effect | Source | |---|---|---|---| | `--assemblies` | `false` | Samplesheet of genome assemblies. Each is aligned with minimap2 (or winnowmap) and called with `svim-asm haploid`, keeping `INS` and `DEL` of 100 bp or more. | `nextflow.config:45`, `module/main.nf:187` | | `--longreads` | `false` | Samplesheet of unaligned long reads. Aligned, then called per sample and jointly with Sniffles2 at `--minsvlen 100`. | `nextflow.config:44`, `module/main.nf:113,131` | | `--bams` | `false` | Samplesheet of long-read BAMs that are already aligned to `--reference`. Skips alignment and goes straight to Sniffles2. Combines with `--longreads`. | `nextflow.config:32`, `main.nf:92-101` | | `--pav` | `false` | Samplesheet of phased assemblies to call with [PAV](https://github.com/EichlerLab/pav), which runs in its own container. Keeps variants with \|SVLEN\| above 50 bp. | `nextflow.config:46`, `module/main.nf:170` | | `--svs` | `false` | Samplesheet of per-sample SV VCFs you called yourself. No caller runs; the files go straight into the merge. | `nextflow.config:47`, `main.nf:120-123` | `--vcf` is the one input that does not combine. Passing it beside any of the five above stops the run at launch with a message naming the flags. `main.nf:46-49` See [Stage 1: SV search](../guides/discovery.md) for what each backend does. ### Discovery tuning | Parameter | Default | Effect | Source | |---|---|---|---| | `--aligner` | `"minimap2"` | Aligner for assemblies and long reads. The only other accepted value is `"winnowmap"`. Any other value leaves `map_asm` and `map_longreads` with no script and the run fails. | `nextflow.config:124`, `module/main.nf:51-64` | | `--asm_divergence` | `"asm5"` | minimap2 `-x` preset for assembly alignment. Use `asm10` or `asm20` for assemblies further from the reference. Assemblies only. | `nextflow.config:123`, `module/main.nf:53` | | `--break_scaffolds` | `false` | Split each assembly into contigs at runs of at least `--break_scaffolds_min_gap` `N` before aligning. For scaffolded input. | `nextflow.config:48`, `main.nf:107-109` | | `--break_scaffolds_min_gap` | `10` | Shortest run of `N` that `--break_scaffolds` treats as a gap. A shorter run is an unknown base and stays inside its contig, so an insertion that carries one is not cut. `1` splits at every `N`. | `nextflow.config:49`, `module/main.nf:39`, `bin/breakgaps.py:14-15` | | `--mini_K` | `"500M"` | minimap2 and winnowmap `-K`, the number of bases loaded per batch. Larger is faster and uses more memory. | `nextflow.config:57`, `module/main.nf:53` | | `--stSort_m` | `"4G"` | `samtools sort -m`, memory per sort thread. Total sort memory is about `stSort_m` times `stSort_t`, on top of the aligner. | `nextflow.config:58`, `module/main.nf:54` | | `--stSort_t` | `4` | `samtools sort -@`, sort threads. Independent of the process `cpus`. | `nextflow.config:59`, `module/main.nf:54` | --- ## Stage 2: TE annotation | Parameter | Default | Effect | Source | |---|---|---|---| | `--repeat_span_cutoff` | `0.80` (fraction of variant length) | The filter keeps a variant when `total_repeat_span`, the fraction of its sequence covered by the union of RepeatMasker hits and ULTRA tandem repeats, is above this value. Applied twice: per contig chunk, and again after concatenation. | `nextflow.config:61`, `module/main.nf:579,661` | | `--tsd_win` | `30` (bp) | Width of the flank on each side of the variant, and of the variant end trimmed for the search, when looking for target site duplications. Sizes the sequences and the scoring alike. | `nextflow.config:54`, `module/main.nf:675,690` | | `--tsd_batch_size` | `100` (variants) | Variants per TSD-search task. Lower for more parallel tasks, higher for fewer. | `nextflow.config:60`, `main.nf:158` | ### Trusted subset Without `--human`, GraffiTE writes `pangenome.trusted.vcf`, a conservative subset of `pangenome.vcf`. These parameters define it. With `--human`, GraffiTE writes neither `pangenome.trusted.vcf` nor `GraffiTE.merged.genotypes.trusted.vcf.gz`, because `--human` replaces the trusted subset instead of narrowing it. `genotyping_audit` still reads all three on every genotyping run to fill the `trusted` column of `genotyping_record_audit.tsv`. | Parameter | Default | Effect | Source | |---|---|---|---| | `--trusted_min_svlen` | `250` (bp) | Minimum \|SVLEN\|. Sized for insertions; it truncates the `SVA_*(VNTR_only)` records, whose unit is about 49 bp. See [SVA VNTR polymorphisms](../background/sva-vntr.md#vntr-records-in-the-subsets). | `nextflow.config:62`, `module/main.nf:17` | | `--trusted_max_ultra_span` | `0.6` (fraction of variant length) | Maximum `ULTRA_TR_span`; rejects variants that are mostly tandem repeat. Records whose class is `Simple_repeat` bypass it. | `nextflow.config:63`, `module/main.nf:17` | | `--trusted_ignore_filter` | `false` | When true, the record no longer needs `FILTER=PASS` from the upstream caller. | `nextflow.config:64`, `module/main.nf:25` | The full expression also requires `n_hits==1`. It has no polyA requirement; the `--human` subset has one. See [Stage 2: TE annotation](../guides/annotation.md#trusted-subset). --- ## `--human` MEI subset `--human` swaps the trusted subset for one restricted to recent human mobile element subfamilies. The output is `pangenome.human.vcf`; `pangenome.trusted.vcf` is not written. It also turns on the HERV-K steps below. | Parameter | Default | Effect | Source | |---|---|---|---| | `--human` | `false` | Write `pangenome.human.vcf` instead of `pangenome.trusted.vcf`, run `hervk_annotate`, and run `hervk_reconcile` after genotyping. | `nextflow.config:65`, `main.nf:171,286` | | `--human_alu_ids` | `"^AluY"` | Alu subfamilies to keep. The default keeps every `AluY*` and drops `AluS*` and `AluJ*`. | `nextflow.config:70` | | `--human_l1_ids` | `"^L1HS"` | L1 subfamilies. Add `^L1PA2` to widen by one subfamily. | `nextflow.config:71` | | `--human_sva_ids` | `"^SVA_[DEF]"` | SVA subfamilies. The same list gates the `Simple_repeat` records that come from VNTR-only SVA variants, where it matches the consensus the VNTR sequence scored against rather than the host element's subfamily. See [SVA VNTR polymorphisms](../background/sva-vntr.md#vntr-records-in-the-subsets). | `nextflow.config:72`, `module/main.nf:542-543` | | `--human_hervk_ids` | `'^HERVK-int,^HERVK$,^LTR5_Hs,^LTR5A,^LTR5B'` | HML-2 lineage names. Both `HERVK-int` and a bare `HERVK` are listed because libraries differ; `^HERVK$` is anchored at both ends so that HERVK9, HERVK11 and HERVK14 stay out. Single-quoted in the config because `$` inside double quotes is a Groovy interpolation. | `nextflow.config:73-81` | | `--human_min_svlen` | `250` (bp) | Minimum \|SVLEN\|. Sized for insertions; it truncates the `SVA_*(VNTR_only)` records, whose unit is about 49 bp. See [SVA VNTR polymorphisms](../background/sva-vntr.md#vntr-records-in-the-subsets). | `nextflow.config:82`, `module/main.nf:545` | | `--human_max_ultra_span` | `0.6` (fraction of variant length) | Maximum `ULTRA_TR_span`; `Simple_repeat` records bypass it. | `nextflow.config:83`, `module/main.nf:545` | | `--human_ignore_filter` | `false` | When true, drop the `FILTER=PASS` requirement. | `nextflow.config:84`, `module/main.nf:573` | | `--hervk_sva_pair` | `true` | Also admit multi-hit records that pair `HERVK-int` with an SVA hit. RepeatMasker assigns part of the LTR5_Hs sequence to SVA, so it reports a provirus as two or three hits. | `nextflow.config:85`, `module/main.nf:570-571` | | `--hervk_pair_max_svlen` | `10500` (bp) | \|SVLEN\| ceiling for that carve-out: a 9472 bp provirus plus tolerance. | `nextflow.config:86`, `module/main.nf:570` | | `--hervk_pair_max_hits` | `3` (hits) | `n_hits` ceiling for the same carve-out. Three admits a provirus whose internal region RepeatMasker split in two; `2` restores the earlier behavior. | `nextflow.config:87`, `module/main.nf:555-570` | !!! note "Whitelist syntax" The `*_ids` parameters are comma-separated lists of bcftools regular expressions matched against `repeat_ids`. bcftools regexes support `^`, `$`, `.`, `*` and `[...]` and have no alternation, which is why they are lists. `~` is applied to each element of the field, so `^` anchors per element. An empty string keeps the whole class. `nextflow.config:67-69`, `module/main.nf:534-538` See [Human mobile element insertions](../guides/human-mei.md) for the assembled expression. ### HERV-K classifier and locus reconciliation All `--human` only. `hervk_annotate` runs after `concat_repeatmask` and reads the raw RepeatMasker tables; `hervk_reconcile` runs after `merge_VCFs`. | Parameter | Default | Effect | Source | |---|---|---|---| | `--hervk_config` | `null` | JSON file overriding the classifier's thresholds. Template at [`utils/HERVK.config.json`](https://github.com/cgroza/GraffiTE/blob/v1.1.0.0/utils/HERVK.config.json). | `nextflow.config:66`, `module/main.nf:324` | | `--hervk_max_svlen` | `25000` (bp) | \|SVLEN\| ceiling for HERV-K candidacy. Applied when the candidate list is built, before the reference windows are masked, so an oversized record costs no masking. | `nextflow.config:89`, `module/main.nf:348` | | `--hervk_ref_flank` | `1500` (bp) | Reference sequence masked on each side of a candidate footprint to establish the REF state. | `nextflow.config:113`, `module/main.nf:356,360` | | `--hervk_ref_annotation` | `null` | A precomputed RepeatMasker `.out` or BED for the reference. When set, the in-pipeline masking is skipped. | `nextflow.config:118`, `module/main.nf:353-356` | | `--hervk_locus_window` | `1200` (bp) | Largest gap between two record footprints that still counts as one locus: one LTR plus tolerance. | `nextflow.config:114`, `module/main.nf:388` | | `--hervk_strict` | `false` | Drop candidates classed `other` or below the confidence floor from `pangenome.human.vcf`. Off by default because dropping records hid a classifier failure before. | `nextflow.config:120`, `module/main.nf:325,378` | | `--hervk_reconcile` | `true` | Consolidate flagged HERV-K loci in the human subset of the genotyped calls. Reads `vg call` genotypes: giraffe, graphaligner or precomputed. | `nextflow.config:99`, `main.nf:286,302`, `bin/hervk_reconcile.py:434` | | `--hervk_reconcile_vcf` | `null` | Consolidate against this genotyped VCF from an earlier run instead of one produced now. Pair it with `--genotype false`. | `nextflow.config:95`, `main.nf:302-314` | | `--hervk_mask_graph_gt_at_cnv` | `true` | Withhold the graph genotypes at copy-number loci, where reads from the pre-existing reference copy give non-carriers ALT support. The calls are kept either way. | `nextflow.config:103`, `module/main.nf:442-444` | `--graffite_vcf` with `--human` and the default `--hervk_reconcile true` stops at launch, because the reconciler needs the outputs of `hervk_annotate` and that process only runs during discovery. Pass `--hervk_reconcile false`, or enter from `--RM_dir`. `main.nf:61-63` A `--human` run that genotypes with `--graph_method pangenie` also stops at launch while `--hervk_reconcile` is `true`, because the reconciler reads `vg call` genotypes and PanGenie does not produce them. Pass `--hervk_reconcile false`, or genotype with giraffe, graphaligner or precomputed. `main.nf:65-71` --- ## Stage 3: graph mapping and genotyping | Parameter | Default | Effect | Source | |---|---|---|---| | `--genotype` | `true` | Run Stage 3. Set `false` to stop after annotation. | `nextflow.config:37`, `main.nf:188` | | `--graph_method` | `"pangenie"` | One of `pangenie`, `giraffe`, `graphaligner`, `precomputed`. See below. | `nextflow.config:38`, `main.nf:200-206,263` | | `--min_mapq` | `0` | `vg pack -Q`, the lowest mapping quality a read needs to contribute coverage. Ignored by `pangenie`. | `nextflow.config:125`, `module/main.nf:845,853` | | `--min_support` | `"2,4"` | `vg call -m`, minimum support to call an allele, as `ref,alt`. Ignored by `pangenie`. | `nextflow.config:126`, `module/main.nf:874` | | `--graph_method` | Graph | Read mapping | Notes | |---|---|---|---| | `pangenie` | `PanGenie-index` on the annotated VCF | k-mer counting, no alignment | Written for short reads. The read preset, `--min_mapq` and `--min_support` do nothing. | | `giraffe` | `vg autoindex` | `vg giraffe` | Short reads interleaved (`-i`) unless the samplesheet `type` selects a long-read preset. | | `graphaligner` | `vg construct` | `GraphAligner` | Long reads. | | `precomputed` | supplied with `--graph` | supplied with `--graph_alignments`, or skipped with `--vcfs` | Builds nothing. Without `--graph` and one of the two, the run stops at launch. | `main.nf:53-56,200-232`, `module/main.nf:788-801,842-860` ### Reusing existing intermediates Each of these replaces the process that would produce it. | Parameter | Default | Effect | Source | |---|---|---|---| | `--graffite_vcf` | `false` | Skip Stages 1 and 2 and genotype this `pangenome.vcf` from an earlier run. | `nextflow.config:34`, `main.nf:183-186` | | `--vcf` | `false` | Skip Stage 1. Annotate this one merged SV VCF. Cannot be combined with a discovery flag. | `nextflow.config:35`, `main.nf:46-49,148-149` | | `--RM_dir` | `false` | Skip RepeatMasker. Reuse a `2_Repeat_Filtering/` directory whose subdirectories each hold `genotypes_repmasked_filtered.vcf` and `repeatmasker_dir/`. | `nextflow.config:36`, `main.nf:133-142` | | `--graph` | `false` | A graph index directory as `make_graph` writes it (`index.gfa`, `index.pb`, and `index.giraffe.gbz` for giraffe). Skips `make_graph`. | `nextflow.config:40`, `main.nf:210-214` | | `--graph_alignments` | `false` | Samplesheet of graph alignments (`sample,gaf,pack`). Skips `graph_align_reads`. | `nextflow.config:41`, `main.nf:223-225` | | `--vcfs` | `false` | Samplesheet of per-sample `vg call` VCFs. Skips alignment and `vg_call`. | `nextflow.config:42`, `main.nf:218-220` | See [Resuming and skipping work](../guides/skipping-work.md). --- ## Stage 3.2: epigenetic mapping (`--epigenomes`) Needs the `panmethyl` submodule and one of the `giraffe`, `graphaligner` or `precomputed` methods; the branch sits inside that block. `main.nf:12,234` | Parameter | Default | Effect | Source | |---|---|---|---| | `--epigenomes` | `false` | Lift per-read modification calls from the genotyping BAMs onto the graph and annotate the genotyped VCFs with them. | `nextflow.config:33`, `main.nf:234-258` | | `--code` | `"C+m"` | The SAM `MM`/`ML` modification code to extract. | `nextflow.config:169`, `main.nf:245` | | `--motif` | `"CG"` | Motif indexed on the graph. | `nextflow.config:170`, `main.nf:236` | | `--lifted` | `false` | Samplesheet of modification tables already lifted onto the graph; skips extraction and lifting. | `nextflow.config:171`, `main.nf:239-241` | | `--bed` | `false` | A BED file to project onto the graph and annotate with methylation levels. | `nextflow.config:172`, `main.nf:253-256` | See [Epigenetic mapping](../guides/methylation.md). --- ## Resources ### Global switches | Parameter | Default | Effect | Source | |---|---|---|---| | `--cores` | `false` | An integer here overrides the `cpus` of every process that reads a `*_threads` parameter, and the `32` of `pav_asm`. The processes fixed at one CPU are unaffected. | `nextflow.config:55,184-350` | | `--out` | `"out"` | Root of the published output tree. | `nextflow.config:53` | | `--container_tmp` | `false` | Directory bound to `/tmp` inside the container. When unset, the directory each task runs in: its directory under `work/`, or its scratch directory under `-profile cluster`. Set it when that filesystem is small, slow, or unwritable from the container. | `nextflow.config:51,181` | ### Per-process allocation Memory and time values are Nextflow strings (`"10G"`, `"12h"`). Where one parameter serves several processes, they are listed once. !!! warning "A `null` memory default means no memory directive" Seven of these default to `null`, which means the process declares no memory requirement. A scheduler that needs one, or a memory-hungry step such as `pangenie`, needs the value set. | Parameter | Default | Processes | Source | |---|---|---|---| | `--map_asm_threads` | `1` | `map_asm` | `nextflow.config:141,189` | | `--map_asm_memory` | `null` | `map_asm` | `nextflow.config:140,190` | | `--map_asm_time` | `"3h"` | `map_asm` | `nextflow.config:142,191` | | `--map_longreads_threads` | `1` | `map_longreads` | `nextflow.config:144,194` | | `--map_longreads_memory` | `null` | `map_longreads` | `nextflow.config:143,195` | | `--map_longreads_time` | `"12h"` | `map_longreads` | `nextflow.config:145,196` | | `--sniffles_threads` | `1` | `sniffles_sample_call`, `sniffles_population_call` | `nextflow.config:155,199,204` | | `--sniffles_memory` | `null` | same | `nextflow.config:154,200,205` | | `--sniffles_time` | `"12h"` | same | `nextflow.config:156,201,206` | | `--svim_asm_threads` | `1` | `svim_asm`, `truvari_merge` | `nextflow.config:160,209,214` | | `--svim_asm_memory` | `null` | same | `nextflow.config:159,210,215` | | `--svim_asm_time` | `"12h"` | same | `nextflow.config:161,211,216` | | `--pav_memory` | `"120G"` | `pav_asm` (its `cpus` is the literal `32` unless `--cores` is set) | `nextflow.config:157,346-347` | | `--pav_time` | `"12h"` | `pav_asm` | `nextflow.config:158,348` | | `--repeatmasker_threads` | `1` | `split_repeatmask`, `repeatmask_VCF`, `concat_repeatmask` | `nextflow.config:152,219,224,229` | | `--repeatmasker_memory` | `"10G"` | same | `nextflow.config:151,220,225,230` | | `--repeatmasker_time` | `"12h"` | same | `nextflow.config:153,221,226,231` | | `--tsd_memory` | `"10G"` | `tsd_prep`, `tsd_search`, `tsd_report` (one CPU each) | `nextflow.config:162,235,240,245` | | `--tsd_time` | `"1h"` | same | `nextflow.config:163,236,241,246` | | `--hervk_annotate_threads` | `1` | `hervk_annotate` | `nextflow.config:133,295` | | `--hervk_annotate_memory` | `"10G"` | `hervk_annotate` | `nextflow.config:132,296` | | `--hervk_annotate_time` | `"12h"` | `hervk_annotate` | `nextflow.config:134,297` | | `--hervk_reconcile_memory` | `"10G"` | `hervk_reconcile` (one CPU) | `nextflow.config:135,301` | | `--hervk_reconcile_time` | `"1h"` | `hervk_reconcile` | `nextflow.config:136,302` | | `--pangenie_threads` | `1` | `pangenie_index`, `pangenie` | `nextflow.config:149,249,254` | | `--pangenie_memory` | `"32G"` | same | `nextflow.config:148,250,255` | | `--pangenie_time` | `"12h"` | same | `nextflow.config:150,251,256` | | `--make_graph_threads` | `1` | `make_graph` | `nextflow.config:138,259` | | `--make_graph_memory` | `"40G"` | `make_graph` | `nextflow.config:137,260` | | `--make_graph_time` | `"6h"` | `make_graph` | `nextflow.config:139,261` | | `--graph_align_threads` | `1` | `bam_to_fastq`, `graph_align_reads` | `nextflow.config:130,264,269` | | `--graph_align_memory` | `null` | same | `nextflow.config:129,265,270` | | `--graph_align_time` | `"12h"` | same | `nextflow.config:131,266,271` | | `--vg_call_threads` | `1` | `vg_call` | `nextflow.config:165,275` | | `--vg_call_memory` | `null` | `vg_call` | `nextflow.config:164,276` | | `--vg_call_time` | `"2h"` | `vg_call` | `nextflow.config:166,277` | | `--merge_vcf_memory` | `"10G"` | `merge_VCFs`, `trusted_genotypes`, `genotyping_audit` (one CPU each) | `nextflow.config:146,281,286,291` | | `--merge_vcf_time` | `"1h"` | same | `nextflow.config:147,282,287,292` | `break_scaffold` runs on one CPU with no memory or time directive. The eight methylation processes have fixed allocations of 40 to 60 GB and 6 h that no parameter changes. See [Resources and scaling](../guides/resources.md) for the full table. `nextflow.config:185-187,304-343` !!! note "`truvari_merge` shares the svim-asm parameters" The merge has no parameters of its own. It shards the merged VCF with `truvari divide` and runs `truvari collapse` on `task.cpus` shards at once, so `--svim_asm_threads` also speeds up merging. `module/main.nf:250-257` ### RepeatMasker threading `bin/repmask_vcf.sh` ignores `task.cpus`. It passes `nproc / 4` (at least 1) to RepeatMasker's `-pa` and `nproc` to ULTRA's `-t`. On a node where `nproc` reports the host's cores rather than the cores allocated to the job, both run wider than the allocation. `bin/repmask_vcf.sh:67,75,92` --- ## Deprecated and inert | Parameter | Default | Status | Source | |---|---|---|---| | `--mammal` | `false` | Inert since v1.1. Still passed to `bin/repmask_vcf.sh`, which prints a notice and does nothing else. L1 5' inversions and SVA VNTR-only polymorphisms are always reported, through the `L1_5PINV` INFO field and the `(VNTR_only)` suffix on `repeat_ids`. The `mam_filter_1` and `mam_filter_2` fields no longer exist. | `nextflow.config:56`, `bin/repmask_vcf.sh:165-169` | | `--hervk_mask_tandem` | `null` | Old name of `--hervk_mask_graph_gt_at_cnv`. When set, its value wins over the new name. | `nextflow.config:112`, `module/main.nf:442-443` | --- ## Nextflow's own options Single dash. These are the ones you will use most. | Option | Effect | |---|---| | `-profile` | `standard` (local), `cluster` (SLURM) or `cloud` (AWS). See [Resources and scaling](../guides/resources.md). | | `-resume` | Reuse cached results from the previous run of the same pipeline in the same directory. | | `-r` | Git revision (branch, tag or commit) when running straight from GitHub. | | `-latest` | Pull the newest commit of `-r` before running. | | `-with-report` | Write an HTML execution report with per-process CPU and memory peaks. Useful for tuning the table above. | | `-with-trace` | Write a tab-delimited trace of every task. | | `-c` | Add a config file, for site-specific executor settings. | Full list in the [Nextflow CLI documentation](https://www.nextflow.io/docs/latest/cli.html). # Samplesheet formats !!! info "Applies to GraffiTE v1.1" Verified against `v1.1.0.0` at commit `bf51777`. The [2024 paper](https://www.nature.com/articles/s41467-024-53294-2) describes v1.0, which differs in places; see [v1.0 vs v1.1](../getting-started/v1.0-vs-v1.1.md). Every samplesheet is a CSV read by `main.nf`. With one exception (`--pav`) the file has a header row and columns are picked by name, so their order does not matter and extra columns are ignored. The column names below are the ones the code reads; with a misspelled header the value is empty and the run stops when it tries to open the file. !!! warning "Use absolute paths" Nextflow resolves a relative path against the directory you launched from, whatever directory the CSV sits in. --- ## `--assemblies` Columns `sample`, `path`. One row per haploid assembly; a diploid sample gets two rows with two names. `main.nf:105-106` ```csv title="assemblies.csv" sample,path HG002_mat,/data/HG002.mat.fa.gz HG002_pat,/data/HG002.pat.fa.gz ``` The `sample` name becomes the sample column of the svim-asm VCF and, after the merge, the haplotype name in `pangenome.vcf`. `module/main.nf:187-188` ## `--longreads` Columns `sample`, `path`, `type`. Unaligned reads in FASTQ or FASTA, plain or gzipped. `type` picks the minimap2 (or winnowmap) preset: it becomes `map-`, except `lr:hq` which is passed as is. So `ont`, `hifi` and `pb` are the usual values. `main.nf:87-88`, `module/main.nf:75-78` ```csv title="longreads.csv" sample,path,type HG002,/data/HG002.hifi.fastq.gz,hifi HG005,/data/HG005.ont.fastq.gz,ont ``` ## `--bams` Columns `sample`, `path`. Long reads already aligned to `--reference`, coordinate-sorted; the process indexes the BAM before calling. `main.nf:93-94`, `module/main.nf:107` ```csv title="bams.csv" sample,path HG002,/data/HG002.hifi.sorted.bam ``` ## `--pav` No header names are read. The first line is skipped as a header, the first column is the sample name, and every further column is one haplotype FASTA of that sample. All haplotypes of a sample share one row. `main.nf:115-116`, `module/main.nf:154-166` ```csv title="pav.csv" sample,hap1,hap2 HG002,/data/HG002.mat.fa.gz,/data/HG002.pat.fa.gz ``` ## `--svs` Columns `sample`, `path`. Per-sample SV VCFs from your own caller, bgzip-compressed and named `*.vcf.gz`: the merge indexes each file with `tabix` and then loops over `*.vcf.gz`. `sample` is read but not used. `main.nf:120-123`, `module/main.nf:215-228` ```csv title="svs.csv" sample,path HG002,/data/HG002.sv.vcf.gz ``` Nothing on this path filters by `SVTYPE`, so anything other than insertions and deletions reaches Stage 2. Of the other discovery backends, Sniffles2 and svim-asm keep `INS` and `DEL` only; `pav_asm` filters on `|SVLEN| > 50` alone, so PAV records of any other type above that size reach the merge as well. `module/main.nf:132,170,187` ## `--genotype_with` Columns `sample`, `path`, `type`. One read set per row, FASTQ (plain or gzipped) or BAM. `type` maps to a read preset and anything else, including an empty value, means short reads: | `type` | Preset | Effect | |---|---|---| | `pb`, `hifi` | `hifi` | `vg giraffe --parameter-preset hifi` | | `ont` | `r10` | `vg giraffe --parameter-preset r10` | | anything else | `default` | `vg giraffe` with `-i`, interleaved paired-end short reads | `main.nf:189-191`, `module/main.nf:837-844` `pangenie` and `graphaligner` ignore the preset. A `.bam` path is converted to FASTQ first by `bam_to_fastq`; with `--epigenomes`, GraffiTE also reads modification tags from it. `main.nf:192-197,244` ```csv title="reads.csv" sample,path,type HG002,/data/HG002.illumina.interleaved.fastq.gz, HG005,/data/HG005.hifi.bam,hifi ``` ## `--vcfs` Columns `sample`, `path`. Per-sample `vg call` VCFs from an earlier run, bgzipped with the `.vcf.gz` suffix, because `merge_VCFs` collects every `*vcf.gz` it is given. `path` has to be a glob such as `HG002.vcf.gz*`: the code sorts the files it matches, and a plain path is taken apart into its directory components instead (checked with Nextflow 26.04.6). The glob also matches the `.tbi` index. `main.nf:218-220`, `module/main.nf:893` ```csv title="vcfs.csv" sample,path HG002,/data/earlier_run/HG002.vcf.gz* ``` ## `--graph_alignments` Columns `sample`, `gaf`, `pack`. The two files `graph_align_reads` publishes to `GraffiTE_alignments/` for each sample. Needs `--graph` pointing at the index they were made against. `main.nf:223-225`, `module/main.nf:827-833` ```csv title="graph_alignments.csv" sample,gaf,pack HG002,/data/earlier_run/GraffiTE_alignments/HG002.gaf.gz,/data/earlier_run/GraffiTE_alignments/HG002.pack ``` ## `--lifted` Columns `sample`, `path`. Modification tables already lifted onto the graph, as `lift_epigenome` writes them. Skips `bamtags_to_BED` and `lift_epigenome`. `main.nf:239-241` ```csv title="lifted.csv" sample,path HG002,/data/earlier_run/lifted/HG002.csv.gz ``` # Output files !!! info "Applies to GraffiTE v1.1" Verified against `v1.1.0.0` at commit `bf51777`. The [2024 paper](https://www.nature.com/articles/s41467-024-53294-2) describes v1.0, which differs in places; see [v1.0 vs v1.1](../getting-started/v1.0-vs-v1.1.md). ## Directory layout Everything below is relative to `--out` (default `out/`). Every `publishDir` copies rather than links, so the tree stands on its own once `work/` is deleted. ```text out/ ├── 1_SV_search/ │ ├── SVs.vcf ← truvari_merge │ ├── svim-asm_individual_VCFs/.vcf.gz ← svim_asm │ ├── sniffles2_individual_VCFs/*.vcf.gz ← sniffles_population_call │ └── pav_individual_VCFs/sv_.vcf.gz ← pav_asm ├── 2_Repeat_Filtering/ │ └── / ← repeatmask_VCF, one dir per contig │ ├── genotypes_repmasked_filtered.vcf │ ├── genotypes_repmasked.vcf.gz │ ├── repeatmasker_dir/ │ ├── ultra_out.bed ultra_out.span ultra_out.stats │ ├── total_repeat_span.tsv union.bp combined.stats │ └── vcf_annotation.bak.txt ├── 3_TSD_search/ ← concat_repeatmask, then hervk_annotate │ ├── pangenome.vcf │ ├── pangenome.presence-absence.tsv │ ├── pangenome.trusted.vcf (default; not written with --human) │ ├── pangenome.presence-absence_trusted.tsv (default; not written with --human) │ ├── pangenome.human.vcf (--human only) │ ├── pangenome.presence-absence_human.tsv (--human only) │ ├── pangenome.human.consolidated.vcf (--human only) │ ├── human_filter_summary.txt (--human only) │ ├── hervk_polymorphism_summary.md (--human only) │ ├── hervk_loci.tsv hervk_calls.tsv (--human only) │ ├── hervk_arch.tsv hervk_refstate.tsv (--human only) │ ├── hervk_candidates.vcf (--human only) │ ├── hervk_discovery_consolidation_report.md (--human only) │ ├── TSD_summary.txt │ └── TSD_full_log.txt ├── 4_Genotyping/ │ ├── pangenie_graph_variants.tsv ← pangenie_index, pangenie method only │ ├── _genotyping.vcf.gz(.tbi) ← pangenie, pangenie method only │ ├── genotyping_record_audit.tsv ← genotyping_audit │ ├── GraffiTE.merged.genotypes.vcf.gz ← merge_VCFs │ ├── GraffiTE.merged.genotypes.trusted.vcf.gz(.tbi) (not with --human) ← trusted_genotypes │ ├── GraffiTE.merged.genotypes.presence-absence_trusted.tsv (not with --human) │ ├── GraffiTE.merged.genotypes.human.vcf.gz(.tbi) (--human only) ← hervk_reconcile │ ├── hervk_unconsolidated_records.vcf (--human only) │ └── hervk_reconciliation_report.md (--human only) ├── GraffiTE_graph/index/ ← make_graph, giraffe/graphaligner only └── GraffiTE_alignments/ ← graph_align_reads, giraffe/graphaligner only ``` Which subset appears depends on the entry point and the graph method: ```mermaid flowchart LR A["Stage 1"] --> D1["1_SV_search/"] B["Stage 2"] --> D2["2_Repeat_Filtering/"] B --> D3["3_TSD_search/"] C["Stage 3"] --> D4["4_Genotyping/"] C -.->|"giraffe · graphaligner"| D5["GraffiTE_graph/"] C -.->|"giraffe · graphaligner"| D6["GraffiTE_alignments/"] classDef s1 fill:#f5851f2e,stroke:#f5851f; classDef s2 fill:#f2523f2e,stroke:#f2523f; classDef s3 fill:#3d63c92e,stroke:#3d63c9; classDef always fill:#8888881a,stroke:#888888; classDef maybe fill:none,stroke:#888888,stroke-dasharray:4 3; class A s1; class B s2; class C s3; class D1,D2,D3,D4 always; class D5,D6 maybe; ``` !!! note "Main output files" For most users the file that matters is `3_TSD_search/pangenome.vcf` (all annotated polymorphisms) or its filtered companion: `pangenome.trusted.vcf` by default, or `pangenome.human.vcf` with `--human`. If you genotyped, it is `4_Genotyping/GraffiTE.merged.genotypes.vcf.gz`, which carries the same annotations plus per-sample genotypes. !!! note "Reading HERV-K with `--human`" GraffiTE can emit several VCF records for one HERV-K locus: two breakpoints for one insertion, or a deletion and an insertion describing opposite directions of the same event. The `.consolidated.` and `.human.` VCFs hold each locus as one multi-allelic record. Read those for HERV-K. The files they are built from stay as they are, because the discovery VCF induces the graph and the merged genotypes VCF is the native record of what `vg call` did. | want | read | |---|---| | HERV-K loci before genotyping | `3_TSD_search/pangenome.human.consolidated.vcf` | | HERV-K loci with genotypes | `4_Genotyping/GraffiTE.merged.genotypes.human.vcf.gz` | | every other TE family | `pangenome.human.vcf` or `GraffiTE.merged.genotypes.vcf.gz` | `INFO/HERVK_MEI` marks the loci where a null allele segregates. Those are the ones comparable to an *Alu*, L1 or SVA insertion. See [VCF fields](vcf-fields.md). ## 1_SV_search Stage 1 output. Present whenever discovery ran, and with `--vcf`, where the directory holds only `SVs.vcf`. Absent with `--RM_dir` and `--graffite_vcf`, which skip the merge. | File | Contents | Source | |---|---|---| | `SVs.vcf` | The merged, non-redundant set of SVs from every caller and sample, sorted, with `SVLEN` recomputed from the alleles and IDs shortened to `_`. Missing genotypes are set to `0`. This is the file Stage 2 annotates. With `--vcf` or a single input VCF, it is a copy of the input. | `module/main.nf:193,201,278-280` | | `svim-asm_individual_VCFs/.vcf.gz` | One file per assembly: svim-asm calls of at least 100 bp, insertions and deletions only, sorted. | `module/main.nf:175,187-188` | | `sniffles2_individual_VCFs/.vcf.gz` | One file per read set, split from the Sniffles2 population call of at least 100 bp, insertions and deletions only, symbolic alleles dropped. | `module/main.nf:118,131-135` | | `pav_individual_VCFs/sv_.vcf.gz` | One file per sample: PAV calls with `abs(SVLEN)` above 50 bp. PAV's own filters (`TRIM`, `COMPOUND`) stay in `FILTER`. | `module/main.nf:141,171` | The `--svs` input is passed straight to the merge and is not copied here. ## 2_Repeat_Filtering One directory per contig of `SVs.vcf`, numbered by task index, so `1/` is not necessarily chromosome 1. Each holds the RepeatMasker and ULTRA run on that contig's variants and the intermediate tables the span filter was computed from. The whole directory is what `--RM_dir` reads back in to skip Stage 2's masking step. `module/main.nf:638-652`, `main.nf:133-142` | File | Contents | Source | |---|---|---| | `genotypes_repmasked_filtered.vcf` | The contig's records that passed `total_repeat_span > --repeat_span_cutoff`, with the repeat annotation fields. The TSD search reads this file. | `module/main.nf:661` | | `genotypes_repmasked.vcf.gz` | The same records before the span filter, so you can inspect a dropped variant. | `module/main.nf:660` | | `repeatmasker_dir/` | RepeatMasker's own output on `indels.fa`, the FASTA of every variant's inserted or deleted sequence: `indels.fa.out` is the table `annotate_vcf.R` parses, and the `RM_hit_IDs` field points into its last column. | `bin/repmask_vcf.sh:37-39,47-48,75,77,108` | | `ultra_out.bed` | ULTRA's tandem repeat intervals, one BED line per repeat, the variant ID as the sequence name. | `bin/repmask_vcf.sh:92-98` | | `ultra_out.span` | Non-redundant tandem-repeat bases per variant. | `bin/repmask_vcf.sh:102-104` | | `ultra_out.stats` | Variant ID, `ULTRA_TR`, `ULTRA_TR_span`. | `bin/repmask_vcf.sh:135-137` | | `union.bp` | Bases covered by the union of TE hits and ULTRA intervals, per variant. | `bin/repmask_vcf.sh:142-144` | | `total_repeat_span.tsv` | Variant ID and `total_repeat_span`. | `bin/repmask_vcf.sh:145-147` | | `combined.stats` | Variant ID, `ULTRA_TR`, `ULTRA_TR_span`, `total_repeat_span`, one row per variant with a hit in either tool. | `bin/repmask_vcf.sh:151-152` | | `vcf_annotation.bak.txt` | The annotation table handed to `bcftools annotate`, one row per variant, before compression. | `bin/repmask_vcf.sh:156-162` | ## 3_TSD_search Stage 2's deliverables. `concat_repeatmask` writes everything except the `hervk_*` files and the consolidated VCF, then, under `--human`, `hervk_annotate` writes its own files into the same directory and overwrites `pangenome.human.vcf` and `pangenome.presence-absence_human.tsv` with annotated versions. `module/main.nf:511-527`, `module/main.nf:301-321` | File | Contents | Source | |---|---|---| | `pangenome.vcf` | Every variant from every contig that passed the span filter, with REF and ALT re-read from the reference, `TSD` and `polyA` added, and the caller's `FILTER` kept. This file induces the pangenome graph, so nothing downstream modifies it. | `module/main.nf:577-592` | | `pangenome.trusted.vcf` | The records of `pangenome.vcf` that pass the trusted-subset expression in [Stage 2](../guides/annotation.md). Not written under `--human`. | `module/main.nf:16-25,597-601` | | `pangenome.human.vcf` | `--human` only. The records that pass the MEI filter in [Human MEIs](../guides/human-mei.md), with the HERV-K classifier fields and locus flags added by `hervk_annotate`. `make_graph` and `pangenie_index` take `pangenome.vcf`, not this file, so the graph is the same under `--human`. `hervk_reconcile` reads this file to consolidate HERV-K loci in the genotyped VCF. | `module/main.nf:607`, `module/main.nf:312,384-388`, `main.nf:167,201,213,288` | | `pangenome.human.consolidated.vcf` | `--human` only. `pangenome.human.vcf` with each HERV-K locus collapsed onto one multi-allelic record, genotypes taken from the assemblies. | `module/main.nf:401-407` | | `pangenome.presence-absence.tsv`, `..._trusted.tsv`, `..._human.tsv` | Flat tables of the matching VCF; see [Presence-absence TSVs](#presence-absence-tsvs). | `module/main.nf:595,601,608` | | `human_filter_summary.txt` | `--human` only. The exact `bcftools view -i` expression that was applied, record counts before and after, and the kept and dropped `(matching_classes, repeat_ids)` combinations with their counts. | `module/main.nf:610-625` | | `TSD_summary.txt` | One row per variant searched, the best duplication found and whether it passed. Columns are in [Target site duplications](../background/tsd.md). | `module/main.nf:575`, `bin/TSD_Match_v2.sh:146` | | `TSD_full_log.txt` | The full search log: both fragments with a ruler, every candidate duplication and the chosen one, per variant. | `module/main.nf:576`, `bin/TSD_Match_v2.sh:156` | | `hervk_candidates.vcf` | `--human` only. The HERV-K candidates among the `LTR/ERVK` records of `pangenome.vcf` up to `--hervk_max_svlen`, classified, with their discovery genotypes. Wider than the human subset: this file has every member of a locus the `--human` filter split. | `module/main.nf:349-377` | | `hervk_calls.tsv` | `--human` only. The per-candidate call table: id, position, `SVLEN`, class, allele states, evidence, `k`, `j`, reference units and period, reference state, `lambda`, `nu`, coverage, `pmap`, architecture, notes. | `bin/hervk_classify.py:478-480` | | `hervk_loci.tsv` | `--human` only. One row per locus: id, interval, member records, how many are in the human subset and which are not, reference state, allele set, locus type, the three flags, per-record class, evidence and `k`, architecture, and flags such as `LOCUS_SPLIT_BY_HUMAN_FILTER`. | `bin/hervk_reconcile.py:127-131` | | `hervk_arch.tsv` | `--human` only. The architecture read from the RepeatMasker fragments of each candidate: signature, permutation points, LTR family, termini, fragment count, LTR, internal and other bp, strand, internal gaps, architecture string. | `bin/hervk_arch.py:399-401` | | `hervk_refstate.tsv` | `--human` only. What the masked reference window holds at each candidate: state, unit count and period, LTR and internal bp, distance, the reference element's interval, flags, architecture. | `bin/hervk_ref_state.py:382-384` | | `hervk_polymorphism_summary.md` | `--human` only. Counts per class and per evidence type, the permutation points seen, and the unresolved candidates. | `bin/hervk_classify.py:649` | | `hervk_discovery_consolidation_report.md` | `--human` only. Per locus, the alleles and counts after consolidating the assembly genotypes, and the loci that were skipped and why. | `bin/hervk_reconcile.py:1249` | ## 4_Genotyping Stage 3's deliverables, present when `--genotype` is true (the default). | File | Contents | Source | |---|---|---| | `pangenie_graph_variants.tsv` | PanGenie method only. One row per ALT allele of `pangenome.vcf`: `record`, `CHROM`, `POS`, `pangenome_ID`, `allele`, `graph_ID`, `in_graph`, `note`. `graph_ID` is what PanGenie writes to `INFO/ID` of the genotyped VCFs; `in_graph=no` marks alleles `merge_vcfs.py` left out of the graph. | `module/main.nf:715,724,727-730`, `bin/pangenie_graph_vcf.py:25` | | `_genotyping.vcf.gz`, `.tbi` | PanGenie method only. Each read set's genotypes, split to one ALT per record so they match `pangenome.vcf` one for one. | `module/main.nf:737,744,748,766-769` | | `GraffiTE.merged.genotypes.vcf.gz` | All read sets merged into one VCF, one column per sample, with every INFO field of `pangenome.vcf` copied onto the matching record by position and alleles. The headline genotyped file. No `.tbi` is published for it; run `tabix -p vcf` on it before random access. | `module/main.nf:882-904` | | `GraffiTE.merged.genotypes.trusted.vcf.gz`, `.tbi` | Not written under `--human`. The records of the merged genotypes whose `pangenome.vcf` counterpart passes the trusted-subset expression, so every record has one repeat class. Subset by ID, because the expression tests `FILTER` and `merge_VCFs` does not transfer it. | `module/main.nf:931-961` | | `GraffiTE.merged.genotypes.presence-absence_trusted.tsv` | Not written under `--human`. Flat table of the file above, same schema as the discovery TSVs; see [Presence-absence TSVs](#presence-absence-tsvs). | `module/main.nf:931-961` | | `genotyping_record_audit.tsv` | One row per ALT allele of `pangenome.vcf`, saying whether the graph genotyped it, whether the annotation reached it, and which stage dropped it (`lost_at`). Counts summarized in `#` lines at the top. | `module/main.nf:909-929` | | `GraffiTE.merged.genotypes.human.vcf.gz`, `.tbi` | `--human` only. The human subset of the merged genotypes, HERV-K annotation carried over from `pangenome.human.vcf`, and each HERV-K locus consolidated onto one record. Graph genotypes at copy-number loci are withheld unless `--hervk_mask_graph_gt_at_cnv false`. | `module/main.nf:423,434-435,449-491` | | `hervk_unconsolidated_records.vcf` | `--human` only. The member records each consolidated record was built from, as they were before consolidation. | `module/main.nf:436,487` | | `hervk_reconciliation_report.md` | `--human` only. Per locus, alleles, `AC`, `AN` against `2N`, resolved and partial samples; then the loci with ploidy exceeded, with `AN` below `2N`, and skipped. | `bin/hervk_reconcile.py:1249` | The per-sample `vg call` VCFs of the giraffe and graphaligner methods are not published; you can pass them back with `--vcfs` only if you keep them from `work/`. ## GraffiTE_graph Giraffe and graphaligner methods only, unless `--graph` pointed at an existing directory. The `index/` directory is what `--graph` takes. `module/main.nf:773-806`, `main.nf:210-212` | File | Method | Contents | Source | |---|---|---|---| | `index/index.giraffe.gbz` | giraffe | The GBZ graph and indexes from `vg autoindex`. | `module/main.nf:790-792` | | `index/index.gfa` | both | The graph in GFA. `vg call` reads it on the graphaligner path, and the methylation module indexes it. | `module/main.nf:791,799` | | `index/index.pb` | both | The snarl decomposition `vg call` needs. | `module/main.nf:792,800` | | `index/index.vg` | graphaligner | The `vg construct` graph the GFA was converted from. | `module/main.nf:798` | ## GraffiTE_alignments Giraffe and graphaligner methods only, unless you supplied them with `--graph_alignments`. One pair per read set, which `--graph_alignments` takes back. `module/main.nf:827-835`, `main.nf:223-225` | File | Contents | Source | |---|---|---| | `.gaf.gz` | The alignments in GAF, reduced to the twelve standard columns plus the `cs` or `cg` tag, sorted by read name. | `module/main.nf:846,854`, `bin/subset_gaf.py` | | `.pack` | The `vg pack` coverage over the graph, alignments below `--min_mapq` excluded, which `vg call` genotypes from. | `module/main.nf:845,853` | ## Presence-absence TSVs `pangenome.vcf`, `pangenome.trusted.vcf` and `pangenome.human.vcf` each have a flat companion written by `vcf_to_pa_tsv.py`. The first 21 columns are fixed, then one column per sample: ```text CHROM POS END ID SVTYPE SVLEN n_hits match_lengths repeat_ids matching_classes fragmts RM_hit_strands RM_hit_IDs total_match_length total_match_span L1_5PINV ULTRA_TR ULTRA_TR_span total_repeat_span TSD polyA ... ``` A missing INFO field is written as `NA`. The sample columns say whether the **element** is present, whichever way the VCF record points: | `SVTYPE` | genotype carries an ALT allele | all REF | missing | |---|---|---|---| | `INS` | `1` | `0` | `NA` | | `DEL` | `0` | `1` | `NA` | A `1` therefore always means the TE is in that sample. Under `--human`, the `_human.tsv` is rewritten by `hervk_annotate` with the classifier's columns appended. `bin/vcf_to_pa_tsv.py:4-15,42-75`, `module/main.nf:379-381` ## What is not published These stay in `work/` and vanish with it: - The alignments of Stage 1: `map_asm` and `map_longreads` BAMs, and the `.snf` files of `sniffles_sample_call`. - `truvari_merge`'s intermediates: the stripped and merged inputs, the shards, the collapsed shards. - The per-contig split of `SVs.vcf` and the TSD working files (`indels.fa`, the flank and end FASTAs, per-batch summaries). - The PanGenie index (`pangenie_index/`) and the multi-allelic graph VCF it was built from. - The per-sample `vg call` VCFs, the `.gam` alignments (deleted inside the task), and the FASTQ converted from a BAM in `--genotype_with`. - `merge_VCFs`' sorted copy of `pangenome.vcf` and its uncompressed merge. `nextflow run -with-report` and `-with-trace` are the way to see resource use per task; nothing in `out/` records it. # VCF fields !!! info "Applies to GraffiTE v1.1" Verified against `v1.1.0.0` at commit `bf51777`. The [2024 paper](https://www.nature.com/articles/s41467-024-53294-2) describes v1.0, which differs in places; see [v1.0 vs v1.1](../getting-started/v1.0-vs-v1.1.md). Every table below gives the `Number` and `Type` from the header line the code writes, and the **Source** column names the line that writes it. Fields are grouped by the stage that adds them. Which files carry which group is in [Output files](outputs.md). ## Reading a GraffiTE VCF record GraffiTE writes standard VCF 4.2 with sequence-resolved alleles. One record from the `pangenome.human.vcf` of a three-sample PAV run, the ALT sequence shortened. Three input VCFs take the truvari collapse path, which strips every upstream INFO field before the merge and puts only `SVLEN` back, so no PAV INFO field survives. PAV's ID is in the ID column. `module/main.nf:228,279` ```text chr1 18081 chr1-18082-INS-315_10 t tAGAAGGAATAAGACGGGCCGGGT... . PASS SVLEN=315;NumCollapsed=4;CollapseId=5.0; n_hits=1;fragmts=1;match_lengths=298;repeat_ids=AluY;matching_classes=SINE/Alu; RM_hit_strands=+;RM_hit_IDs=72004;L1_5PINV=None;total_match_length=300; total_match_span=0.949367;ULTRA_TR=37;ULTRA_TR_span=0.117089; total_repeat_span=0.949367;polyA=TRUE GT 1|0 0/0 1|0 ``` | Column | What GraffiTE puts there | Source | |---|---|---| | `ID` column | The caller's ID, with `_` appended after the truvari merge (`n` is the record's zero-based position in `SVs.vcf`, so the first record gets `_0`): `chr1-18082-INS-315_10` above is PAV's `chr1-18082-INS-315`, the eleventh record in the merge. svim-asm IDs are prefixed with the assembly name (`HG002_mat.svim_asm.INS.12`). With `--vcf` the IDs pass through unchanged. An ID of 50 characters or more stops Stage 2. | `module/main.nf:188,280`, `bin/shorten_ids.py:21`, `bin/repmask_vcf.sh:42-45` | | `REF` and `ALT` columns | Sequence-resolved. For an insertion `REF` is the anchor base and `ALT` is that base plus the inserted sequence; for a deletion `REF` is the anchor base plus the deleted reference interval, re-read from the reference FASTA, and `ALT` is the anchor base. Symbolic `` and `` records from Sniffles2 are dropped in Stage 1. | `bin/fix_vcf.py:33-44`, `module/main.nf:132` | | `FILTER` column | Whatever the SV caller wrote. GraffiTE defines no FILTER of its own; see [Fields inherited from upstream callers](#fields-inherited-from-upstream-callers). | `module/main.nf:591` | | Sample columns | In `pangenome.vcf`, one column per Stage 1 sample, holding the genotype its caller wrote (PAV writes phased diploid calls, as above). A genotype missing after the merge is set to `0`. In `GraffiTE.merged.genotypes.vcf.gz`, one column per read set from `--genotype_with`. | `module/main.nf:278`, `module/main.nf:894` | `concat_repeatmask`, `hervk_annotate` and `merge_VCFs` each write a `##GraffiTE_version=` line, holding the content of `version.txt` (`1.1.0`), immediately after `##fileformat`. Between them they stamp `pangenome.vcf`, `pangenome.trusted.vcf`, `pangenome.human.vcf`, `pangenome.human.consolidated.vcf` and `GraffiTE.merged.genotypes.vcf.gz`; `bcftools view` and `hervk_classify.py` copy the header whole, so `GraffiTE.merged.genotypes.trusted.vcf.gz` and `hervk_candidates.vcf` carry the line too. The VCFs published earlier, the per-caller calls and `SVs.vcf` in `1_SV_search` and `genotypes_repmasked_filtered.vcf` in `2_Repeat_Filtering`, have none. `module/main.nf:409-411,630-633,903` !!! warning "An ALT allele does not mean the TE is present" For a `DEL` record the transposable element is in the reference and an `ALT` genotype means the sample lacks it. The presence-absence TSVs in `3_TSD_search/` fold this polarity for you; see [Output files](outputs.md). ## Repeat annotation fields Added by `repeatmask_VCF` from the RepeatMasker and ULTRA output on each variant's inserted or deleted sequence. A **hit** is one RepeatMasker element after its fragments have been grouped by RepeatMasker's own link ID (column 15 of the `.out` file); a **fragment** is one line of that file. Simple repeats and low-complexity fragments are removed before grouping, so they count neither as hits nor toward the TE span. `bin/annotate_vcf.R:97-114` | Field | Number | Type | Meaning | Source | |---|---|---|---|---| | `n_hits` | 1 | Integer | Hits on the variant sequence. `0` when RepeatMasker found nothing. | `bin/repmask_vcf.sh:21`, `bin/annotate_vcf.R:178` | | `fragmts` | . | Integer | Fragments grouped into each hit, in hit order. | `bin/repmask_vcf.sh:25`, `bin/annotate_vcf.R:166` | | `match_lengths` | . | Integer | Bases of the variant covered by each hit, first to last fragment. | `bin/repmask_vcf.sh:22`, `bin/annotate_vcf.R:160` | | `repeat_ids` | . | String | Name of each hit, taken from its highest-scoring fragment. A hit whose fragments carry different names gets an `(x)` suffix. An SVA hit lying entirely inside the VNTR gets a `(VNTR_only)` suffix; see [SVA VNTR polymorphisms](../background/sva-vntr.md). | `bin/repmask_vcf.sh:23`, `bin/annotate_vcf.R:107-111,151-153` | | `matching_classes` | . | String | RepeatMasker class of each hit, as `class/family` from the library (`SINE/Alu`, `LINE/L1`, `LTR/ERVK`, ...). A `(VNTR_only)` SVA hit is reported as `Simple_repeat` here. | `bin/repmask_vcf.sh:24`, `bin/annotate_vcf.R:109,154-156` | | `RM_hit_strands` | . | String | Strand of each hit: `+` or `C` as RepeatMasker writes them. A hit whose fragments lie on both strands reports the concatenation (`C+`, `+C`), except an L1 with the `C+` twin-priming signature, whose strand is inferred; see [L1 5' inversions](../background/l1-5prime-inversion.md). | `bin/repmask_vcf.sh:26`, `bin/annotate_vcf.R:104,120-127` | | `RM_hit_IDs` | . | String | RepeatMasker link ID of each hit, so a hit can be found again in `repeatmasker_dir/indels.fa.out`. | `bin/repmask_vcf.sh:27`, `bin/annotate_vcf.R:170` | | `L1_5PINV` | . | String | Link IDs of the hits flagged as an L1 with a 5' inversion, or `None`. | `bin/repmask_vcf.sh:30`, `bin/annotate_vcf.R:119,177` | | `total_match_length` | 1 | Integer | Bases of the variant covered by TE hits, overlaps counted once. | `bin/repmask_vcf.sh:28`, `bin/repmask_vcf.sh:114-124` | | `total_match_span` | 1 | Float | `total_match_length` divided by the variant length. Written for continuity with v1.0, where it was the filter metric; nothing in v1.1 filters on it. | `bin/repmask_vcf.sh:29,121-124` | | `ULTRA_TR` | 1 | Integer | Bases of the variant that ULTRA annotates as tandem repeat, overlaps counted once. `0` when ULTRA found nothing. | `bin/repmask_vcf.sh:31,102-104` | | `ULTRA_TR_span` | 1 | Float | `ULTRA_TR` divided by the variant length, capped at 1. | `bin/repmask_vcf.sh:32,135-137` | | `total_repeat_span` | 1 | Float | Fraction of the variant covered by the union of TE hits and ULTRA intervals, capped at 1. This is the Stage 2 filter metric: records at or below `--repeat_span_cutoff` (default `0.80`) are discarded. | `bin/repmask_vcf.sh:33,142-147`, `module/main.nf:579,661` | A record without any hit has `n_hits=0`, `repeat_ids=None`, `matching_classes=None`, `RM_hit_strands=None`, `RM_hit_IDs=None` and `L1_5PINV=None`; such records fail the span filter unless ULTRA covers them. `bin/annotate_vcf.R:205-213` ## TSD and polyA fields Added by `tsd_report` and `concat_repeatmask` to `pangenome.vcf`, and carried downstream, including into the genotyped VCFs. A consolidated HERV-K record is built from scratch and does not carry them. | Field | Number | Type | Meaning | Source | |---|---|---|---|---| | `TSD` | 2 | String | The target site duplication as its 5' copy and its 3' copy, comma-separated and upper-cased: `GATTACAG,GATTACAG`. The two copies are exact matches. Absent when the search found no duplication of 4 to 20 bp whose ends sit, on average, within 5 bp of the breakpoints. How the search works is in [Target site duplications](../background/tsd.md). In output from before commit `d1dfd7b` the header says `Number=1` and the comma reads `%2C` (`GATTACAG%2CGATTACAG`); decode it before splitting. | `bin/tsd_annotate_vcf.sh:23,32` | | `polyA` | 1 | String | `TRUE` when a tail of at least 8 bp with at least 80% A ends within 5 bp of the variant's 3' end for a plus-strand hit, or the same with T at its 5' end for a minus-strand hit, with or without the matching `TSD` copy trimmed off. `FALSE` otherwise, including when the single hit has a mixed strand. `NA` when `n_hits` is greater than 1. Before commit `d1dfd7b` the pipeline trimmed no `TSD` copy, and from `d1dfd7b` to `19da5f8` it scanned only the trimmed end; see the [changelog](../changelog.md). | `bin/add_polyA.py:24-34,71-95,111-158` | ## HERV-K classifier fields Written only under `--human`, by `hervk_annotate`. `pangenome.vcf` is left untouched because it induces the graph, so these fields appear in `pangenome.human.vcf`, in `hervk_candidates.vcf` and in the two consolidated VCFs. What the states mean is in [HERV-K (HML-2) biology](../background/hervk-hml2.md). | Field | Number | Type | Meaning | Source | |---|---|---|---|---| | `HERVK_CLASS` | 1 | String | Polymorphism class: `null_solo`, `solo_prov`, `truncated_prov`, `null_prov`, `copy_number` or `other`. | `bin/hervk_classify.py:425` | | `HERVK_ALLELE_REF` | 1 | String | State of the REF allele: `null`, `solo`, `provirus`, `prov_xN` (a tandem array of N proviral units sharing an LTR at each junction), `partial`, or `.` when unresolved. | `bin/hervk_classify.py:428` | | `HERVK_ALLELE` | . | String | State of each ALT allele, in ALT order, same vocabulary. | `bin/hervk_classify.py:432` | | `HERVK_EVIDENCE` | 1 | String | What resolved the states: `ARCH_2LTR`, `ARCH_PERM`, `ARCH_INT_PERM`, `CNV_PERIOD`, `ARCH_SOLO`, `REF_ANNOT`, `DENOVO_LTR`, `UNRESOLVED` or `NON_HML2`. | `bin/hervk_classify.py:434` | | `HERVK_ARCH` | 1 | String | 5' to 3' architecture of the variant allele with consensus intervals, for example `LTR:575-968/INT:1-7536/LTR:1-574`. | `bin/hervk_classify.py:437` | | `HERVK_K` | 1 | Integer | Where the aligner broke the reference solo LTR. An alignment property that varies between haplotypes and callers; do not key on its value. | `bin/hervk_classify.py:440` | | `HERVK_J` | 1 | Integer | The same for the internal region, the `ARCH_INT_PERM` counterpart of `HERVK_K`. | `bin/hervk_classify.py:443` | | `HERVK_N_UNITS_REF` | 1 | Integer | Proviral units in the masked reference element, a junction LTR counted once. | `bin/hervk_classify.py:446` | | `HERVK_UNIT_BP` | 1 | Integer | Period of the reference array in bp: one internal region plus one LTR. A copy-number change moves a whole number of these. | `bin/hervk_classify.py:448` | | `HERVK_REF_STATE` | 1 | String | State of the masked reference window: `null`, `solo`, `provirus`, `partial` or `unknown`. | `bin/hervk_classify.py:451` | | `HERVK_LAMBDA` | 1 | Float | bp of HML-2 LTR sequence on the variant allele. | `bin/hervk_classify.py:453` | | `HERVK_NU` | 1 | Float | bp of HML-2 internal (`HERVK-int`) sequence on the variant allele. | `bin/hervk_classify.py:455` | | `HERVK_COV` | 1 | Float | Fraction of the variant allele that is HML-2 sequence. | `bin/hervk_classify.py:457` | | `HERVK_PMAP` | 1 | Float | Confidence in the class under the size model, used by `--hervk_strict`; it does not determine the class. | `bin/hervk_classify.py:459` | | `HERVK_NOTE` | . | String | Diagnostics: `REF_ARCH_CONFLICT` (architecture and masked reference imply different REF states), `CNV_UNITS:a->b` (units on REF and ALT), `UNIT_COUNT_ASSUMED` (the count came from the architecture, since the reference did not resolve into counted units). | `bin/hervk_classify.py:462` | ## HERV-K locus flags Added by `hervk_reconcile.py flag` to `pangenome.human.vcf` after classification, and carried onto the genotyped human VCF. They group records that describe the same element and say what varies there. Records are never merged at this stage; the genotyped calls are matched to this file by ID, so its structure has to stay. | Field | Number | Type | Meaning | Source | |---|---|---|---|---| | `HERVK_LOCUS` | 1 | String | Locus identifier shared by the records that describe one element. | `bin/hervk_reconcile.py:96` | | `HERVK_LOCUS_N` | 1 | Integer | Records assigned to the locus. | `bin/hervk_reconcile.py:98` | | `HERVK_MEI` | 0 | Flag | A null allele segregates: the element is absent from some haplotypes, so a transposition produced the difference. This is the flag that separates an insertion polymorphism, comparable to an *Alu*, L1 or SVA insertion, from structural variation in an element every haplotype carries. | `bin/hervk_reconcile.py:100` | | `HERVK_SOLO_PROV` | 0 | Flag | A solo LTR and a provirus both segregate. Can be set beside the other two flags. | `bin/hervk_reconcile.py:106` | | `HERVK_CNV` | 0 | Flag | Some allele carries two or more proviral units. Can be set beside the other two flags. | `bin/hervk_reconcile.py:109` | | `HERVK_LOCUS_TYPE` | 1 | String | One label derived from the flags: `null_vs_present` when `HERVK_MEI` is set, else `copy_number`, else `solo_vs_provirus`, else `unresolved`. For a locus that is two things at once, this field holds only the first; the flags are the precise statement. | `bin/hervk_reconcile.py:113` | | `HERVK_MERGE_FLAG` | 0 | Flag | The locus holds more than one record. | `bin/hervk_reconcile.py:118` | | `HERVK_POLARITY_CONFLICT` | 0 | Flag | Records at the locus imply different REF states. The masked reference wins, and consolidation resolves it. | `bin/hervk_reconcile.py:122` | In a cohort of 20 diploid human genomes, chr6:78,894,316 segregates a solo LTR, a provirus and a two-unit allele. It is labeled `copy_number` and carries both `HERVK_SOLO_PROV` and `HERVK_CNV`. ## Consolidated HERV-K records GraffiTE can emit several records for one HERV-K locus: two breakpoints for the same insertion, or a deletion and an insertion describing opposite directions of the same event. The two `.consolidated.` and `.human.` VCFs hold each locus as one multi-allelic record, with the fields below. A `##hervk_consolidation=source:...` header line says whether the genotypes came from discovery or from the graph. `bin/hervk_reconcile.py:1167` | Field | Number | Type | Meaning | Source | |---|---|---|---|---| | `SVTYPE` | A | String | Redefined per ALT, since one consolidated record can hold an insertion and a deletion. | `bin/hervk_reconcile.py:531` | | `SVLEN` | A | Integer | Redefined per ALT for the same reason. | `bin/hervk_reconcile.py:532` | | `HERVK_MEMBERS` | . | String | Record IDs consolidated into the locus. | `bin/hervk_reconcile.py:538` | | `HERVK_AC` | . | Integer | Allele count per ALT after dosage resolution across the members. | `bin/hervk_reconcile.py:540` | | `HERVK_AN` | 1 | Integer | Alleles called at the locus. Below `2N` it means members were structurally uncalled for some samples, since graph genotyping can call every carrier and still leave some non-carriers uncalled. | `bin/hervk_reconcile.py:542` | | `HERVK_N_RESOLVED` | 1 | Integer | Samples fully resolved by dosage. | `bin/hervk_reconcile.py:545` | | `HERVK_N_PARTIAL` | 1 | Integer | Samples with some haplotypes unaccounted for; those haplotypes are reported missing. | `bin/hervk_reconcile.py:547` | | `HERVK_N_PLOIDY_EXCEEDED` | 1 | Integer | Samples whose summed ALT dosage exceeds their ploidy, which happens when a third allele was lost to `bcftools norm -m-`. Their genotypes are set missing. | `bin/hervk_reconcile.py:549` | | `HERVK_AC_DISC` | . | Integer | Allele count per ALT from the discovery (assembly) callset, an independent check on `HERVK_AC`. | `bin/hervk_reconcile.py:552` | | `HERVK_AN_DISC` | 1 | Integer | Alleles in the discovery callset. | `bin/hervk_reconcile.py:554` | | `HERVK_DISC_CONCORDANT` | 0 | Flag | Graph and discovery agree on every ALT count. | `bin/hervk_reconcile.py:556` | | `HERVK_GT_MASKED` | 0 | Flag | Graph genotypes were withheld at a copy-number locus (see the warning below). | `bin/hervk_reconcile.py:558` | | `HERVK_ALLELE_NOGT` | . | String | Alleles the graph cannot genotype, for which `HERVK_AC` reports 0. Their counts are in `HERVK_AC_DISC`. | `bin/hervk_reconcile.py:564` | | `HERVK_DISC_PLOIDY_MISMATCH` | 0 | Flag | Discovery and graph disagree on ploidy, so the discovery counts are withheld rather than reported on a denominator the two do not share. Expected on hemizygous chromosomes and with a haploid discovery caller such as svim-asm run per haplotype. | `bin/hervk_reconcile.py:570` | | `HERVK_MEMBERS_MASKED` | . | String | Members whose genotypes were withheld. | `bin/hervk_reconcile.py:575` | | `HERVK_ALLELE_SET` | . | String | Every allele state segregating at the locus, including states carried by members that are not in this file. | `bin/hervk_reconcile.py:577` | | `HERVK_MEMBERS_ABSENT` | . | String | Members the `--human` filter removed, whose alleles cannot be counted here. | `bin/hervk_reconcile.py:581` | | `HERVK_LOCUS_INCOMPLETE` | 0 | Flag | Some member is absent from this file, so the frequencies do not cover every allele. | `bin/hervk_reconcile.py:584` | | `HERVK_MEMBERS_UNRESOLVED` | . | String | Members with no usable allele state. | `bin/hervk_reconcile.py:587` | | `HERVK_POLARITY_FLIPPED` | . | String | Members whose own polarity disagreed with the locus REF state and were re-expressed against it. | `bin/hervk_reconcile.py:589` | `HERVK_LOCUS`, `HERVK_ALLELE_REF`, `HERVK_ALLELE` and the four locus flags are written again on consolidated records with the same meaning. `bin/hervk_reconcile.py:509-514,533-536` !!! warning "A copy-number allele cannot be genotyped from short reads" Its ALT path repeats sequence the REF path already carries, so a read from the pre-existing copy traverses it and non-carriers pick up ALT support. More depth does not remove that. GraffiTE withholds those alleles from the graph genotypes and names them in `HERVK_ALLELE_NOGT`. The other alleles at the same locus are genotyped normally, and the withheld one takes its frequency from the assemblies. At chr6:78,894,316 the graph counts the solo allele at AC=8, matching the assemblies, and the two-unit allele comes from `HERVK_AC_DISC`. !!! warning "`HERVK_LOCUS_INCOMPLETE` means the frequencies are partial" The `--human` filter is narrower than the HERV-K candidate list, so it can remove some members of a locus and keep others. In a cohort of 20 diploid human genomes, three loci are in that state. At chr7:4,699,714 it keeps one of three; all three describe the same 8.5 kb unit, and the two it removes carry a third RepeatMasker fragment the HERV-K clause does not admit. The surviving record carries the locus id and the full `HERVK_ALLELE_SET`, but its counts cover only the alleles still present. `hervk_candidates.vcf` has all the records with their assembly genotypes. When reading these records, quote `HERVK_AC` and `HERVK_AN` together rather than a frequency alone, because `AN` below `2N` deflates the denominator without touching `AC`. Treat `HERVK_N_PLOIDY_EXCEEDED` above zero as a sign of a lost third allele. Do not key on `HERVK_K`. ## FORMAT fields | Field | Number | Type | Meaning | Source | |---|---|---|---|---| | `GT` | 1 | String | Genotype. In `pangenome.vcf` it is the discovery genotype: `1` or `0` per haploid assembly, or the diploid call from Sniffles2 or PAV. In the genotyped VCFs it is what PanGenie or `vg call` wrote for each read set. | `bin/repmask_vcf.sh:34`, `bin/merge_vcfs.py:521` | PanGenie and `vg call` add their own FORMAT fields (genotype quality, depth, likelihoods) with their own header lines; GraffiTE passes them through unchanged. Which ones appear depends on the version of those tools in the container, so they are not listed here. ## Fields inherited from upstream callers On a single-input run, `SVTYPE`, `SVLEN` and `END` come from the SV caller. With more than one input VCF every upstream INFO field is stripped before the truvari merge, `truvari collapse` adds `NumCollapsed`, `NumConsolidated` and `CollapseId`, and `bcftools +fill-tags` recomputes `SVLEN` as `strlen(ALT) - strlen(REF)` after the collapse, so it is negative for a deletion; with a single input VCF the caller's INFO fields (PAV's `HAP`, `QRY_REGION` and so on) are kept. On a `--vcf` run, and on a run whose callers produce a single VCF, `truvari_merge` only copies or decompresses the input into `SVs.vcf`, and `SVLEN` stays whatever the caller wrote, sign convention included. `abs(SVLEN)` is what the trusted and human filters test either way. `module/main.nf:17,205-212,222-223,228,260-263,279,545` GraffiTE defines no `##FILTER` line and never sets `FILTER` itself. `pangenome.vcf` retains the value the caller wrote, and the caller's `##FILTER` definitions (PAV's `TRIM`, `COMPOUND`, `QRY_FILTER` and `SVLEN`, for instance) travel with it. The trusted and human subsets require `PASS` unless `--trusted_ignore_filter` or `--human_ignore_filter` is set. `module/main.nf:25,573,591` One field is defined for the PanGenie graph and comes back in the genotyped VCFs: | Field | Number | Type | Meaning | Source | |---|---|---|---|---| | `ID` | A | String | Graph variant IDs per ALT allele, in the multi-allelic graph VCF `pangenie_index` builds. PanGenie writes them into `INFO/ID` of `_genotyping.vcf.gz`; `4_Genotyping/pangenie_graph_variants.tsv` maps them back to `pangenome.vcf` records. | `bin/merge_vcfs.py:520` | ## Retired fields | Field (v1.0) | What replaced it | |---|---| | `mam_filter_1` (`5P_INV`) | `L1_5PINV`, written for every run. `--mammal` is accepted and ignored. | | `mam_filter_2` (`VNTR_ONLY:...`) | The `(VNTR_only)` suffix on `repeat_ids` and `Simple_repeat` in `matching_classes`. | | `total_match_span` as the filter metric | `total_repeat_span` with `--repeat_span_cutoff`. `total_match_span` is still written. | `bin/repmask_vcf.sh:164-169`, `bin/annotate_vcf.R:151-156` ## Filtering GraffiTE VCFs with bcftools On the multi-valued fields (`repeat_ids`, `matching_classes`, `RM_hit_strands`, everything with `Number=.`), `~` is evaluated on each element, and `^` anchors each element, so `repeat_ids~"^LTR5_Hs"` is true for a record whose value is `SVA_A,LTR5_Hs`. `!~` does not negate reliably on these fields: `matching_classes!~"SINE"` is true for every record, `SINE/Alu` ones included. GraffiTE's own `--human` expression is written with positive matches only for that reason. bcftools regular expressions also have no alternation, which is why the whitelist parameters are comma-separated lists rather than `A|B`. `module/main.nf:533-549` Single-hit *Alu* insertions with a polyA tail and a TSD: ```bash bcftools view -i 'n_hits=1 & matching_classes="SINE/Alu" & polyA="TRUE" & TSD!="."' pangenome.vcf ``` Read HERV-K from a consolidated VCF; in the unmerged ones a locus is several records and the same allele can be counted twice. Insertion polymorphisms only, the set to use alongside *Alu*, L1 and SVA: ```bash bcftools view -i 'INFO/HERVK_MEI=1' GraffiTE.merged.genotypes.human.vcf.gz ``` Every other HERV-K locus, where the element is in every haplotype and its structure varies: ```bash bcftools view -i 'INFO/HERVK_LOCUS!="." && INFO/HERVK_MEI=0' \ GraffiTE.merged.genotypes.human.vcf.gz ``` Drop loci whose counts do not cover every allele, either because the graph could not count one or because the `--human` filter removed a member: ```bash bcftools view -e 'INFO/HERVK_ALLELE_NOGT!="." || INFO/HERVK_LOCUS_INCOMPLETE=1' \ GraffiTE.merged.genotypes.human.vcf.gz ``` SVA VNTR-only records, which carry `Simple_repeat` rather than `Retroposon/SVA`: ```bash bcftools view -e 'INFO/repeat_ids~"VNTR_only"' pangenome.human.vcf ``` # Pipeline processes !!! info "Applies to GraffiTE v1.1" Verified against `v1.1.0.0` at commit `bf51777`. The [2024 paper](https://www.nature.com/articles/s41467-024-53294-2) describes v1.0, which differs in places; see [v1.0 vs v1.1](../getting-started/v1.0-vs-v1.1.md). `module/main.nf` defines 25 processes. The methylation branch imports eight more from the `panmethyl` submodule. The inputs you pass determine which ones run; Nextflow never schedules a process with nothing on its input channel. `main.nf:12-18` Every process runs in the GraffiTE container except `pav_asm`, which has its own. Nextflow puts the repository's `bin/` on `PATH` inside every task. `nextflow.config:345` --- ## Process graph ```mermaid %%{init: {"flowchart": {"nodeSpacing": 20, "rankSpacing": 26, "padding": 8}}}%% flowchart TB subgraph SA["Stage 1 · SV search"] direction TB asmIn(["--assemblies"]) lrIn(["--longreads"]) bamIn(["--bams"]) pavIn(["--pav"]) svsIn(["--svs"]) vcfIn(["--vcf"]) bs["break_scaffold"] ma["map_asm"] sv["svim_asm"] ml["map_longreads"] ssc["sniffles_sample_call"] spc["sniffles_population_call"] pav["pav_asm"] tm["truvari_merge"] asmIn -.->|"--break_scaffolds"| bs --> ma asmIn --> ma --> sv --> tm lrIn --> ml --> ssc --> spc --> tm bamIn --> ssc pavIn --> pav --> tm svsIn --> tm vcfIn --> tm end subgraph SB["Stage 2 · TE annotation"] direction TB rmdIn(["--RM_dir"]) spl["split_repeatmask"] --> rm["repeatmask_VCF"] --> tp["tsd_prep"] --> ts["tsd_search"] --> tr["tsd_report"] --> cr["concat_repeatmask"] rmdIn --> tp cr -.->|"--human"| ha["hervk_annotate"] end subgraph SC["Stage 3.1 · Genotyping"] direction TB pvIn[/"pangenome.vcf,
or --graffite_vcf"/] readsIn(["--genotype_with"]) graphIn(["--graph"]) galnIn(["--graph_alignments"]) vcfsIn(["--vcfs"]) hkIn[/"hervk_annotate
tables"/] epiIn[/"VCFs with methylation
from Stage 3.2"/] b2f["bam_to_fastq"] pi["pangenie_index"] --> pg["pangenie"] mg["make_graph"] --> gar["graph_align_reads"] --> vc["vg_call"] pg --> mv["merge_VCFs"] vc --> mv mv --> ga["genotyping_audit"] mv -.->|"default"| tg["trusted_genotypes"] mv -.->|"--human"| hr["hervk_reconcile"] pvIn --> pi pvIn --> mg readsIn --> b2f readsIn --> pg readsIn --> gar b2f --> gar b2f --> pg graphIn -.->|"replaces"| mg galnIn -.->|"replaces"| gar vcfsIn -.->|"replaces"| vc hkIn -.-> hr epiIn -.-> mv end subgraph SM["Stage 3.2 · Epigenetic mapping · --epigenomes"] direction TB gIn[/"graph from make_graph"/] aIn[/"GAFs from graph_align_reads"/] bIn(["BAM rows of
--genotype_with"]) vIn[/"VCFs from vg_call"/] liftIn(["--lifted"]) bedIn(["--bed"]) ig["index_graph"] b2b["bamtags_to_BED"] --> le["lift_epigenome"] --> mc["merge_CSV"] --> av["annotate_VCF"] b2g["BED_to_graph"] --> ab["annotate_BED"] --> mb["merge_BED"] gIn --> ig aIn --> le bIn --> b2b vIn --> av ig --> le mc --> ab liftIn -.->|"replaces"| le bedIn --> b2g av --> mvOut[/"to merge_VCFs"/] end SA -->|"SVs.vcf"| SB SB -->|"pangenome.vcf"| SC SC -.->|"--epigenomes"| SM classDef inp fill:#8888881a,stroke:#888888; classDef file fill:none,stroke:#888888; class asmIn,lrIn,bamIn,pavIn,svsIn,vcfIn,rmdIn,readsIn,graphIn,galnIn,vcfsIn,liftIn,bedIn,bIn inp; class pvIn,hkIn,epiIn,gIn,aIn,vIn,mvOut file; classDef s1 fill:#f5851f2e,stroke:#f5851f; classDef s2 fill:#f2523f2e,stroke:#f2523f; classDef s3 fill:#3d63c92e,stroke:#3d63c9; classDef s32 fill:#2fb3b32e,stroke:#2fb3b3; class bs,ma,sv,ml,ssc,spc,pav,tm s1; class spl,rm,tp,ts,tr,cr,ha s2; class b2f,pi,pg,mg,gar,vc,mv,ga,tg,hr s3; class ig,b2b,le,mc,av,b2g,ab,mb s32; style SA fill:#f5851f0d,stroke:#f5851f; style SB fill:#f2523f0d,stroke:#f2523f; style SC fill:#3d63c908,stroke:#3d63c9; style SM fill:#2fb3b30d,stroke:#2fb3b3,stroke-dasharray:4 3; ``` Rounded boxes are parameters you pass, and slanted boxes are files that one stage writes and another reads. Dashed edges are taken only when the labeled parameter is set. `--graph`, `--graph_alignments`, `--vcfs` and `--lifted` each replace the process they point at. --- ## Stage 1: SV search | Process | What it runs | Outputs | Published to | Resources | |---|---|---|---|---| | `break_scaffold` `module/main.nf:28` | `breakgaps.py` splits each assembly at runs of at least `--break_scaffolds_min_gap` `N`. Only with `--break_scaffolds`. | `broken/.fa.gz` | not published | `cpus 1` `nextflow.config:185-187` | | `map_asm` `module/main.nf:43` | `minimap2 -a -x --cs -r2k` (or winnowmap after `meryl count k=19`) piped into `samtools sort`. | `asm.sorted.bam` | not published | `map_asm_*` `nextflow.config:188-192` | | `map_longreads` `module/main.nf:67` | `minimap2 -ax map-` (or winnowmap, `k=15`) piped into `samtools sort`. | `.bam` | not published | `map_longreads_*` `nextflow.config:193-197` | | `sniffles_sample_call` `module/main.nf:98` | `samtools index`, then `sniffles --minsvlen 100 --all-contigs` per sample, writing a `.snf` for the joint call. | `.snf`, `.vcf` | not published | `sniffles_*` `nextflow.config:198-202` | | `sniffles_population_call` `module/main.nf:117` | `sniffles` over every `.snf`; `bcftools filter` keeps `INS` and `DEL` with an explicit ALT sequence; `bcftools +split` into one VCF per sample. | `sniffles2_individual_VCFs/*.vcf.gz` | `1_SV_search/` | `sniffles_*` `nextflow.config:203-207` | | `pav_asm` `module/main.nf:140` | Writes PAV's `assemblies.tsv` and `config.json`, runs `/opt/pav/files/docker/run`, keeps \|SVLEN\| above 50 bp. Own container. | `sv_.vcf.gz` | `1_SV_search/pav_individual_VCFs/` | `32` CPUs unless `--cores`, `pav_*` `nextflow.config:344-349` | | `svim_asm` `module/main.nf:174` | `samtools index`, `svim-asm haploid --min_sv_size 100 --types INS,DEL`, prefixes the IDs with the assembly name, `bcftools sort`. | `.vcf.gz` | `1_SV_search/svim-asm_individual_VCFs/` | `svim_asm_*` `nextflow.config:208-212` | | `truvari_merge` `module/main.nf:192` | With `--vcf`: copies the file. Otherwise strips INFO, `bcftools merge -m none`, `truvari divide` into shards, `truvari collapse --chain -P 0.5 -p 0.5 -S -1 -k common` per shard in parallel, `bcftools concat`, `+setGT` to `0`, `+fill-tags` recomputing `SVLEN`, then `shorten_ids.py`. One input file is copied without collapsing. | `SVs.vcf` | `1_SV_search/` | `svim_asm_*` `nextflow.config:213-217` | --- ## Stage 2: TE annotation | Process | What it runs | Outputs | Published to | Resources | |---|---|---|---|---| | `split_repeatmask` `module/main.nf:495` | Sorts and indexes `SVs.vcf`, writes one VCF per contig. | `.vcf` | not published | `repeatmasker_*` `nextflow.config:218-222` | | `repeatmask_VCF` `module/main.nf:637` | One task per contig. `repmask_vcf.sh` runs RepeatMasker with `--TE_library`, ULTRA, `bedtools merge` and `annotate_vcf.R`; then `bcftools view` keeps `total_repeat_span` above `--repeat_span_cutoff`. | `genotypes_repmasked_filtered.vcf`, `repeatmasker_dir/`, `genotypes_repmasked.vcf.gz`, `ultra_out.{bed,span,stats}`, `union.bp`, `total_repeat_span.tsv`, `combined.stats`, `vcf_annotation.bak.txt` | `2_Repeat_Filtering//` | `repeatmasker_*` `nextflow.config:228-232` | | `tsd_prep` `module/main.nf:665` | `prepTSD.sh` with `--tsd_win`: lists the indels and extracts the flanks and trimmed variant ends. | `indels.txt`, `SV_sequences_L_R_trimmed_WIN.fa`, `flanking_sequences.fasta` | not published | `cpus 1`, `tsd_*` `nextflow.config:233-237` | | `tsd_search` `module/main.nf:679` | One task per batch of `--tsd_batch_size` indels. `TSD_Match_v2.sh` with `--tsd_win` calls `exact_match.py` on each pair of fragments. | `*TSD_summary.txt`, `*TSD_full_log.txt`, `chrom.txt` | not published | `cpus 1`, `tsd_*` `nextflow.config:238-242` | | `tsd_report` `module/main.nf:694` | One task per contig. Concatenates the batch summaries and writes `INFO/TSD` with `tsd_annotate_vcf.sh`. | `TSD_summary.txt`, `TSD_full_log.txt`, `pangenome.vcf` (per contig) | not published | `cpus 1`, `tsd_*` `nextflow.config:243-247` | | `concat_repeatmask` `module/main.nf:510` | `bcftools concat` of the contigs, sort, the repeat-span filter again, `fix_vcf.py`, `add_polyA.py`, the presence-absence TSVs with `vcf_to_pa_tsv.py`, then `bcftools view -i` for the trusted subset, or for the `--human` subset plus `human_filter_summary.txt`. Stamps `##GraffiTE_version`. | `pangenome.vcf`, `pangenome.presence-absence.tsv`, `TSD_summary.txt`, `TSD_full_log.txt`, and either `pangenome.trusted.vcf` + `pangenome.presence-absence_trusted.tsv` or `pangenome.human.vcf` + `pangenome.presence-absence_human.tsv` + `human_filter_summary.txt` | `3_TSD_search/` | `repeatmasker_*` `nextflow.config:223-227` | | `hervk_annotate` `module/main.nf:300` | `--human` only. Lists LTR/ERVK candidates up to `--hervk_max_svlen`, reads the raw RepeatMasker tables with `hervk_arch.py`, masks the reference windows with `hervk_ref_state.py` (RepeatMasker on `task.cpus` threads, or a supplied annotation), classifies with `hervk_classify.py`, flags loci with `hervk_reconcile.py flag`, and writes a consolidated discovery VCF. Overwrites the two human files from `concat_repeatmask`. | `pangenome.human.vcf`, `pangenome.presence-absence_human.tsv`, `hervk_loci.tsv`, `hervk_calls.tsv`, `hervk_arch.tsv`, `hervk_refstate.tsv`, `hervk_candidates.vcf`, `hervk_polymorphism_summary.md`, `pangenome.human.consolidated.vcf`, `hervk_discovery_consolidation_report.md` | `3_TSD_search/` (`overwrite: true`) | `hervk_annotate_*` `nextflow.config:294-298` | --- ## Stage 3: graph mapping and genotyping | Process | What it runs | Outputs | Published to | Resources | |---|---|---|---|---| | `bam_to_fastq` `module/main.nf:808` | For `.bam` rows of `--genotype_with`: strips tags, name-sorts, `samtools fastq`, `pigz`. | `.fq.gz` | not published | `graph_align_*` `nextflow.config:263-267` | | `pangenie_index` `module/main.nf:714` | Drops genotypes from the annotated VCF, `pangenie_graph_vcf.py prepare` (a `ref` sample, one graph variant per site and safe IDs), `bcftools sort`, `bcftools norm -m+`, `merge_vcfs.py merge` at ploidy 2, `pangenie_graph_vcf.py report`, `PanGenie-index`. | `pangenie_index/`, `pangenie_graph_variants.tsv` | `4_Genotyping/pangenie_graph_variants.tsv` | `pangenie_*` `nextflow.config:248-252` | | `pangenie` `module/main.nf:736` | `PanGenie` per read set, then `samtools faidx` and `bcftools reheader -f` put the reference contigs in the header (PanGenie writes no `##contig` lines and `bcftools norm` stops without them), `bcftools norm -N -m-` so records match `pangenome.vcf` one for one, and `tabix`. | `_genotyping.vcf.gz`, `.tbi` | `4_Genotyping/` | `pangenie_*` `nextflow.config:253-257` | | `make_graph` `module/main.nf:773` | `bcftools +setGT` unphases the VCF. giraffe: `vg autoindex -w sr-giraffe -w lr-giraffe`, `vg convert` to GFA, `vg snarls`. graphaligner: `vg construct -a -m 1024`, `vg convert`, `vg snarls`. Skipped with `--graph`. | `index/` (`index.gfa`, `index.pb`, and `index.giraffe.gbz` for giraffe) | `GraffiTE_graph/` | `make_graph_*` `nextflow.config:258-262` | | `graph_align_reads` `module/main.nf:826` | giraffe: `vg giraffe --parameter-preset ` (with `-i` for short reads), `vg pack -Q `, `vg convert` to GAF through `subset_gaf.py`. graphaligner: `GraphAligner -x vg`, then the same. Skipped with `--graph_alignments`. If a sample fails, the tasks already running finish before the run stops (`errorStrategy 'finish'`). | `.gaf.gz`, `.pack` | `GraffiTE_alignments/` | `graph_align_*` `nextflow.config:268-273` | | `vg_call` `module/main.nf:863` | `vg call -a -A -R chrX:1,chrY:1 -m ` against the snarls, `bcftools norm -m-`, `bcftools sort`, `tabix`. Skipped with `--vcfs`. | `.vcf.gz`, `.tbi` | not published | `vg_call_*` `nextflow.config:274-278` | | `merge_VCFs` `module/main.nf:881` | `bcftools merge -m none` of every per-sample VCF, then `bcftools annotate` copies ID and INFO from `pangenome.vcf`, matching on `CHROM`, `POS`, `REF` and a shared `ALT`. Stamps `##GraffiTE_version`. | `GraffiTE.merged.genotypes.vcf.gz` | `4_Genotyping/` | `cpus 1`, `merge_vcf_*` `nextflow.config:279-283` | | `genotyping_audit` `module/main.nf:909` | `genotyping_audit.py` against `pangenome.vcf` and the merged genotypes, plus `pangenie_graph_variants.tsv` on the pangenie path. One row per ALT allele saying which stage dropped it. | `genotyping_record_audit.tsv` | `4_Genotyping/` | `cpus 1`, `merge_vcf_*` `nextflow.config:289-293` | | `trusted_genotypes` `module/main.nf:931` | Not under `--human`. Evaluates the trusted expression on `pangenome.vcf` and subsets the merged genotypes by the IDs it returns, then `vcf_to_pa_tsv.py`. | `GraffiTE.merged.genotypes.trusted.vcf.gz`, `.tbi`, `GraffiTE.merged.genotypes.presence-absence_trusted.tsv` | `4_Genotyping/` | `cpus 1`, `merge_vcf_*` `nextflow.config:284-288` | | `hervk_reconcile` `module/main.nf:422` | `--human` only. Subsets the merged genotypes to the human IDs, copies every `HERVK_*` INFO tag across from the discovery VCF, and runs `hervk_reconcile.py consolidate`, which masks graph genotypes at copy-number loci unless `--hervk_mask_graph_gt_at_cnv false`. With `--hervk_reconcile_vcf` the merged VCF comes from that file instead. | `GraffiTE.merged.genotypes.human.vcf.gz`, `.tbi`, `hervk_unconsolidated_records.vcf`, `hervk_reconciliation_report.md` | `4_Genotyping/` (`overwrite: true`) | `cpus 1`, `hervk_reconcile_*` `nextflow.config:299-303` | `vg_call` passes `-R chrX:1,chrY:1`, so contigs named exactly `chrX` and `chrY` are called at ploidy one. Sex chromosomes named otherwise are called at ploidy two. `module/main.nf:874` --- ## Stage 3.2: epigenetic mapping processes Imported from `panmethyl/module/main.nf` at submodule commit `f0aa2c0`; `--epigenomes` only, and only inside the giraffe, graphaligner or precomputed branch. Their resources are fixed in `nextflow.config` and have no parameter. `main.nf:12,234-258` | Process | What it runs | Outputs | Published to | Resources | |---|---|---|---|---| | `index_graph` `panmethyl/module/main.nf:67` | Node sizes from the GFA, and `index_nucleotide.py` locating every `--motif` on the graph. | `node_sizes.csv`, `nodes_list.csv`, `index.csv.gz` | `index/` | `cpus 1`, `40 GB`, `6 h` `nextflow.config:319-323` | | `bamtags_to_BED` `panmethyl/module/main.nf:136` | `tagtobed` extracts the `--code` modification calls from each genotyping BAM. Skipped with `--lifted`. | `.mods.gz` | not published | `cpus 2`, `50 GB`, `6 h` `nextflow.config:304-308` | | `lift_epigenome` `panmethyl/module/main.nf:150` | Joins the calls with the sample's GAF and runs `lift_mods` to place them on graph nodes. | `.csv.gz` | `lifted/` | `cpus 1`, `60 GB`, `6 h` `nextflow.config:309-313` | | `merge_CSV` `panmethyl/module/main.nf:168` | `nodes_levels.py` per input, then `merge_csvs.py` into one table per sample. | `.csv.gz` | `levels/` | `cpus 1`, `60 GB`, `6 h` `nextflow.config:314-318` | | `annotate_VCF` `panmethyl/module/main.nf:1` | `annotate_vcf.py` adds methylation levels to the sample's `vg call` VCF; that VCF then goes to `merge_VCFs`. | `.mods.vcf.gz`, `.tbi`, `.mods.tsv` | `annotation/` | `cpus 1`, `40 GB`, `6 h` `nextflow.config:324-328` | | `BED_to_graph` `panmethyl/module/main.nf:17` | `vg annotate` projects `--bed` onto the graph. | `annotation.gaf`, `annotation.bed` | not published | `cpus 1`, `40 GB`, `6 h` `nextflow.config:334-338` | | `annotate_BED` `panmethyl/module/main.nf:30` | `annotate_bed.py` gives each BED feature the sample's levels. | `.bed` | `annotation/` | `cpus 1`, `40 GB`, `6 h` `nextflow.config:329-333` | | `merge_BED` `panmethyl/module/main.nf:45` | Pastes the per-sample columns into one table. | `merged_epiannoation.bed` | `annotation/` | `cpus 1`, `40 GB`, `6 h` `nextflow.config:339-343` | The methylation directories are published directly under `--out`, next to the numbered stage directories. See [Epigenetic mapping](../guides/methylation.md) and [Output files](outputs.md). --- ## Resource selectors Each process is matched by a `withName` block in `nextflow.config`. The `cpus` line of most blocks reads `params.cores ? params.cores : params._threads`, so `--cores` overrides every configurable thread count at once. The processes fixed at one CPU (`break_scaffold`, the three `tsd_*`, `merge_VCFs`, `trusted_genotypes`, `genotyping_audit`, `hervk_reconcile`) and the methylation processes ignore it. `nextflow.config:184-350` The full table of parameters is in [Parameters](parameters.md); the same table grouped by process is in [Resources and scaling](../guides/resources.md). # Container !!! info "Applies to GraffiTE v1.1" Verified against `v1.1.0.0` at commit `bf51777`. The [2024 paper](https://www.nature.com/articles/s41467-024-53294-2) describes v1.0, which differs in places; see [v1.0 vs v1.1](../getting-started/v1.0-vs-v1.1.md). ## Container image Every process runs in `docker://cgroza/graffite:1.1.0.0`, pulled from Docker Hub, except `pav_asm`. Each release has its own tag, and `latest` follows the newest release. `standard` and `cluster` run the image with Apptainer; `cluster` also sets `process.scratch = '$SLURM_TMPDIR'`. `cloud` runs the same image with Docker on AWS Batch. `nextflow.config:7-29` The image is `linux/amd64` only, 39 layers and about 2.8 GB compressed. Apptainer converts it to a SIF on first use. On an arm64 host it runs under emulation. | Profile | Executor | Extra | |---|---|---| | `standard` | `local` | | | `cluster` | `slurm` | `process.scratch = '$SLURM_TMPDIR'` | | `cloud` | `awsbatch` | Docker instead of Apptainer, `cgroza/graffite:1.1.0.0`. Needs your AWS settings in a config passed with `-c`; `pav_asm` cannot run. Not tested. See [Installation](../getting-started/installation.md#execution-profiles). | Singularity (or Apptainer) is enabled globally, with automatic mounts. The run options are built after the params block, so that `--container_tmp` can be read: `nextflow.config:3-4,181` ``` --contain --bind <--container_tmp, or $(pwd)>:/tmp ``` `--container_tmp` is unset by default, and the bind source is then `$(pwd)`. Pass `--container_tmp /scratch/you/tmp` and that directory is bound to `/tmp` instead. `nextflow.config:51` See [`--container_tmp`](parameters.md#global-switches) and [Paths and `/tmp`](../getting-started/installation.md#paths-and-tmp). `--contain` hides the host filesystem from the task except for what is bound in: the task directory, the input files Nextflow mounts on its own, and `/tmp`, which the bind points at the task directory or at `--container_tmp`. Two consequences: - A tool inside a task can only reach files the pipeline staged. Anything a script opens by an absolute host path that was not an input is invisible. - With `--container_tmp` unset, tools that write to `/tmp` write into the task directory, which sits on whatever filesystem Nextflow's `work/` is on. Put `work/` on fast, roomy storage, or point `--container_tmp` at storage that suits the traffic. To run it under Docker rather than Apptainer, turn `singularity.enabled` off in a config of your own and pass `-with-docker cgroza/graffite:1.1.0.0`. ## What is inside Built from [`Dockerfile`](https://github.com/cgroza/GraffiTE/blob/v1.1.0.0/Dockerfile) on top of `dfam/tetools:latest`, which is Debian 12. The recipe pins few versions; most tools are whatever the upstream repository, or the base image, held on the day the image was built. We read the last column out of the published image, `sha256:47836cda` (pushed 2026-09-30), on 2026-10-03. `Dockerfile:2` | Tool | Used by | Installed from | Pinned | In `sha256:47836cda` | |---|---|---|---|---| | RepeatMasker, RMBlast, HMMER, TRF, RepeatModeler and the rest of the Dfam TETools bundle | `repmask_vcf.sh`, `hervk_ref_state.py` | the `dfam/tetools:latest` base image | no | RepeatMasker 4.2.4, RMBlast 2.17.1+, HMMER 3.4, TRF 4.09, RepeatModeler 2.0.9 `Dockerfile:2` | | Dfam | nothing: both RepeatMasker calls take `--TE_library` through `-lib` | the base image | no | `dfam40.0.h5` and `dfam40.curated.consensus.0.h5` in `/opt/FamDB-Dfam-4.0/Libraries/famdb` `bin/repmask_vcf.sh:75`, `bin/hervk_ref_state.py:156` | | Winnowmap, meryl | `map_asm`, `map_longreads` with `--aligner winnowmap` | git, default branch | no | Winnowmap 2.03, meryl r992 `Dockerfile:34-43` | | htslib (with `bgzip` and `tabix`), samtools, bcftools | nearly every process | git, default branch; bcftools with `--enable-libgsl --enable-perl-filters` | no | htslib 1.24-87-g4be16390, samtools 1.24-47-gde749a60, bcftools 1.24-24-gedf7fd96 `Dockerfile:45-77` | | SURVIVOR | nothing in v1.1 | git, default branch | no | 1.0.7 `Dockerfile:82-87` | | minimap2 | `map_asm`, `map_longreads` | git, default branch | no | 2.31-r1302 `Dockerfile:89-94` | | minigraph | nothing in GraffiTE; panmethyl's `align_minigraph` calls it, and `main.nf` does not import that process | git, default branch | no | 0.21-r606 `Dockerfile:96-101`, `main.nf:12` | | ULTRA | `repmask_vcf.sh` | git tag | `v1.0.0` | the binary prints no version `Dockerfile:103-111` | | PanGenie, PanGenie-index | `pangenie_index`, `pangenie` | git, default branch, with cereal `v1.3.2`; the commit is written to `/metadata/pangenie.git.version` | no | commit `d44c4da` `Dockerfile:114-140` | | pysam, pyparsing, svim-asm, pandas, polars, vcfpy, sniffles, cigar, truvari, pyfaidx, h5py | `svim_asm`, `sniffles_*`, `truvari_merge`, `bin/*.py`, and panmethyl's `annotate_vcf.py` and `merge_csvs.py` | pip, into Debian's Python 3.11 | no | truvari 5.4.0, vcfpy 0.14.2, pysam 0.24.1, pandas 3.0.6, polars 1.44.2, numpy 2.4.6 (pulled in as a dependency), sniffles 2.8.1, svim-asm 1.0.3, pyfaidx 0.9.0.4, pyparsing 3.0.9, cigar 0.1.3, h5py 3.16.0 `Dockerfile:146` | | R with XML, dplyr, stringr, tidyr, readr, vcfR, optparse | `annotate_vcf.R` | CRAN, into Debian's R | no | R 4.2.2; XML 3.99.0.24, dplyr 1.2.1, stringr 1.6.0, tidyr 1.3.2, readr 2.2.0, vcfR 1.16.0, optparse 1.8.2 `Dockerfile:150` | | vg | `make_graph`, `graph_align_reads`, `vg_call`, `BED_to_graph` | GitHub release binary | `v1.77.0` | v1.77.0 `Dockerfile:182-183` | | pypy3 | `subset_gaf.py` (its shebang is `/opt/pypy3/bin/pypy3`) | tarball to `/opt/pypy3` | `7.3.17` | 7.3.17, Python 3.10.14 `Dockerfile:185-190` | | GraphAligner | `graph_align_reads` with `--graph_method graphaligner` | bioconda, through a throwaway Miniforge | no | 1.0.20 `Dockerfile:194-204` | | tagtobed, lift_mods, lift_offsets, lift_edges | `bamtags_to_BED` runs `tagtobed` and `lift_epigenome` runs `lift_mods`; the other two belong to panmethyl processes GraffiTE does not import | built from the panmethyl repository with Rust 1.85.0 | `f0aa2c0`, the submodule's commit | not recorded; its `tagtobed` has the panmethyl#3 fix, first in `f0aa2c0` `Dockerfile:206-227` | | bedtools, ncbi-blast+, pigz, gawk, bc, r-base-core | various | Debian 12 apt | no | bedtools 2.30.0, BLAST 2.12.0+, pigz 2.6, gawk 5.2.1, bc 1.07.1 `Dockerfile:6-31,175` | ## PAV container `pav_asm` runs in `library://becklab/pav/pav:latest`, PAV's own image, with 32 CPUs unless `--cores` is set. GraffiTE's image does not contain PAV. `nextflow.config:344-349`, `module/main.nf:169` ## Build recipe and published image We build the published image from `Dockerfile`, and `GraffiTE.def` is unmaintained. The published image matches `Dockerfile`: Debian 12, vg `v1.77.0` and the `lift_*` binaries, none of which `GraffiTE.def` gives. `GraffiTE.def` is the Apptainer recipe that came before it, on Ubuntu 20.04. We have not built it; going by the recipe, an image built from it would differ from the published one: - vg `v1.70.0` rather than `v1.77.0`, and RepeatMasker set up from the TETools sources with the Dfam 3.8 root partition `GraffiTE.def:30-167,287`. - No `lift_mods` and no polars. `lift_epigenome` runs `lift_mods`, and `merge_CSV` runs `merge_csvs.py`, which imports polars, so we expect every `--epigenomes` run to stop at one of the two `GraffiTE.def:305-313`, `panmethyl/module/main.nf:163,185`. Two more things follow from the unpinned installs: - bcftools is built from the default branch. The `--human` filter relies on how bcftools evaluates `~` on `Number=.` INFO fields and was checked on bcftools 1.22; the published image has 1.24-24-gedf7fd96, and a different bcftools may keep different records without an error. See [VCF fields](vcf-fields.md). - `GraffiTE.def` pins numpy to `1.21` and runs `pip3 check`, so a dependency conflict fails its build. `Dockerfile` does neither, and the published image has numpy 2.4.6. `GraffiTE.def:250-253`, `Dockerfile:146` To read the versions out of another image: ```bash apptainer exec graffite.sif bash -c 'vg version | head -1; bcftools --version | head -1; \ RepeatMasker -v; pip3 list 2>/dev/null | grep -i -E "truvari|vcfpy|pysam|numpy"' ``` ## Building it yourself `Dockerfile` needs Docker with BuildKit, the default builder since Docker Engine 23, because it uses heredoc `RUN` blocks: ```bash git clone --recurse-submodules https://github.com/cgroza/GraffiTE.git cd GraffiTE docker build -t graffite:local . ``` For Apptainer, convert the result to a SIF: ```bash apptainer build graffite.sif docker-daemon://graffite:local ``` Then point the profiles at the file instead of the Docker Hub image, in a config passed with `-c`: ```groovy process.container = '/path/to/graffite.sif' ``` The build pulls `dfam/tetools:latest`, clones several repositories and downloads a Miniforge installer, so it needs network access and takes a while. A rebuilt image may not carry the same tool versions as the published one for anything the table above lists as not pinned. `sudo apptainer build graffite.sif GraffiTE.def` builds the older recipe, with the differences listed in the previous section. # Target site duplications !!! info "Applies to GraffiTE v1.1" Verified against `v1.1.0.0` at commit `bf51777`. The [2024 paper](https://www.nature.com/articles/s41467-024-53294-2) describes v1.0, which differs in places; see [v1.0 vs v1.1](../getting-started/v1.0-vs-v1.1.md). ## What a TSD is When a non-LTR retrotransposon integrates by target-primed reverse transcription, the endonuclease nicks the two strands of the target site a few bases apart. Repairing that offset copies the bases between the nicks, so the new element ends up flanked by two identical short direct repeats, the target site duplication. LTR retrotransposons and DNA transposons make one too, through their own integrases, with a length characteristic of the family. A TSD is therefore evidence that a sequence got where it is by transposition, rather than by any other kind of structural change. In a variant call, the two copies straddle the breakpoint. The reference genome holds one copy (the original target site), and the inserted sequence carries the other at one of its ends, depending on where the caller placed the breakpoint. GraffiTE looks for that pair. ## Search procedure The search runs on every record that passed the repeat-span filter, whatever its `n_hits`, and uses only exact matches. Three scripts do the work, one process each. **`prepTSD.sh` builds two FASTA files.** For each variant, `tsd_flanks.py` reads `--tsd_win` bp of reference ending at `POS` (the anchor base included) and `--tsd_win` bp starting just after the variant: after `POS` for an insertion, after the deleted interval for a deletion. A window that runs off the start of a contig is clamped and comes out shorter. Separately, the variant sequence itself (ALT for an insertion, REF for a deletion), minus its anchor base, is trimmed to its first and last `--tsd_win` bp; a variant no longer than the window is used whole. The default window is 30 bp. `bin/prepTSD.sh:43-56`, `bin/tsd_flanks.py:50-59`, `nextflow.config:54` **`TSD_Match_v2.sh` compares two fragments per variant.** The L fragment is the 5' flank followed by the first bases of the variant; the R fragment is the last bases of the variant followed by the 3' flank. Each is two windows long and the junction between flank and variant sits at column `WIN` in both. `exact_match.py` then lists every maximal exact match of at least 4 bp between R and L on the plus strand, in BLAST tabular form, and matches longer than 20 bp are discarded. `bin/TSD_Match_v2.sh:37-69`, `bin/exact_match.py:45-89,117`
[figure: tsd-anatomy]
The two fragments, a duplication in the configuration that scores 0, and the score. In the other snug configuration the two copies start at the junction, one at the beginning of the variant and one at the beginning of the 3' flank; it scores 0 too.
**`tsd_annotate_vcf.sh` writes `INFO/TSD`** for every record whose row in the summary says `PASS`, as the 5' copy and the 3' copy comma-separated and upper-cased. Records that failed get no `TSD` field. The header declares `Number=2`, one value per copy. `fix_vcf.py` rewrites `pangenome.vcf` afterwards with vcfpy, which percent-encodes a comma inside a `Number=1` value. In output from before commit `d1dfd7b` the header said `Number=1`, and the field shows as `GATTACAG%2CGATTACAG`. `bin/tsd_annotate_vcf.sh:22-36` The search runs in batches of `--tsd_batch_size` variants per contig, and the per-batch summaries and logs are concatenated into `3_TSD_search/TSD_summary.txt` and `TSD_full_log.txt`. `main.nf:157-162`, `module/main.nf:575-576` ## Scoring and the PASS rule Every match is scored by how far its two copies sit from the junction. With `R_start`, `R_end`, `L_start`, `L_end` the 1-based columns of the match on each fragment: ```text a = ( |WIN + 1 - R_start| + |WIN + 1 - L_start| ) / 2 b = ( |WIN - R_end| + |WIN - L_end| ) / 2 score = min(a, b) ``` `a` is low when both copies begin at the junction, `b` when both end there. A candidate shorter than 6 bp competes only if it scores 0.5 or less. Among the rest, candidates scoring 1.5 or less count as ties, and the longest of them is the best. When none scores that low, the best is the lowest score, ties broken by the longest match. The best candidate passes when its score is at most 5 bp. These thresholds, and the 4 to 20 bp length range, are fixed in the script. `bin/TSD_Match_v2.sh:48-49,59-60,69,115-116,142` A copy that ends exactly at the junction is at column `WIN`, and one that starts exactly there is at column `WIN + 1`, so both snug configurations score 0. The tie at 1.5 is for insertions that end in a poly(A) tail. When the TSD also opens with As, the tail and the TSD run together and the boundary between them is uncertain by a base or two. A 4 bp run of A scoring 0.5 lower would otherwise beat the real copy. At 1.5 the two copies can sit up to three bases off the junction between them. `bin/TSD_Match_v2.sh:61-68,104-116`, `test/tsd/test_tsd_match.sh` The rule for short candidates comes from a null test on a cohort of 20 diploid human genomes, with CHM13v2.0 as the reference. We replaced each insertion's R window with that of another insertion of the same family, strand and SV type, so that no duplication could span the pair, and ran the search unchanged. Without the rule it passed a match in 72% of swapped Alu, L1 and SVA pairs, most of them 4 or 5 bp long and off the junction, while real calls of 9 bp or more scored 0 or 0.5 in 97% of cases. With it, 36% of swapped pairs pass, and 53 calls on 5,614 real Alu, L1 and SVA records are lost, all short and off the junction. Swapped pairs still get a call of 9 bp or more 1.6% of the time, so a long TSD is good evidence of transposition and a short one is weak even when it sits on the junction. `bin/TSD_Match_v2.sh:50-60,115-116,142`, `test/tsd/test_tsd_match.sh` ## Reading TSD_summary.txt One row per variant searched. A row with a hit has 21 tab-separated columns: | Column | Content | |---|---| | 1 | variant ID | | 2, 3 | `R\|3P_end`, `L\|5P_end` (query and target fragment names) | | 4 | identity, always `100.000` | | 5 | match length in bp | | 6, 7 | mismatches and gap opens, always `0` | | 8, 9 | start and end of the copy on the R fragment | | 10, 11 | start and end of the copy on the L fragment | | 12, 13 | placeholder e-value and bit score, derived from the length | | 14 to 17 | the start offsets of the R and L copies (`WIN + 1` minus columns 8 and 10), then their end offsets (`WIN` minus columns 9 and 11) | | 18 | the score | | 19, 20 | the sequence of the L copy and of the R copy | | 21 | `PASS` or `FAIL` | A variant with no exact match of 4 to 20 bp gets a shorter row: the ID, twelve `NA`, `no_hit`, `no_hit`, `FAIL`. Read the file from the right (`$NF`, `$(NF-1)`, `$(NF-2)`) rather than by column number, as `tsd_annotate_vcf.sh` does. `bin/TSD_Match_v2.sh:69,76,142`, `bin/exact_match.py:92-109` `TSD_full_log.txt` shows, for each variant, both fragments over a base ruler, every candidate match with its offsets, the chosen one, and the two fragments again with the copies underlined. The column header printed there names 16 columns for rows that have 17, because it omits the bit score. The header lines up through the e-value in column 11; column 12 of a row is the unnamed bit score; from column 13 on, the right name is one header column to the left. `bin/TSD_Match_v2.sh:42,118-135` ## Limitations - **Exact matches only.** A duplication with a single mismatch between its copies, or one interrupted by a sequencing error in the assembly, is missed. v1.0 used an aligner here and reported partial matches; v1.1 traded that for a search that cannot produce spurious alignments in low-complexity flanks. - **4 to 20 bp.** Shorter matches are below the seed; longer ones are treated as flank homology rather than a TSD. A match under 6 bp counts only when it sits on the junction. - **One TSD per variant.** Only the best candidate is reported, so a variant with two plausible duplications shows one. - **The window bounds what can be seen.** A copy further than `--tsd_win` from the breakpoint, or a breakpoint the caller placed more than 5 bp from the true junction, does not pass. Raising `--tsd_win` widens the search and, since the score is measured from the junction, does not change what a snug duplication scores. - **The variant sequence must be resolved.** A symbolic `` has no ends to compare; GraffiTE drops those before the search. - **PolyA tails can hide a copy.** The 3' end of a plus-strand Alu or L1 is a run of A; a TSD rich in A can be found at the wrong offset inside it, or be a run of the tail itself. `polyA` is therefore scanned with the `TSD` copy trimmed and without it, and a tail found either way counts. `bin/add_polyA.py:71-95` # L1 5' inversions !!! info "Applies to GraffiTE v1.1" Verified against `v1.1.0.0` at commit `bf51777`. The [2024 paper](https://www.nature.com/articles/s41467-024-53294-2) describes v1.0, which differs in places; see [v1.0 vs v1.1](../getting-started/v1.0-vs-v1.1.md). ## Twin priming Most L1 insertions are 5' truncated: reverse transcription starts at the polyA tail and stops before reaching the 5' end of the RNA. In a fraction of them the 5' part of the element is also inverted relative to the 3' part. Ostertag and Kazazian (2001) explained this by twin priming: after the first nick, reverse transcription of the 3' end begins as usual, then the second nicked strand primes a second reverse transcription on the same RNA, further upstream, in the opposite direction. The two cDNAs are joined, and the element ends up as an inverted 5' piece followed by a normally oriented 3' piece, often with a small deletion or duplication at the junction between them.
![Twin priming: a second nick primes reverse transcription upstream on the same L1 RNA, in the opposite direction, so the integrated copy carries an inverted 5' segment ahead of the 3' segment](../assets/l1-twin-priming.png)
Twin priming. The 5' segment is copied by a second priming event and integrates inverted.
For a variant caller such an insertion is one event. For RepeatMasker it is two fragments of the same L1 on opposite strands, and without a rule to join them the element reads as two hits. ## Strand signature RepeatMasker reports each fragment's strand as `+` or `C`. An L1 with a 5' inversion appears as a `C` fragment followed, along the variant sequence, by a `+` fragment, both belonging to the same L1 (RepeatMasker gives them the same link ID). Only the `C+` order counts as a 5' inversion. Reverse-complementing a twin-primed insertion flips the strand labels and the fragment order together, so the same element read from the other strand is `C+` again; which strand it sits on comes from the consensus coordinates instead, below.
![A RepeatMasker .out excerpt in which two fragments share one link ID, the first on strand C and the second on strand +](../assets/l1-strand-pattern.png)
The C+ pattern in RepeatMasker output.
## How GraffiTE detects it `annotate_vcf.R` groups the fragments of each RepeatMasker link ID into one hit and records the distinct strands of its fragments, in query order, as one string (`C+`, `+`, `C`, `+C`). A hit is flagged as an L1 5' inversion when its class is `LINE/L1` and that string is exactly `C+`. The rule does not count the fragments: a `C` piece followed by two `+` pieces also qualifies. `bin/annotate_vcf.R:104,119` `annotate_vcf.R` then derives the strand of the element as a whole, because neither fragment's strand is the answer. It compares the consensus coordinate where each fragment begins: if the `C` fragment begins at a lower consensus position than the `+` fragment, the element is on the `+` strand; otherwise it is on `C`. That inferred value is what `RM_hit_strands` reports for the hit, and `polyA` is scanned on the end that strand implies. Every other hit reports its fragments' strands as they came. `bin/annotate_vcf.R:120-127`, `bin/add_polyA.py:116`
![Consensus coordinates of the two fragments for a plus-strand and a minus-strand L1 with a 5' inversion](../assets/l1-consensus-coordinates.png)
Inferring the strand from where the two fragments sit on the L1 consensus.
The rule runs on every dataset, not only human ones. It needs the library to name the class `LINE/L1`, and it applies to any L1 subfamily in it. ## L1_5PINV field | Value | Meaning | |---|---| | `None` | No hit on the variant matched the rule (this is also the value for variants with no hit at all). | | `` | The RepeatMasker link ID of the hit flagged as inverted, the same number that appears in `RM_hit_IDs`, so the fragments can be found in `repeatmasker_dir/indels.fa.out`. Several IDs are comma-separated. | `bin/annotate_vcf.R:177,213`, `bin/repmask_vcf.sh:30,181` Such a variant still has `n_hits=1` when the inverted L1 is its only element, so it is eligible for the trusted and human subsets like any other single-hit L1. In v1.0 the field was `mam_filter_1`, written only with `--mammal`, and its value was the inferred strand: `5P_INV:plus`, `5P_INV:minus`, or `None`. # SVA VNTR polymorphisms !!! info "Applies to GraffiTE v1.1" Verified against `v1.1.0.0` at commit `bf51777`. The [2024 paper](https://www.nature.com/articles/s41467-024-53294-2) describes v1.0, which differs in places; see [v1.0 vs v1.1](../getting-started/v1.0-vs-v1.1.md). ## SVA structure An SVA element is a composite: a hexamer repeat at the 5' end, an *Alu*-like region, a variable number of tandem repeats (the VNTR), a SINE-R region derived from an endogenous retrovirus, and a polyA tail. The VNTR is made of GC-rich units of roughly 37 to 50 bp, and its copy number varies between elements and between alleles of the same element.
![Structure of an SVA element: hexamer repeat, Alu-like region, VNTR, SINE-R, polyA tail](../assets/sva-vntr-structure.png)
The regions of an SVA element. The VNTR is the part that expands and contracts.
## VNTR-only polymorphisms Because the VNTR is a tandem array, it changes length by replication slippage or unequal recombination without any transposition. Between two haplotypes that both carry the same SVA, one can have a longer VNTR than the other, and an SV caller reports that difference as an insertion or a deletion of a few hundred bp. RepeatMasker then annotates the variant sequence as SVA, since VNTR sequence is SVA sequence, and without a rule to catch it the variant counts as an SVA insertion polymorphism when no element moved. GraffiTE recognizes these by where the hit lands on the consensus: a variant whose single SVA fragment sits entirely inside the VNTR region of its subfamily is a VNTR-only polymorphism. ## VNTR coordinates by subfamily The VNTR interval on each subfamily consensus, as fixed in `annotate_vcf.R`: | Subfamily | VNTR start | VNTR end | |---|---|---| | `SVA_A` | 436 | 855 | | `SVA_B` | 431 | 867 | | `SVA_C` | 432 | 851 | | `SVA_D` | 432 | 689 | | `SVA_E` | 428 | 864 | | `SVA_F` | 435 | 857 | `bin/annotate_vcf.R:132-134` The coordinates are those of the Dfam human consensus sequences with those names, so the rule only fires for a library that uses them. A hit named otherwise (`SVA_F1`, or a species-specific name) is left as is. ## How GraffiTE reclassifies them A hit is a VNTR-only polymorphism when all of these hold: `bin/annotate_vcf.R:136-149` - its class is `Retroposon/SVA`; - it is a single RepeatMasker fragment; - its name is one of the six subfamilies above; - its start on the consensus is greater than the subfamily's VNTR start, and its end is less than the VNTR end (strictly inside on both sides). Such a hit is then written with a `(VNTR_only)` suffix on its name in `repeat_ids`, and its entry in `matching_classes` becomes `Simple_repeat` instead of `Retroposon/SVA`. The hit is still counted in `n_hits` and still contributes to `total_repeat_span`. `bin/annotate_vcf.R:151-156` ```text repeat_ids=SVA_F(VNTR_only);matching_classes=Simple_repeat ``` The downstream filters read the relabeled fields: - The **trusted subset** admits a `Simple_repeat` record without testing its `ULTRA_TR_span`, so a VNTR expansion (which is all tandem repeat) is not excluded on that ground. `module/main.nf:17` - The **`--human` filter** admits `Simple_repeat` records whose `repeat_ids` match `--human_sva_ids` (default `^SVA_[DEF]`), without requiring a polyA tail, so VNTR polymorphisms of the young subfamilies reach `pangenome.human.vcf`, distinguishable from SVA insertions by the suffix. `module/main.nf:543,545,550`, `nextflow.config:72` To count SVA insertion polymorphisms alone, exclude them: ```bash bcftools view -e 'INFO/repeat_ids~"VNTR_only"' pangenome.human.vcf ``` ## VNTR records in the subsets !!! warning "`pangenome.trusted.vcf` and `pangenome.human.vcf` are not a VNTR catalog" On the dataset below they keep one VNTR-only record in eleven, and the ones they keep are the longest. Read `pangenome.vcf` for VNTR work. A later release will size these records in VNTR units instead of bp. Both subsets require `|SVLEN|` of at least 250 bp (`--trusted_min_svlen`, `--human_min_svlen`). We set that threshold for insertions, where 250 bp is a truncated *Alu*. The VNTR unit is about 49 bp, so the same threshold requires a VNTR change to span five units, and most changes are smaller. Measured on the 20-genome HPRC assembly set (PAV discovery, graph genotyping) used for the v1.1 human analysis: | | records | |---|---| | `repeat_ids~"VNTR_only"` in the annotated callset | 1,141 | | of those, `\|SVLEN\| < 250` bp, so dropped by the default | **1,039 (91%)** | | median length change | 126 bp | The length distribution peaks at 50, 78, 98, 127, 176 and 225 bp. Those are sums of a 49 bp and a 78 bp VNTR unit, with 127 = 49 + 78 as the higher-order repeat, and the 250 bp default sits above every one of them. `--human_sva_ids` cuts further. GraffiTE matches it against `repeat_ids`, which for a VNTR-only record names the consensus the VNTR sequence scored best against. That is not the subfamily of the element hosting it: on the dataset above the two agree for 402 of 1,138 records (35%), and 65% of the VNTR changes sitting in an SVA_A, SVA_B or SVA_C element are annotated to an old consensus. The default `^SVA_[DEF]` therefore drops them. That filter alone takes SVA_A host elements from 20.4% carrying a variable VNTR to 3.2%, which looks like a difference between subfamilies and is not one. With both filters off, 20% of reference SVA_A elements of at least 1 kb in CHM13v2 carry a variable VNTR across the 20 samples, and 54% of SVA_F elements do. With both filters on, 0% and 10%. The SV callers set a floor below that. The PAV path keeps `|SVLEN| > 50` `module/main.nf:170`, and the sniffles and svim-asm paths require 100 bp `module/main.nf:113,131,187`. On the run above the smallest annotated VNTR record is 50 bp, about one unit, so single-unit changes sit at the edge of what the callset records. ### Working with the full set Take the VNTR-only records from `pangenome.vcf`, which carries no size or subfamily filter, and apply your own rules: ```bash bcftools view -i 'INFO/repeat_ids~"VNTR_only"' pangenome.vcf ``` Genotypes for the same records are in the merged genotyped VCF, which GraffiTE annotates from `pangenome.vcf` and likewise does not filter. To get them inside `pangenome.human.vcf` instead, lower the threshold and widen the subfamily list: ```bash nextflow run cgroza/GraffiTE --human \ --human_min_svlen 50 \ --human_sva_ids '^SVA_' ``` Both changes loosen the filter for SVA insertions too, which is usually not what you want, so prefer reading `pangenome.vcf` unless you need the whole subset relaxed. In v1.0 the same records were flagged with `mam_filter_2=VNTR_ONLY:::`, only with `--mammal`, and kept their `Retroposon/SVA` class. # HERV-K (HML-2) biology !!! info "Applies to GraffiTE v1.1" Verified against `v1.1.0.0` at commit `bf51777`. The [2024 paper](https://www.nature.com/articles/s41467-024-53294-2) describes v1.0, which differs in places; see [v1.0 vs v1.1](../getting-started/v1.0-vs-v1.1.md). HERV-K classification runs only under `--human`; the procedure is in [Human MEIs](../guides/human-mei.md). ## HML-2 architecture A HERV-K (HML-2) provirus is `LTR - INT - LTR`: two identical long terminal repeats of 968 bp (`LTR5_Hs`; `LTR5A` is 1,033 bp) flanking a 7,536 bp internal region, 9,472 bp in all `bin/hervk_arch.py:56-57`, `bin/hervk_classify.py:49-51`. Homologous recombination between the two LTRs excises the intervening `LTR + INT`, 8,504 bp whatever the crossover point, and leaves a single recombinant solo LTR.
[figure: hervk-locus-states]
The states one locus can hold, and the value each carries in HERVK_ALLELE_REF and HERVK_ALLELE. A fifth value, partial, names a reference element that is neither a whole LTR nor a provirus with both LTRs.
A structural variant call is always a statement about **two** of these states, and the polymorphism type depends on which two. A `null` allele against anything else is an insertion polymorphism, the event behind the difference being a transposition; that is what the `HERVK_MEI` flag records, and what makes a HERV-K locus comparable to an Alu or L1 insertion. Solo LTR against provirus, or one unit against two, is structural variation in an element every haplotype carries `bin/hervk_reconcile.py:136-170`. ## Why size alone cannot tell them apart An 8,504 bp insertion is equally consistent with `LTR + INT` entering a solo LTR and with a complete provirus entering an empty site whose internal region carries a deletion. GraffiTE therefore does not classify on size. It reads the **architecture** of the variant allele out of the raw RepeatMasker fragments, and where that is ambiguous it reads the state off the **masked reference** at the locus. Two architectures name the allele pair directly `bin/hervk_arch.py:254-356`: - **Two full terminal LTRs**, each running the length of its family's consensus, to within `perm_tol` (50 bp) at either end, with internal sequence between them. The consensus length is the family's: 968 bp for `LTR5_Hs`, `LTR5B` and `LTR5`, 1,033 bp for `LTR5A` `bin/hervk_arch.py:56,75,328-338`. Nothing was consumed by the alignment, so the variant carries a whole provirus. Reported as `ARCH_2LTR`. - **One LTR split across the termini**: the 5' fragment covering consensus `k+1..L` and the 3' fragment `1..k`, complementary and summing to one LTR. The aligner broke a reference LTR at position `k`, so the reference held one. Reported as `ARCH_PERM`. The same split inside the internal region is `ARCH_INT_PERM`, with its point in `HERVK_J`. The variant's polarity sets which side of the pair it carries. For an insertion the architecture describes the allele being added; for a deletion it describes reference sequence being removed, so `ARCH_2LTR` reads `provirus -> null` on a `DEL` and `null -> provirus` on an `INS`. Where the masked reference already holds a provirus, the classifier overrides that `INS` reading and calls one unit gained, `provirus -> prov_x2`, keeping `HERVK_EVIDENCE` at `ARCH_2LTR` and adding `CNV_UNITS:1->2,UNIT_COUNT_ASSUMED` to `HERVK_NOTE`. It does the same for `ARCH_PERM` `bin/hervk_classify.py:322-363`. `HERVK_K` records `k`. It is a property of the **alignment**, not of the biology: the inserted length is the same for every `k`, so the gap penalty cancels and the handful of substitutions separating the two LTR copies sets the placement. It varies between haplotypes and between callers, so do not key on its value. At `k = 0` the split is degenerate: one whole LTR and nothing at the other end, which is indistinguishable from a one-LTR-truncated provirus. The reference check is therefore the main mechanism: the classifier masks the reference in a window of `--hervk_ref_flank` (1,500 bp) either side of the candidate, widens it when an element runs into the edge, and calls the state from the LTR and internal-region base pairs the window holds `bin/hervk_ref_state.py:46-72, 272-292`. ## `HERVK_CLASS` values `HERVK_ALLELE_REF` and `HERVK_ALLELE` give the states directly; read those in downstream analysis. `HERVK_CLASS` names the pair, not the direction `bin/hervk_classify.py:274-288, 424-467`: | `HERVK_CLASS` | states | | |---|---|---| | `null_solo` | null, solo | a solo LTR segregates | | `solo_prov` | solo, provirus | dimorphic; no null observed | | `truncated_prov` | as `null_prov` or `solo_prov`, with less than 80 % of the internal region | | | `null_prov` | null, provirus | a whole provirus segregates | | `copy_number` | `prov_xN`, `prov_xM` | the array gains or loses whole units | | `other` | | not resolved to two HML-2 states | `HERVK_EVIDENCE` says what settled the call: `ARCH_2LTR`, `ARCH_PERM`, `ARCH_INT_PERM`, `ARCH_SOLO`, `CNV_PERIOD`, `REF_ANNOT` (from the reference state), `UNRESOLVED`, or `NON_HML2` (a candidate with fewer than 50 bp of HML-2 sequence) `bin/hervk_classify.py:434-436`. `HERVK_PMAP` is a confidence under a size model and never determines a class. ## Copy-number loci An HML-2 locus is not always one provirus. In a cohort of 20 diploid human genomes, the locus at chr7:4.70 Mb carries two units in tandem sharing a central LTR, and one, two and three units all segregate `module/main.nf:555-562`. The reference step counts the units of a proviral reference element and measures their period, one internal region plus one LTR (`HERVK_N_UNITS_REF`, `HERVK_UNIT_BP`) `bin/hervk_ref_state.py:238-270`. An SV whose `|SVLEN|` lands on a whole number of that period, within 50 bp or 0.5 % of its length, changes copy number by that many units. Those states are written `prov_xN`, with `provirus` as the `N = 1` spelling. Zero units is a solo LTR, because an array of N units carries N + 1 LTRs and removing every unit leaves the one they shared, so the familiar solo/provirus dimorphism is the `N = 1` case of the same arithmetic `bin/hervk_classify.py:225-271`. The geometry, one internal region plus exactly one LTR with the junction inside the LTR the two copies share, is what unequal exchange between misaligned units produces. Hughes and Coffin (2004, *PNAS* 101:1668-1672) proposed that mechanism for the tandem HERV-K108 allele and suggested a solo LTR they found was its reciprocal product. **`hervk_reconcile` withholds graph genotypes at these loci** (`HERVK_GT_MASKED`). The ALT path repeats sequence the reference already carries, so reads from the pre-existing copy traverse it and non-carriers pick up ALT support; in our run on the 20-genome cohort the ALT fraction at such a locus tracked provirus dosage rather than carriage. Discovery genotypes come from haplotype-resolved alignments, do not have this problem, and carry the allele counts (`HERVK_AC_DISC`, `HERVK_AN_DISC`). Set `--hervk_mask_graph_gt_at_cnv false` to keep the graph calls `nextflow.config:103-111`. ## Why the SVA hits are not SVA RepeatMasker frequently reports an `SVA_*` hit at the terminus of an HML-2 element. This is homology, not a second element: SVA's SINE-R domain is HERV-K LTR derived. GraffiTE treats an SVA hit that starts at SVA consensus position 900 or later and abuts HML-2 sequence within 50 bp as SINE-R, reassigns it to the LTR class and tiles hits winner-take-all along the variant, so an SVA hit lying on top of an `LTR5_Hs` hit is counted once `bin/hervk_arch.py:69-84, 201-233`. The same homology is why the `--human` filter carries its HERVK + SVA carve-out ([Human MEIs](../guides/human-mei.md)). ## Library naming The internal region is named `HERVK` by Dfam and `HERVK-int` by RepBase-derived sets; `HERVK_int` and `HERVKint` also occur. The classifier recognizes all of them, so no modified library is needed `bin/hervk_arch.py:65`. `HERVK9-int`, `HERVK11-int`, `HERVK14-int` and `HERVKC4-int` are deliberately *not* matched: they are separate ERV lineages. The LTR families recognized are `LTR5_Hs`, `LTR5A`, `LTR5B` and `LTR5` `bin/hervk_arch.py:56`. The carve-out in the `--human` filter is stricter than the classifier: it requires the literal name `HERVK-int`; see the note in [Human MEIs](../guides/human-mei.md). # Troubleshooting !!! info "Applies to GraffiTE v1.1" Verified against `v1.1.0.0` at commit `bf51777`. The [2024 paper](https://www.nature.com/articles/s41467-024-53294-2) describes v1.0, which differs in places; see [v1.0 vs v1.1](getting-started/v1.0-vs-v1.1.md). --- ## Nextflow 26 rejects main.nf with "Unexpected input" ``` Error main.nf:158:27: Unexpected input: 'splitText' ``` You are running a checkout older than commit `4605630` (2026-09-10, on `v1.1dev` since 2026-09-15) on Nextflow 26, whose default parser is the strict one. Update to a newer commit, or select the legacy parser for that checkout: ```bash export NXF_SYNTAX_PARSER=v1 ``` Nextflow 26's default parser passes a command-line `--flag false` as the string `"false"`, which Groovy treats as true. Before commit `cfaff1e`, GraffiTE ran genotyping on Nextflow 26 even with `--genotype false`. Since that commit GraffiTE reads every boolean parameter through `isOn()` `module/main.nf:1-9`, which returns the same value under both parsers. --- ## Messages the workflow prints on purpose Each of these stops the run before any process starts. | Message | Cause | What to do | |---|---|---| | `No input given. Pass one of --longreads, --bams, --assemblies, --pav, --svs (discovery), --vcf (a merged SV VCF), --RM_dir (RepeatMasker output of an earlier run) or --graffite_vcf (a pangenome.vcf from an earlier run).` `main.nf:151` | No entry flag on the command line. | Pick one on [Choosing your inputs](getting-started/choosing-your-inputs.md). | | `--vcf cannot be combined with --assemblies. Pass --vcf alone, or drop it and use --svs to add your own per-sample VCFs to the discovery merge.` `main.nf:46-49` | `--vcf` replaces the discovery merge, so a discovery flag beside it has no merge to feed. | Use `--svs` if you want your VCF merged with caller output. | | `--graph_method precomputed builds nothing itself: it needs --graph (...) and either --vcfs (...) or --graph_alignments (...).` `main.nf:53-56` | `precomputed` reuses a graph and alignments from an earlier run and was not given both. | Pass `--graph` plus `--vcfs` or `--graph_alignments`, or choose another method. | | `Unsupported --graph_method. --graph_method must be pangenie, giraffe, graphaligner or precomputed.` `main.nf:263` | A misspelled method. | One of the four. | | `--graffite_vcf skips discovery, and HERV-K reconciliation needs the hervk_annotate outputs discovery produces. Pass --hervk_reconcile false, or start from --RM_dir instead of --graffite_vcf.` `main.nf:61-63` | `--human` consolidation reads files that only the annotation stage writes. | Either option in the message. | | `With --human, hervk_reconcile consolidates HERV-K loci in vg call genotypes, and --graph_method pangenie does not produce them. Pass --hervk_reconcile false to genotype with PanGenie, or choose --graph_method giraffe, graphaligner or precomputed.` `main.nf:65-71` | `--human` with PanGenie genotyping, the default `--graph_method`; the reconciler reads `vg call` genotypes only. | Either option in the message. | | `Error main.nf:12:1: Invalid include source: '/panmethyl/module.nf'` `main.nf:12` | A clone made without `--recurse-submodules`; the `panmethyl` submodule directory is empty. This one is Nextflow's own message. | `git submodule update --init` in the clone. `nextflow pull` clones do not hit this. | --- ## A process cannot see an input file Every container runs with `--contain --bind $(pwd):/tmp` `nextflow.config:181`. Files outside the launch directory are only visible if given by absolute path, and `/tmp` inside the container is the directory the task runs in. Symptoms are `No such file` inside a process for a file that exists on the host, or a full filesystem when the filesystem holding `work/` is small. Use absolute paths, and bind a larger scratch directory to `/tmp` if needed; see [Installation](getting-started/installation.md). --- ## `TSD_summary.txt` is empty and no record has `INFO/TSD` On `v1.1dev` before commit `884afa8` the flank extraction failed without an error on a gzip-compressed reference, and a missing `exact_match.py` read as no hit on every variant. Both now stop the run instead. If your copy is older than that commit, update it ([Installation](getting-started/installation.md#updating)); `test/tsd/test_tsd_chain.sh` checks the chain. --- ## `variant IDs must be no greater than 50 characters` The annotation script stops on any variant ID longer than 50 characters `bin/repmask_vcf.sh:41-45`, the length RepeatMasker keeps intact in its output. IDs written by the pipeline's own callers are short. The message appears with `--vcf`, whose IDs pass through unchanged `module/main.nf:205-207`, or with `--svs`: rename them before the run. --- ## RepeatMasker runs out of memory or time Stage 2 is split by contig `module/main.nf:495-508` and each piece runs with `--repeatmasker_memory` (default `10G`) and `--repeatmasker_time` (default `12h`) `nextflow.config:151-153`. Raise them, and raise `--repeatmasker_threads`, for large contigs or large libraries. Nextflow's message when a job is killed by the scheduler can be misleading; check the `.command.log` in the failing work directory. For maize-sized, repeat-rich genomes users have requested up to 120 h and 400 GB per process, with long-read alignment the most demanding step. See [Resources and scaling](guides/resources.md). --- ## `3_TSD_search/pangenome.vcf` missing after a finished run Check whether `tsd_search` and `tsd_report` ran. When the container cannot write to `/tmp` the pipeline can skip them and still report success. `/tmp` inside the container is the task's own directory by default; point `--container_tmp` at a writable directory instead, see [Paths and `/tmp`](getting-started/installation.md#paths-and-tmp). The other way to get here is a run where no chunk survived annotation. Stage 2 is split one piece per contig `module/main.nf:495-508`, and a chunk whose records all fail `--repeat_span_cutoff` drops out by design. If every chunk drops out, `concat_repeatmask` never runs and nothing says so. `2_Repeat_Filtering/*/genotypes_repmasked_filtered.vcf` holds the per-chunk record counts. --- ## `cgroza/GraffiTE contains uncommitted changes -- cannot pull from repository` The pipeline cached under `~/.nextflow/assets/cgroza/GraffiTE/` was edited in place. Delete it and pull again; see [Installation](getting-started/installation.md#updating). Usually the edit was to `nextflow.config`, to bind a scratch directory to `/tmp`. That is what `--container_tmp` is for; use it and leave the cached copy alone. --- ## A full-length LTR element shows `n_hits` greater than 1 RepeatMasker annotates the LTR and the internal region of an LTR retrotransposon as separate hits when they are separate entries in the library, and the pipeline reports what RepeatMasker finds. Such an element has `n_hits=2` or `3` and is left out of the subsets that require a single hit (`pangenome.trusted.vcf`, and `pangenome.human.vcf` apart from the HERV-K pair rule `module/main.nf:17,550,570-571`). It stays in `pangenome.vcf` with all its hits listed. A library entry that holds the full element as one consensus gives one hit. --- ## Slow runs Two steps dominate: `samtools sort` after minimap2, whose threads and memory are set by `--stSort_t` and `--stSort_m`, and RepeatMasker with a large library and many SVs. `-with-report report.html` shows where the time went and which requests to change. --- ## A tool is missing, or a fixed bug is still there If a run fails on a tool the image is supposed to carry, or a bug fixed in a rebuilt image is still happening, check the image you are running before anything else. Nextflow's Singularity cache is keyed on the image name, so it reuses an old `cgroza-graffite-latest.img` after the tag is rebuilt, and says nothing about it. ```bash apptainer inspect /path/to/cgroza-graffite-latest.img | grep base.digest ``` Compare that with the registry. If it differs, delete the cached file and let Nextflow pull again; see [Updating](getting-started/installation.md#updating). --- ## Getting help Open an issue at . It is the only channel the authors watch, and someone may have hit the same thing. Include the commit you run (`nextflow info cgroza/GraffiTE`), the command line, and the `.command.log` of the failing task. # Changelog !!! info "Applies to GraffiTE v1.1" Verified against `v1.1.0.0` at commit `bf51777`. The [2024 paper](https://www.nature.com/articles/s41467-024-53294-2) describes v1.0, which differs in places; see [v1.0 vs v1.1](getting-started/v1.0-vs-v1.1.md). Entries before v1.1 are the README's, kept with their original dates. From beta 0.2.5 to v1.1, releases were identified by commit. From v1.1.0.0, each release is a git tag, `vW.X.Y.Z`; give the version you run when asking for help. --- ## v1.1.0.0 (2026-10-17) Versions now have four numbers, W.X.Y.Z; [CONTRIBUTING.md](https://github.com/cgroza/GraffiTE/blob/main/CONTRIBUTING.md) says what each one means. This release names its own image, `cgroza/graffite:1.1.0.0`, so a run of it pulls the image it needs. **Annotation** - Tandem repeats annotated with [ULTRA](https://github.com/TravisWheelerLab/ULTRA) after RepeatMasker: `ULTRA_TR` (non-redundant bp of tandem repeat) and `ULTRA_TR_span` (fraction of the variant, capped at 1). - New filter metric `total_repeat_span`, the non-redundant union of RepeatMasker TE hits and ULTRA tandem repeats over the variant length, in place of `total_match_span` alone. Long insertions where a TE sits next to a polyA or tandem tail are kept. `--repeat_span_cutoff` (default `0.80`) sets the threshold. - polyA tail detection: `polyA=TRUE` or `FALSE` on single-hit records and `NA` where `n_hits` is above 1, after trimming an exact TSD copy from the variant end. - `--mammal` discontinued. L1 5' inversion detection and SVA VNTR-only handling run on every dataset. - L1 5' inversions reported as `INFO/L1_5PINV` (the hit ID of the inverted fragment, or `None`) in place of `mam_filter_1=5P_INV`. - SVA hits that fall inside the VNTR region are renamed with a `(VNTR_only)` suffix and reclassified from `Retroposon/SVA` to `Simple_repeat`; `mam_filter_2` removed. - OneCodeToFindThemAll removed from the annotation step; the RepeatMasker `.out` is read directly. - `concat_repeatmask` accepts a gzip-compressed `--reference` and re-compresses it to BGZF. **Genotyping** - `GraffiTE.merged.genotypes.trusted.vcf.gz` and `GraffiTE.merged.genotypes.presence-absence_trusted.tsv`, the counterpart of `pangenome.trusted.vcf` for the genotyped calls: every record has one repeat class. Governed by the same `--trusted_*` parameters, and not written under `--human` (PR #103, issue #93). - `genotyping_record_audit.tsv`, one row per `pangenome.vcf` ALT allele, saying whether the graph genotyped it, whether the annotation reached it, and which stage dropped it. - The pangenie back end split PanGenie's records with `bcftools norm -f -m-`, and `-f` also left-aligns. `pangenome.vcf` was left-aligned only when two or more caller VCFs went through the truvari merge, so on `--vcf`, single-caller and `--graffite_vcf` runs an insertion inside a homopolymer came back at a shifted position and lost its whole annotation at the merge. `-N` keeps the position. **Contigs with nothing to mask** - The run no longer stops on a contig whose records are all non-indel. `tsd_prep` and `tsd_search` dropped a `cp` of the RepeatMasker directory that nothing had read since v1.0, and `repmask_vcf.sh` now runs under `set -e` with an explicit path for a chunk with nothing to mask (issue #93). **Execution** - `--container_tmp` binds a directory of your choice to `/tmp` inside the container, in place of editing `singularity.runOptions` in the cached copy of `nextflow.config` (which then breaks `nextflow pull` and `-latest`). - The image is pinned: every process but `pav_asm` runs `docker://cgroza/graffite:1.1.0.0`, built from `Dockerfile`. Each release has its own tag, and `latest` follows the newest release. `GraffiTE.def` is unmaintained. - `-profile cloud` runs on AWS Batch, with the `awsbatch` executor and Docker in place of Singularity. Before, it named an executor, `aws`, that Nextflow does not have. `pav_asm` cannot run there. Not tested. - `--pangenie_memory` defaults to `32G` (was unset), so Nextflow starts only as many PanGenie tasks at once as the memory allows. - A quick install test ships in `test/quick_test.tar.gz`; see [Installation](getting-started/installation.md#quick-install-test). **Subsets** - `pangenome.trusted.vcf` and matching `*.presence-absence*.tsv` tables next to `pangenome.vcf`; trusted records carry `FILTER=PASS`. Parameters `--trusted_min_svlen` (250), `--trusted_max_ultra_span` (0.6), `--trusted_ignore_filter`. The trusted subset has no polyA requirement, and the `--human` subset has one. - `--human` rebuilt from `pangenome.vcf` by its own filter, output `pangenome.human.vcf` (was `pangenome.trusted.human.vcf`); `pangenome.trusted.vcf` is not written on `--human` runs. The filter keeps `AluY*`, `L1HS`, `SVA_D/E/F` and the HML-2 lineage, and admits the `HERVK-int`+`SVA` proviral pattern up to `--hervk_pair_max_hits` hits (PR #98). Whitelists and thresholds are parameters; `human_filter_summary.txt` reports what was kept and dropped. **Known limitation: the subsets truncate SVA VNTR polymorphisms** - `--trusted_min_svlen` and `--human_min_svlen` default to 250 bp, a threshold sized for insertions. The SVA VNTR unit is about 49 bp, so the default requires a VNTR length change to span five units. On the 20-genome HPRC set it keeps 102 of 1,141 `SVA_*(VNTR_only)` records; the median change is 126 bp. - `--human_sva_ids` (`^SVA_[DEF]`) is matched against `repeat_ids`, which for a VNTR-only record names the consensus its sequence scored against. That agrees with the host element's subfamily for 35% of records, so the default drops VNTR changes inside old SVAs and makes the subfamilies look more different than they are. - Neither filter touches `pangenome.vcf` or the merged genotyped VCF, so the full set is available; see [SVA VNTR polymorphisms](background/sva-vntr.md#vntr-records-in-the-subsets). - A later release will size the VNTR-only records in VNTR units and stop `--human_sva_ids` from gating them. **HERV-K (HML-2) classifier, `--human` only** (PRs #94 to #97) - Evidence-first allele-state classifier from the element's architecture and from masking the reference at the locus (`hervk_classify.py`, `hervk_arch.py`, `hervk_ref_state.py`), with the `ARCH_INT_PERM` internal-region permutation signature and copy-number allele states. - Loci clustered by overlap and flagged (`HERVK_LOCUS`, `HERVK_MEI`, `HERVK_CNV`, ...); graph genotypes withheld per allele at copy-number and tandem-duplication loci (`--hervk_mask_graph_gt_at_cnv`). - Consolidated VCFs, one record per locus: `pangenome.human.consolidated.vcf` in discovery and `GraffiTE.merged.genotypes.human.vcf.gz` after genotyping, with reports; `--hervk_reconcile`, `--hervk_reconcile_vcf` to consolidate an existing genotyped VCF with `--genotype false`. - `hervk_candidates.vcf` holds the full candidate set; `--hervk_max_svlen`, `--hervk_ref_flank`, `--hervk_locus_window`, `--hervk_ref_annotation`, `--hervk_strict`, `--hervk_config`. - `human_hervk_ids` accepts both `HERVK-int` and Dfam's bare `HERVK` for the internal region. **Inputs and genotyping** - `--svs`: per-sample VCFs fed straight into the merge. - `--pav`: the PAV caller as a discovery entry point. - `vg call` receives `-a -A` on every graph method, and ploidy 1 on `chrX` and `chrY`. - Precomputed graph alignments: `--graph_alignments` (CSV `sample,gaf,pack`), published to `GraffiTE_alignments/`. - `--break_scaffolds` splits only at runs of at least `--break_scaffolds_min_gap` `N`, 10 by default. It used to split at every `N`, which cut any insertion carrying one; on the synthetic test set it lost 14 of 29 records (`2e13c68`). - `--epigenomes`: the panmethyl submodule moves to `f0aa2c0` (`0fba182`). `annotate_vcf.py` stopped with a `TypeError` on a record whose genotype is missing altogether (`GT` is `.`); it now leaves that record out of the sample's annotated VCF. `tagtobed` exited before its writer thread had finished, so `bamtags_to_BED` kept a different subset of each BAM's calls from run to run. The `tagtobed` fix ([panmethyl#3](https://github.com/cgroza/panmethyl/pull/3)) is in the image. `Dockerfile` and `GraffiTE.def` now check out the submodule's commit after cloning panmethyl, where they used to build from its default branch (`2cdb8c4`). **TSD chain** - `prepTSD.sh` reads the flanks through htslib, re-compresses a gzip reference to BGZF, and stops the run instead of writing an empty flank file; a missing `exact_match.py` is an error rather than no hits; `add_polyA.py` splits the two-copy `TSD` value before trimming (in a pipeline run, only from `d1dfd7b` on; see below). Test: `test/tsd/test_tsd_chain.sh` (commit `884afa8`). - `TSD_Match_v2.sh` measured start offsets from `WIN` instead of `WIN + 1`, so a TSD at the start of the variant scored 1, and a shorter match scoring 0.5 beat it, usually a 4 bp AAAA where a TSD opening with As meets the poly(A) tail. Start offsets now count from `WIN + 1`, and candidates scoring 1.5 or less are ties won by the longest. On the 5,819 records of a 20-genome human run, 1,039 TSD calls got longer and 6 shorter. Test: `test/tsd/test_tsd_match.sh` (commit `d268d93`). - In a pipeline run `add_polyA.py` trimmed no TSD before scanning for a tail. `fix_vcf.py` rewrites `pangenome.vcf` with vcfpy, which wrote the comma of the `Number=1` `INFO/TSD` as `%2C`, so `add_polyA.py` could not split the value into its two copies. `INFO/TSD` is now `Number=2` and keeps its comma, in `pangenome.vcf` and in the `TSD` column of the presence-absence TSVs, and `add_polyA.py` decodes `%2C` in VCFs from earlier runs. On the 5,819 records of a 20-genome human run, with the `d268d93` TSD calls, 17 single-hit records (15 Alu, 1 L1, 1 SVA) go from `polyA=TRUE` to `FALSE` and leave `pangenome.human.vcf`. Records outside that subset were not rerun, so any that turn `TRUE` are not counted. Test: `test/tsd/test_tsd_chain.sh` now runs `fix_vcf.py` (commit `d1dfd7b`). - TSD candidates shorter than 6 bp count only when they sit on the junction (score 0.5 or less). With each insertion's R window swapped for another's, so that no duplication can exist, the search passed a match in 72% of Alu, L1 and SVA pairs; with the rule, 36%. On the 5,614 Alu, L1 and SVA records of a 20-genome human run, 53 short calls are dropped and 33 switch to a longer candidate. Through the TSD trim, `polyA` changes on 2 of all 5,819 records, both `LTR/ERVK`, for which no filter reads `polyA`. Test: `test/tsd/test_tsd_match.sh`, cases 5 and 6 (commit `cc1f3ac`). - `add_polyA.py` counts a tail found with or without the `TSD` copy trimmed. When the TSD search reported a run of the tail base as the duplication, trimming it removed the tail: from `d1dfd7b` on, the 17 single-hit records above (15 Alu, 1 L1, 1 SVA) read `polyA=FALSE` although each has a tail at the expected end. They keep `polyA=TRUE` again. On the same run, 114 records (96 Alu, 17 L1, 1 SVA) that failed `--human` on `polyA` alone in earlier versions pass once their `TSD` copy is trimmed, and no record of that run's `pangenome.human.vcf` is lost. Test: `test/tsd/test_add_polyA.sh` (commit `19da5f8`). **PanGenie and Nextflow 26** (PR #101, 2026-09-14) - PanGenie genotyped one sample and stopped: the reference reached the process as a queue channel with one item (`397fe2b`). - `merge_vcfs.py` stopped on records that shared a position with different or missing IDs ([issue #93](https://github.com/cgroza/GraffiTE/issues/93)). `pangenie_graph_vcf.py` prepares the graph input and publishes `4_Genotyping/pangenie_graph_variants.tsv`, which maps every `pangenome.vcf` allele to the ID PanGenie writes in `INFO/ID` (`b9b5b5c`). - `truvari_merge` failed on a missing file with two or more input VCFs (`29341a3`). - `main.nf` and `module/main.nf` compile under Nextflow 26's strict syntax (`4605630`). **polyA and PanGenie contig headers** (PR #107, 2026-09-19) - `INFO/polyA` read `FALSE` on every record whenever two or more caller VCFs went through the truvari merge. `truvari_merge` strips the upstream INFO fields and puts only `SVLEN` back, so `SVTYPE` had gone by the time `add_polyA.py` ran and it scanned an empty string. The `--human` filter selects Alu, L1 and SVA on `polyA="TRUE"`, so `pangenome.human.vcf` lost those records (`module/main.nf:546-550`). `add_polyA.py` now takes the insertion polarity from `len(ALT) - len(REF)` when `SVTYPE` is absent (`97a6d01`). - `--graph_method pangenie`, the default, produced no genotypes. PanGenie writes its output with no `##contig` lines, and the `bcftools norm -Oz` on the next line cannot BCF-encode a record whose CHROM is not in the header. `samtools faidx` and `bcftools reheader -f` now run first (`5ad9bea`). **HERV-K consolidation and the genotyping back end** (issue #100) - `hervk_reconcile` accepted giraffe genotypes only, so a `--human` run on any other back end genotyped every sample and then stopped at the consolidation. It now accepts graphaligner and precomputed genotypes, which come from `vg call` as giraffe's do, and a `--human` run with PanGenie genotyping stops at launch unless it has `--hervk_reconcile false` (`25e417a`). **Fixes on the documentation branch** - A command-line `--flag false` read as true under Nextflow 26's parser; `--genotype false` ran genotyping. Every boolean parameter is read through `isOn()` (`cfaff1e`). - `test/human_filter/run_test.sh` did not read the single-quoted `human_hervk_ids` default and failed on every HERV-K record. - `--tsd_win` reaches the matcher; scores were computed against a fixed 30 bp (`4c8e385`). - PanGenie genotypes are split to one ALT per record before the merge; the normalized file was written but never emitted (`46c0726`). - `make_graph`'s graphaligner branch interpolated `$PWD` as a Groovy variable and could not run (`9b77788`). - `--vcf` beside a discovery flag, `--graph_method precomputed` without its inputs, and `--graffite_vcf --human` are refused with a message instead of failing on an undefined channel (`159de3f`, `b6a9487`, `9bc505b`). A guard for an empty `panmethyl/` submodule (`959044b`) was dropped again when `main.nf` moved to strict syntax, which allows no statement before an include; Nextflow's own message names the missing module file. - `svs`, `graph`, `graph_alignments`, `vcfs`, `lifted` and `bed` are declared in `nextflow.config` (`4187750`); `hervk_annotate` and `hervk_reconcile` have resource parameters (`f0698ec`); `manifest.version` matches `version.txt` (`e9f4f74`); `merge_VCFs` no longer passes `publishDir` an unknown option (`4b917b4`). - `GraffiTE.def` installs truvari, ULTRA, pyfaidx and pypy3, which the pipeline calls and the published image already had (`9cfaf15`, recipe not rebuilt). - Six unused scripts removed from `bin/` (`ebaf837`). --- ## 10/01/25 Commit [1cbebbf](https://github.com/cgroza/GraffiTE/commit/1cbebbfc0f4ccc5436670d9aa8d2023a90f2eeef). - Removed `-nolow` from the RepeatMasker call. It could produce spurious hits on low-complexity regions of some TE consensus sequences and annotate tandem repeats as TEs. Do not use `-nolow` with RepeatMasker outside debugging. ## 11/07/24 Commit [76537f9](https://github.com/cgroza/GraffiTE/commit/76537f9b5da4024ba03f760f58b024a5f485bf7a). - New `--tsd_time` option for the time request of the TSD processes under the `cluster` profile. Default `1h`. Code update only, no new image. ## 10/22/24 Commit [47ad044](https://github.com/cgroza/GraffiTE/commit/47ad04469e475e9dcbfd4ffc17faa4ba42c5d94d). Pull request by [Han-Cao](https://github.com/Han-Cao). - Faster annotation of large VCFs. - Coordinates in the SVA-VNTR module changed from 1-based to 0-based. Code update only. ## 10/21/24 - RepeatMasker coordinates transformed from 1-based to 0-based to match the BED standard and measure hit lengths exactly. Fixes [issue #43](https://github.com/cgroza/GraffiTE/issues/43). ## 06/24/24 - New option `--break_scaffolds`, which splits each scaffold into contigs at every run of `N`, however short. With some scaffolded genomes minimap2 fails with `[E::parse_cigar] CIGAR length too long at position ...`, a limit of htslib and the SAM specification; breaking scaffolds at N stretches avoids it. ## 06/17/24 - New compatible class names in the TE library: `MITE`, `TIR` and `IS`, as in `>TEnameX#MITE`, `>TEnameY#TIR/Mariner` or `>TEnameX#IS`. Earlier versions discarded them. - Accepted `Class` names in `>TEname#Class/Superfamily`: `LINE`, `LTR`, `SINE`, `RC/Helitron` (treated as `DNA/RC`), `DNA`, `TIR`, `MITE`, `Retroposon`, `IS`, `Unknown`, `Unspecified`. An entry without a class is treated as `Unknown`. Any name and superfamily is accepted when the class is one of these. ## 02/13/24 - Versions are identified by commit ID from here on. - The L1 inversion flag (`--mammal`) had stopped working; fixed. - Winnowmap available as an alternative to minimap2 with `--aligner winnowmap`. ## beta 0.2.5 (09-11-23) - Fixed a VCF annotation error when two distinct variants shared the same `POS`; annotations are now distinct by variant sequence. - Cleaner GraphAligner VCF outputs. ## beta 0.2.4 (06-27-23) - Refactored to Nextflow DSL2. ## beta 0.2.3 (02-21-22) - SV discovery from assemblies and long reads together; the calls from both are merged before filtering and genotyping. - Parameters with defaults to control time, CPU and memory for each process, for `-profile cluster`. - Variants are merged only within the same `SVTYPE`. ## beta 0.2.2 (02-01-22) - `sniffles2` as an alternative to `svim-asm`, from long reads (`--longreads`) instead of an assembly. At this release the two callers could not be combined. - `--asm_divergence ` sets the minimap2 preset ahead of `svim-asm`; default `asm5`. - `time`, `cpu` and `memory` directives per process. ## beta 0.2.1 (11-30-22) - `--RM_vcf` and `--RM_dir` to start at the TSD search from the output of a RepeatMasker run (`2_Repeat_Filtering`), for runs that crashed in the TSD search and cannot be resumed. - TSD search in batches of 100 variants, which divides the number of temporary directories by 100 and spares the inode quota; batches run in parallel. ## beta 0.2 (11-11-22) - Two new read aligners for genotyping, [giraffe](https://github.com/vgteam/vg#mapping) and [GraphAligner](https://github.com/maickrau/GraphAligner): `--graph_method [pangenie/giraffe/graphaligner]`, default `pangenie`. - `--vcf`: a sequence-resolved VCF as input, skipping genome alignment. - `--graffite_vcf`: a `3_TSD_search/pangenome.vcf` from an earlier run, skipping everything but read mapping. - Dropped the `biomartr` dependency. ## beta 0.1 (11-02-22) - First release.