Skip to content

Stage 1: SV search

Applies to GraffiTE v1.1

Verified against v1.1.0.0 at commit bf51777. The 2024 paper describes v1.0, which differs in places; see v1.0 vs v1.1.

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?

%%{init: {"flowchart": {"nodeSpacing": 14, "rankSpacing": 26, "padding": 8}}}%%
flowchart LR
    Q0("What do you<br/>start from?")
    Q0 -->|"Genome<br/>assemblies"| Q1("Call them<br/>with PAV?")
    Q1 -->|"No"| SA["<code>--assemblies</code><br/><small>minimap2, svim-asm</small>"]
    Q1 -->|"Yes"| PV["<code>--pav</code><br/><small>PAV, own container</small>"]
    Q0 -->|"Unaligned<br/>long reads"| LR["<code>--longreads</code><br/><small>minimap2, Sniffles2</small>"]
    Q0 -->|"Aligned<br/>long reads"| BM["<code>--bams</code><br/><small>Sniffles2 only</small>"]
    Q0 -->|"Your own<br/>SV calls"| Q2("One VCF per sample,<br/>or one merged VCF?")
    Q2 -->|"Per sample"| SV["<code>--svs</code><br/><small>straight to the merge</small>"]
    Q2 -->|"Merged"| VC["<code>--vcf</code><br/><small>skips Stage 1</small>"]
    SA --> M["truvari merge<br/><small>SVs.vcf</small>"]
    PV --> M
    LR --> M
    BM --> M
    SV --> M
    M --> B["Stage 2 ·<br/>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;

--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:

--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.


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):

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/<sample>.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.

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.

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.

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_<sample>.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):

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-<type>, 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.

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 <preset> 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 <INS>/<DEL> 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.

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.

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.

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

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".

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.
  • 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