Image size: 156.9 MB

For more on pulling from the registry, see the ilifu documentation.

First, once: add the registry and make it your default

singularity remote add --no-login idia-registry https://sregistry.idia.ac.za
singularity remote use idia-registry

If you added it before, as the ilifu docs describe, remote add says it already exists: just run remote use.

Log in, for a private collection

singularity remote login idia-registry

Paste a token from your token page when asked. Public collections need no login.

Pull the container

singularity pull library://bioinformatics/savvysuite:1.0-2a15928

Shell into the container

singularity shell library://bioinformatics/savvysuite:1.0-2a15928

Run the container

singularity run library://bioinformatics/savvysuite:1.0-2a15928

First, once: add the registry and make it your default

apptainer remote add --no-login idia-registry https://sregistry.idia.ac.za
apptainer remote use idia-registry

If you added it before, as the ilifu docs describe, remote add says it already exists: just run remote use.

Log in, for a private collection

apptainer remote login idia-registry

Paste a token from your token page when asked. Public collections need no login.

Pull the container

apptainer pull library://bioinformatics/savvysuite:1.0-2a15928

Shell into the container

apptainer shell library://bioinformatics/savvysuite:1.0-2a15928

Run the container

apptainer run library://bioinformatics/savvysuite:1.0-2a15928
SavvySuite 1.0-2a15928 by Matthew Wakeling, University of Exeter (https://github.com/rdemolgen/SavvySuite).
This image packages the unmodified upstream source at git commit 2a15928 (2026-07-03;
the last tagged release is v1.0), compiled to a jar. IDIA builds and maintains the image
only. Report bugs in the tools upstream: https://github.com/rdemolgen/SavvySuite/issues

SavvySuite finds CNVs, homozygous regions and shared haplotypes from off-target reads.

Programs (each is on PATH and is also an app, e.g. --app SavvyCNV):
  CoverageBinner, SelectControlSamples, SavvyCNV, SavvyCNVJointCaller,
  PrepareLinkageData, SavvyHomozygosity, SavvySharedHaplotypes, SavvyVcfHomozygosity,
  ValidateGenomeCnvsUsingAlleleBalance, SavvyContaminationFinder,
  SavvyContaminationRepairer, CoverageOffTarget, FindLargeInsertSizes

Usage:
  singularity exec savvysuite.sif CoverageBinner sample.bam > sample.coverageBinner
  JAVA_OPTS="-Xmx30g -XX:ParallelGCThreads=2 -XX:ConcGCThreads=2" \
    singularity exec savvysuite.sif SavvyCNV -d 200000 *.coverageBinner > cnv_list.csv 2> log.txt
  singularity run savvysuite.sif SavvyCNV -d 200000 *.coverageBinner   # same, via runscript
Set Java options such as -Xmx in JAVA_OPTS. CLASSPATH is set, so upstream's
"java -Xmx30g SavvyCNV ..." examples also work inside the container. Upstream docs are in
/opt/savvysuite/README.md.

Data: no reference data is included. Bind your BAM/CRAM/VCF files and, for CRAM, the
reference FASTA (CoverageBinner -R), e.g. --bind /path/to/data:/data.

Licence: SavvySuite is GPL-3.0 (/opt/savvysuite/LICENSE). It runs with Picard 3.5.0
(MIT, bundles htsjdk; /opt/savvysuite/lib/picard-LICENSE.txt and the licences inside
picard.jar) and JAMA 1.0.3 (public domain).

Citation (from upstream): for SavvyCNV, cite
  https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1009940
For the other tools, cite: Wakeling MN, De Franco E, Hattersley AT, Ellard S. Making the
most of targeted sequencing: detecting CNVs and homozygous regions using offtarget reads
with SavvyCNV. ASHG 67th Annual Meeting, Orlando, FL, 2017.

This image has 13 apps. Pick one to see how to use it.

singularity run --app CoverageBinner library://bioinformatics/savvysuite:1.0-2a15928

This works once you've added the registry as a remote (see the CLI tab). Add the app's arguments after the command. With Apptainer, start it with apptainer instead.

Help

Step 1 of CNV calling: counts the reads of one BAM, CRAM or SAM file in 200 bp bins
(-d to change; SavvyCNV's -d must be a multiple of it). Drops reads below MAPQ 30 (-mmq)
and reads clipped at both ends (-includeDoubleClip keeps them). A CRAM needs its
reference (-R); "CoverageBinner info <file>" prints a file's settings.

  singularity run --app CoverageBinner savvysuite.sif -R ref.fasta sample.cram > sample.coverageBinner

Docs: https://github.com/rdemolgen/SavvySuite/blob/2a15928/README.md#coveragebinner

Runs

exec /opt/savvysuite/bin/CoverageBinner "$@"
singularity run --app CoverageOffTarget library://bioinformatics/savvysuite:1.0-2a15928

This works once you've added the registry as a remote (see the CLI tab). Add the app's arguments after the command. With Apptainer, start it with apptainer instead.

Help

Reports how many of each sample's reads are off-target, from a set of CoverageBinner
files, and recommends a SavvyCNV -d bin size for off-target and on-target calling.
-readLength adds the mean off-target read depth; -threshold (default 5) sets the mean
reads per 200 bp bin above which a bin counts as on-target.

  singularity run --app CoverageOffTarget savvysuite.sif -readLength 150 *.coverageBinner > offtarget.txt

Docs: https://github.com/rdemolgen/SavvySuite/blob/2a15928/README.md#coverageofftarget

Runs

exec /opt/savvysuite/bin/CoverageOffTarget "$@"
singularity run --app FindLargeInsertSizes library://bioinformatics/savvysuite:1.0-2a15928

This works once you've added the registry as a remote (see the CLI tab). Add the app's arguments after the command. With Apptainer, start it with apptainer instead.

Help

Finds structural variant edges (deletions, duplications, inversions, translocations)
from read pairs with abnormal insert sizes. Events are found in the first BAM and then
counted in every BAM given, e.g. a proband then the parents; the BAMs need indexes.
Better for small CNVs than read depth; expect false positives for large events.

  singularity run --app FindLargeInsertSizes savvysuite.sif -maxInsert 1000 proband.bam mother.bam father.bam > events.txt

Docs: https://github.com/rdemolgen/SavvySuite/blob/2a15928/README.md#findlargeinsertsizes

Runs

exec /opt/savvysuite/bin/FindLargeInsertSizes "$@"
singularity run --app PrepareLinkageData library://bioinformatics/savvysuite:1.0-2a15928

This works once you've added the registry as a remote (see the CLI tab). Add the app's arguments after the command. With Apptainer, start it with apptainer instead.

Help

Converts an indexed whole-genome VCF of many samples (a few hundred, of an ancestry
similar to yours) into the linkage_data file that SavvyHomozygosity,
SavvySharedHaplotypes, SavvyVcfHomozygosity and ValidateGenomeCnvsUsingAlleleBalance
read. No linkage data is
included in the image; upstream's README links a pre-built 1000 Genomes file.

  JAVA_OPTS=-Xmx5g singularity run --app PrepareLinkageData savvysuite.sif whole_genome.vcf.gz > linkage_data

Docs: https://github.com/rdemolgen/SavvySuite/blob/2a15928/README.md#preparelinkagedata

Runs

exec /opt/savvysuite/bin/PrepareLinkageData "$@"
singularity run --app SavvyCNV library://bioinformatics/savvysuite:1.0-2a15928

This works once you've added the registry as a remote (see the CLI tab). Add the app's arguments after the command. With Apptainer, start it with apptainer instead.

Help

Calls CNVs from many samples' CoverageBinner files: bins the genome into -d bp chunks,
removes noise shared across samples by SVD and calls deletions and duplications with an
HMM. The CNV list goes to stdout and per-sample noise stats to stderr. -g draws PDF
graphs (gnuplot is included) next to the input files, so their directory must be writable.

  JAVA_OPTS="-Xmx30g -XX:ParallelGCThreads=2 -XX:ConcGCThreads=2" \
    singularity run --app SavvyCNV savvysuite.sif -d 200000 *.coverageBinner > cnv_list.csv 2> log.txt

Docs: https://github.com/rdemolgen/SavvySuite/blob/2a15928/README.md#savvycnv

Runs

exec /opt/savvysuite/bin/SavvyCNV "$@"
singularity run --app SavvyCNVJointCaller library://bioinformatics/savvysuite:1.0-2a15928

This works once you've added the registry as a remote (see the CLI tab). Add the app's arguments after the command. With Apptainer, start it with apptainer instead.

Help

Calls CNVs jointly in a few related samples (e.g. a trio), favouring CNVs that start and
end at the same place in each, which cuts false de novo calls. It reads the
<file>.coverageBinner.<bin size>.data files that SavvyCNV writes when given -data.

  JAVA_OPTS=-Xmx30g singularity run --app SavvyCNVJointCaller savvysuite.sif *.coverageBinner.200000.data > joint_cnvs.csv 2> log.txt

Docs: https://github.com/rdemolgen/SavvySuite/blob/2a15928/README.md#savvycnvjointcaller

Runs

exec /opt/savvysuite/bin/SavvyCNVJointCaller "$@"
singularity run --app SavvyContaminationFinder library://bioinformatics/savvysuite:1.0-2a15928

This works once you've added the registry as a remote (see the CLI tab). Add the app's arguments after the command. With Apptainer, start it with apptainer instead.

Help

Estimates cross-contamination between the samples of an indexed multi-sample VCF with
allele depths (AD), e.g. from GATK GenotypeGVCFs. Positional arguments: the VCF, a
sample name or "all", and optionally the maximum mean read depth of a variant and a
thread count.
The output feeds SavvyContaminationRepairer.

  singularity run --app SavvyContaminationFinder savvysuite.sif cohort.vcf.gz all > contamination.txt

Docs: https://github.com/rdemolgen/SavvySuite/blob/2a15928/README.md#savvycontaminationfinder

Runs

exec /opt/savvysuite/bin/SavvyContaminationFinder "$@"
singularity run --app SavvyContaminationRepairer library://bioinformatics/savvysuite:1.0-2a15928

This works once you've added the registry as a remote (see the CLI tab). Add the app's arguments after the command. With Apptainer, start it with apptainer instead.

Help

Re-genotypes an indexed, contaminated VCF using SavvyContaminationFinder's output, read
from stdin. It rewrites GT, GQ and PL and keeps the old values in OLDGT and OLDPL. Give
an output VCF as the second argument, or it writes to stdout (and cannot index it).

  singularity run --app SavvyContaminationRepairer savvysuite.sif cohort.vcf.gz decontaminated.vcf.gz < contamination.txt

Docs: https://github.com/rdemolgen/SavvySuite/blob/2a15928/README.md#savvycontaminationrepairer

Runs

exec /opt/savvysuite/bin/SavvyContaminationRepairer "$@"
singularity run --app SavvyHomozygosity library://bioinformatics/savvysuite:1.0-2a15928

This works once you've added the registry as a remote (see the CLI tab). Add the app's arguments after the command. With Apptainer, start it with apptainer instead.

Help

Finds the homozygous regions of one sample from its off-target reads and writes them as
BED. Takes the linkage_data file from PrepareLinkageData and an indexed BAM; it needs at
least a million off-target reads, and run time grows with their square.

  JAVA_OPTS=-Xmx5g singularity run --app SavvyHomozygosity savvysuite.sif linkage_data sample.bam > sample.homozygous.bed

Docs: https://github.com/rdemolgen/SavvySuite/blob/2a15928/README.md#savvyhomozygosity

Runs

exec /opt/savvysuite/bin/SavvyHomozygosity "$@"
singularity run --app SavvySharedHaplotypes library://bioinformatics/savvysuite:1.0-2a15928

This works once you've added the registry as a remote (see the CLI tab). Add the app's arguments after the command. With Apptainer, start it with apptainer instead.

Help

Finds regions where two samples share a homozygous haplotype, from their off-target
reads, with SavvyHomozygosity's method, and writes them as BED. Takes the linkage_data
file from PrepareLinkageData and two indexed BAMs.

  JAVA_OPTS=-Xmx5g singularity run --app SavvySharedHaplotypes savvysuite.sif linkage_data sample1.bam sample2.bam > shared.bed

Docs: https://github.com/rdemolgen/SavvySuite/blob/2a15928/README.md#savvysharedhaplotypes

Runs

exec /opt/savvysuite/bin/SavvySharedHaplotypes "$@"
singularity run --app SavvyVcfHomozygosity library://bioinformatics/savvysuite:1.0-2a15928

This works once you've added the registry as a remote (see the CLI tab). Add the app's arguments after the command. With Apptainer, start it with apptainer instead.

Help

Finds homozygous regions from an indexed VCF's genotypes, using linkage_data to keep
only variants near Hardy-Weinberg equilibrium, and writes them as BED. With several
sample names it outputs regions homozygous in all of them; with -p, regions where they
all share a haplotype.

  JAVA_OPTS=-Xmx5g singularity run --app SavvyVcfHomozygosity savvysuite.sif linkage_data sample.vcf.gz SAMPLE1 > SAMPLE1.homozygous.bed

Docs: https://github.com/rdemolgen/SavvySuite/blob/2a15928/README.md#savvyvcfhomozygosity

Runs

exec /opt/savvysuite/bin/SavvyVcfHomozygosity "$@"
singularity run --app SelectControlSamples library://bioinformatics/savvysuite:1.0-2a15928

This works once you've added the registry as a remote (see the CLI tab). Add the app's arguments after the command. With Apptainer, start it with apptainer instead.

Help

Picks the controls from a large pool (over about 200) that best match one case sample,
so SavvyCNV runs faster. Run it once with -d on the whole pool to build a summary, then
with -summary and the case sample to list the best-matching files (-subset sets how many).

  JAVA_OPTS=-Xmx30g singularity run --app SelectControlSamples savvysuite.sif -d 200000 pool/*.coverageBinner > summary
  singularity run --app SelectControlSamples savvysuite.sif -summary summary case.coverageBinner > controls.txt

Docs: https://github.com/rdemolgen/SavvySuite/blob/2a15928/README.md#selectcontrolsamples

Runs

exec /opt/savvysuite/bin/SelectControlSamples "$@"
singularity run --app ValidateGenomeCnvsUsingAlleleBalance library://bioinformatics/savvysuite:1.0-2a15928

This works once you've added the registry as a remote (see the CLI tab). Add the app's arguments after the command. With Apptainer, start it with apptainer instead.

Help

Checks CNV calls against the allele balance of variants in VCFs: no heterozygous
variants in a deletion, about 1:2 in a duplication. Takes a tab-separated CNV list with
a header line (chr, start, end, sample; sample "all" tests every sample), linkage_data
or "none", then the indexed VCFs; -columns, given first, picks other columns.

  JAVA_OPTS=-Xmx5g singularity run --app ValidateGenomeCnvsUsingAlleleBalance savvysuite.sif cnv_list.tsv none *.vcf.gz > cnv_validation.txt

Docs: https://github.com/rdemolgen/SavvySuite/blob/2a15928/README.md#validategenomecnvsusingallelebalance

Runs

exec /opt/savvysuite/bin/ValidateGenomeCnvsUsingAlleleBalance "$@"
Bootstrap: docker
From: eclipse-temurin:17.0.21_9-jdk-noble
Stage: build

%post
  set -eu
  export DEBIAN_FRONTEND=noninteractive
  SAVVY_COMMIT=2a15928017e0cdab34c5e72cbb81c9fa0e40b323
  SAVVY_SHA256=77e98f0f03e13c9f4dd50cd870204a8200acbe1dfb75a2694ae0ff9d83814a7f
  # Picard 3.5.0 bundles htsjdk 5.0.0, which SavvySuite needs (upstream suggests a GATK
  # jar, which is far larger). It needs Java 17.
  # NOTE: picard.jar (~65 MB) is shipped only for its htsjdk classes. Bare htsjdk 5.0.0 plus
  # its Maven runtime deps (commons-compress, xz, snappy-java, commons-jexl, ...) would be
  # smaller, but each would need its own pin and checksum, and a missed transitive dep only
  # fails at run time on the input type that needs it (e.g. CRAM). One upstream-built,
  # self-consistent jar is the safer trade for ~50 MB.
  PICARD_VERSION=3.5.0
  PICARD_SHA256=b7d97861c3a54ba5a421f5a317f38382f955803862d30ef4aca2bcdc54943631
  PICARD_LICENSE_SHA256=c9eea75fadb411cd47b06afe1fb5834afbafc350fcb5583d924ac3ea54640ec2
  JAMA_VERSION=1.0.3
  JAMA_SHA256=c7325ee29be1aac1287ddac690f73671f1cd911ca9eca7c619990e86310556fd

  apt-get update
  apt-get install -y --no-install-recommends ca-certificates curl
  rm -rf /var/lib/apt/lists/*

  mkdir -p /src /opt/savvysuite/lib /opt/savvysuite/bin
  cd /src || exit 1
  curl -fsSL -o savvysuite.tar.gz "https://codeload.github.com/rdemolgen/SavvySuite/tar.gz/${SAVVY_COMMIT}"
  curl -fsSL -o picard.jar "https://github.com/broadinstitute/picard/releases/download/${PICARD_VERSION}/picard.jar"
  curl -fsSL -o picard-LICENSE.txt "https://raw.githubusercontent.com/broadinstitute/picard/${PICARD_VERSION}/LICENSE.txt"
  curl -fsSL -o jama.jar "https://repo1.maven.org/maven2/gov/nist/math/jama/${JAMA_VERSION}/jama-${JAMA_VERSION}.jar"
  cat > SHA256SUMS <<EOF
${SAVVY_SHA256}  savvysuite.tar.gz
${PICARD_SHA256}  picard.jar
${PICARD_LICENSE_SHA256}  picard-LICENSE.txt
${JAMA_SHA256}  jama.jar
EOF
  sha256sum -c SHA256SUMS

  tar -xzf savvysuite.tar.gz
  cd "SavvySuite-${SAVVY_COMMIT}" || exit 1
  mkdir classes
  # -proc:none: run no annotation processors found on the classpath.
  # Absolute paths: the base image's ENV PATH may not be set during %post.
  JAVA_BIN=/opt/java/openjdk/bin
  "${JAVA_BIN}/javac" -proc:none -nowarn --release 17 -cp /src/picard.jar:/src/jama.jar -d classes ./*.java
  "${JAVA_BIN}/jar" --create --file /opt/savvysuite/savvysuite.jar -C classes .
  cp LICENSE /opt/savvysuite/LICENSE
  cp README.md /opt/savvysuite/README.md
  cp /src/picard.jar /opt/savvysuite/lib/picard.jar
  cp /src/jama.jar /opt/savvysuite/lib/jama.jar
  cp /src/picard-LICENSE.txt /opt/savvysuite/lib/picard-LICENSE.txt

  # One wrapper per program with a main(). JAVA_OPTS is split on purpose, so it can hold
  # several options.
  for tool in CoverageBinner CoverageOffTarget FindLargeInsertSizes PrepareLinkageData \
      SavvyCNV SavvyCNVJointCaller SavvyContaminationFinder SavvyContaminationRepairer \
      SavvyHomozygosity SavvySharedHaplotypes SavvyVcfHomozygosity SelectControlSamples \
      ValidateGenomeCnvsUsingAlleleBalance; do
    cat > "/opt/savvysuite/bin/${tool}" <<EOF
#!/bin/sh
# shellcheck disable=SC2086
exec /opt/java/openjdk/bin/java \${JAVA_OPTS:-} -cp /opt/savvysuite/savvysuite.jar:/opt/savvysuite/lib/jama.jar:/opt/savvysuite/lib/picard.jar ${tool} "\$@"
EOF
    chmod 755 "/opt/savvysuite/bin/${tool}"
  done

  cd / || exit 1
  rm -rf /src

Bootstrap: docker
From: eclipse-temurin:17.0.21_9-jre-noble
Stage: final

%files from build
  /opt/savvysuite /opt/savvysuite

%post
  set -eu
  export DEBIAN_FRONTEND=noninteractive
  # gnuplot draws SavvyCNV's -g/-a graphs (PDF, via cairo).
  apt-get update
  apt-get install -y --no-install-recommends gnuplot-nox fonts-dejavu-core
  apt-get clean
  rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*

%environment
  export SAVVYSUITE_HOME=/opt/savvysuite
  export PATH=/opt/savvysuite/bin:${PATH}
  # So that upstream's "java SavvyCNV ..." examples work as written.
  export CLASSPATH=/opt/savvysuite/savvysuite.jar:/opt/savvysuite/lib/jama.jar:/opt/savvysuite/lib/picard.jar

%labels
  Maintainer IDIA <support@ilifu.ac.za>
  Version 1.0-2a15928
  Source https://github.com/rdemolgen/SavvySuite
  Source_Commit 2a15928017e0cdab34c5e72cbb81c9fa0e40b323
  License GPL-3.0
  Authors Matthew Wakeling, University of Exeter
  Picard_Version 3.5.0
  Jama_Version 1.0.3

%help
  SavvySuite 1.0-2a15928 by Matthew Wakeling, University of Exeter (https://github.com/rdemolgen/SavvySuite).
  This image packages the unmodified upstream source at git commit 2a15928 (2026-07-03;
  the last tagged release is v1.0), compiled to a jar. IDIA builds and maintains the image
  only. Report bugs in the tools upstream: https://github.com/rdemolgen/SavvySuite/issues

  SavvySuite finds CNVs, homozygous regions and shared haplotypes from off-target reads.

  Programs (each is on PATH and is also an app, e.g. --app SavvyCNV):
    CoverageBinner, SelectControlSamples, SavvyCNV, SavvyCNVJointCaller,
    PrepareLinkageData, SavvyHomozygosity, SavvySharedHaplotypes, SavvyVcfHomozygosity,
    ValidateGenomeCnvsUsingAlleleBalance, SavvyContaminationFinder,
    SavvyContaminationRepairer, CoverageOffTarget, FindLargeInsertSizes

  Usage:
    singularity exec savvysuite.sif CoverageBinner sample.bam > sample.coverageBinner
    JAVA_OPTS="-Xmx30g -XX:ParallelGCThreads=2 -XX:ConcGCThreads=2" \
      singularity exec savvysuite.sif SavvyCNV -d 200000 *.coverageBinner > cnv_list.csv 2> log.txt
    singularity run savvysuite.sif SavvyCNV -d 200000 *.coverageBinner   # same, via runscript
  Set Java options such as -Xmx in JAVA_OPTS. CLASSPATH is set, so upstream's
  "java -Xmx30g SavvyCNV ..." examples also work inside the container. Upstream docs are in
  /opt/savvysuite/README.md.

  Data: no reference data is included. Bind your BAM/CRAM/VCF files and, for CRAM, the
  reference FASTA (CoverageBinner -R), e.g. --bind /path/to/data:/data.

  Licence: SavvySuite is GPL-3.0 (/opt/savvysuite/LICENSE). It runs with Picard 3.5.0
  (MIT, bundles htsjdk; /opt/savvysuite/lib/picard-LICENSE.txt and the licences inside
  picard.jar) and JAMA 1.0.3 (public domain).

  Citation (from upstream): for SavvyCNV, cite
    https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1009940
  For the other tools, cite: Wakeling MN, De Franco E, Hattersley AT, Ellard S. Making the
  most of targeted sequencing: detecting CNVs and homozygous regions using offtarget reads
  with SavvyCNV. ASHG 67th Annual Meeting, Orlando, FL, 2017.

%runscript
  if [ "$#" -eq 0 ]; then
    echo "Usage: singularity run <image> <program> [args...]" >&2
    echo "Programs:" >&2
    ls /opt/savvysuite/bin >&2
    exit 1
  fi
  program="$1"
  shift
  if [ ! -x "/opt/savvysuite/bin/${program}" ]; then
    echo "Unknown program: ${program}. Choose one of:" >&2
    ls /opt/savvysuite/bin >&2
    exit 1
  fi
  exec "/opt/savvysuite/bin/${program}" "$@"

%apprun CoverageBinner
  exec /opt/savvysuite/bin/CoverageBinner "$@"

%apphelp CoverageBinner
  Step 1 of CNV calling: counts the reads of one BAM, CRAM or SAM file in 200 bp bins
  (-d to change; SavvyCNV's -d must be a multiple of it). Drops reads below MAPQ 30 (-mmq)
  and reads clipped at both ends (-includeDoubleClip keeps them). A CRAM needs its
  reference (-R); "CoverageBinner info <file>" prints a file's settings.

    singularity run --app CoverageBinner savvysuite.sif -R ref.fasta sample.cram > sample.coverageBinner

  Docs: https://github.com/rdemolgen/SavvySuite/blob/2a15928/README.md#coveragebinner

%apprun CoverageOffTarget
  exec /opt/savvysuite/bin/CoverageOffTarget "$@"

%apphelp CoverageOffTarget
  Reports how many of each sample's reads are off-target, from a set of CoverageBinner
  files, and recommends a SavvyCNV -d bin size for off-target and on-target calling.
  -readLength adds the mean off-target read depth; -threshold (default 5) sets the mean
  reads per 200 bp bin above which a bin counts as on-target.

    singularity run --app CoverageOffTarget savvysuite.sif -readLength 150 *.coverageBinner > offtarget.txt

  Docs: https://github.com/rdemolgen/SavvySuite/blob/2a15928/README.md#coverageofftarget

%apprun FindLargeInsertSizes
  exec /opt/savvysuite/bin/FindLargeInsertSizes "$@"

%apphelp FindLargeInsertSizes
  Finds structural variant edges (deletions, duplications, inversions, translocations)
  from read pairs with abnormal insert sizes. Events are found in the first BAM and then
  counted in every BAM given, e.g. a proband then the parents; the BAMs need indexes.
  Better for small CNVs than read depth; expect false positives for large events.

    singularity run --app FindLargeInsertSizes savvysuite.sif -maxInsert 1000 proband.bam mother.bam father.bam > events.txt

  Docs: https://github.com/rdemolgen/SavvySuite/blob/2a15928/README.md#findlargeinsertsizes

%apprun PrepareLinkageData
  exec /opt/savvysuite/bin/PrepareLinkageData "$@"

%apphelp PrepareLinkageData
  Converts an indexed whole-genome VCF of many samples (a few hundred, of an ancestry
  similar to yours) into the linkage_data file that SavvyHomozygosity,
  SavvySharedHaplotypes, SavvyVcfHomozygosity and ValidateGenomeCnvsUsingAlleleBalance
  read. No linkage data is
  included in the image; upstream's README links a pre-built 1000 Genomes file.

    JAVA_OPTS=-Xmx5g singularity run --app PrepareLinkageData savvysuite.sif whole_genome.vcf.gz > linkage_data

  Docs: https://github.com/rdemolgen/SavvySuite/blob/2a15928/README.md#preparelinkagedata

%apprun SavvyCNV
  exec /opt/savvysuite/bin/SavvyCNV "$@"

%apphelp SavvyCNV
  Calls CNVs from many samples' CoverageBinner files: bins the genome into -d bp chunks,
  removes noise shared across samples by SVD and calls deletions and duplications with an
  HMM. The CNV list goes to stdout and per-sample noise stats to stderr. -g draws PDF
  graphs (gnuplot is included) next to the input files, so their directory must be writable.

    JAVA_OPTS="-Xmx30g -XX:ParallelGCThreads=2 -XX:ConcGCThreads=2" \
      singularity run --app SavvyCNV savvysuite.sif -d 200000 *.coverageBinner > cnv_list.csv 2> log.txt

  Docs: https://github.com/rdemolgen/SavvySuite/blob/2a15928/README.md#savvycnv

%apprun SavvyCNVJointCaller
  exec /opt/savvysuite/bin/SavvyCNVJointCaller "$@"

%apphelp SavvyCNVJointCaller
  Calls CNVs jointly in a few related samples (e.g. a trio), favouring CNVs that start and
  end at the same place in each, which cuts false de novo calls. It reads the
  <file>.coverageBinner.<bin size>.data files that SavvyCNV writes when given -data.

    JAVA_OPTS=-Xmx30g singularity run --app SavvyCNVJointCaller savvysuite.sif *.coverageBinner.200000.data > joint_cnvs.csv 2> log.txt

  Docs: https://github.com/rdemolgen/SavvySuite/blob/2a15928/README.md#savvycnvjointcaller

%apprun SavvyContaminationFinder
  exec /opt/savvysuite/bin/SavvyContaminationFinder "$@"

%apphelp SavvyContaminationFinder
  Estimates cross-contamination between the samples of an indexed multi-sample VCF with
  allele depths (AD), e.g. from GATK GenotypeGVCFs. Positional arguments: the VCF, a
  sample name or "all", and optionally the maximum mean read depth of a variant and a
  thread count.
  The output feeds SavvyContaminationRepairer.

    singularity run --app SavvyContaminationFinder savvysuite.sif cohort.vcf.gz all > contamination.txt

  Docs: https://github.com/rdemolgen/SavvySuite/blob/2a15928/README.md#savvycontaminationfinder

%apprun SavvyContaminationRepairer
  exec /opt/savvysuite/bin/SavvyContaminationRepairer "$@"

%apphelp SavvyContaminationRepairer
  Re-genotypes an indexed, contaminated VCF using SavvyContaminationFinder's output, read
  from stdin. It rewrites GT, GQ and PL and keeps the old values in OLDGT and OLDPL. Give
  an output VCF as the second argument, or it writes to stdout (and cannot index it).

    singularity run --app SavvyContaminationRepairer savvysuite.sif cohort.vcf.gz decontaminated.vcf.gz < contamination.txt

  Docs: https://github.com/rdemolgen/SavvySuite/blob/2a15928/README.md#savvycontaminationrepairer

%apprun SavvyHomozygosity
  exec /opt/savvysuite/bin/SavvyHomozygosity "$@"

%apphelp SavvyHomozygosity
  Finds the homozygous regions of one sample from its off-target reads and writes them as
  BED. Takes the linkage_data file from PrepareLinkageData and an indexed BAM; it needs at
  least a million off-target reads, and run time grows with their square.

    JAVA_OPTS=-Xmx5g singularity run --app SavvyHomozygosity savvysuite.sif linkage_data sample.bam > sample.homozygous.bed

  Docs: https://github.com/rdemolgen/SavvySuite/blob/2a15928/README.md#savvyhomozygosity

%apprun SavvySharedHaplotypes
  exec /opt/savvysuite/bin/SavvySharedHaplotypes "$@"

%apphelp SavvySharedHaplotypes
  Finds regions where two samples share a homozygous haplotype, from their off-target
  reads, with SavvyHomozygosity's method, and writes them as BED. Takes the linkage_data
  file from PrepareLinkageData and two indexed BAMs.

    JAVA_OPTS=-Xmx5g singularity run --app SavvySharedHaplotypes savvysuite.sif linkage_data sample1.bam sample2.bam > shared.bed

  Docs: https://github.com/rdemolgen/SavvySuite/blob/2a15928/README.md#savvysharedhaplotypes

%apprun SavvyVcfHomozygosity
  exec /opt/savvysuite/bin/SavvyVcfHomozygosity "$@"

%apphelp SavvyVcfHomozygosity
  Finds homozygous regions from an indexed VCF's genotypes, using linkage_data to keep
  only variants near Hardy-Weinberg equilibrium, and writes them as BED. With several
  sample names it outputs regions homozygous in all of them; with -p, regions where they
  all share a haplotype.

    JAVA_OPTS=-Xmx5g singularity run --app SavvyVcfHomozygosity savvysuite.sif linkage_data sample.vcf.gz SAMPLE1 > SAMPLE1.homozygous.bed

  Docs: https://github.com/rdemolgen/SavvySuite/blob/2a15928/README.md#savvyvcfhomozygosity

%apprun SelectControlSamples
  exec /opt/savvysuite/bin/SelectControlSamples "$@"

%apphelp SelectControlSamples
  Picks the controls from a large pool (over about 200) that best match one case sample,
  so SavvyCNV runs faster. Run it once with -d on the whole pool to build a summary, then
  with -summary and the case sample to list the best-matching files (-subset sets how many).

    JAVA_OPTS=-Xmx30g singularity run --app SelectControlSamples savvysuite.sif -d 200000 pool/*.coverageBinner > summary
    singularity run --app SelectControlSamples savvysuite.sif -summary summary case.coverageBinner > controls.txt

  Docs: https://github.com/rdemolgen/SavvySuite/blob/2a15928/README.md#selectcontrolsamples

%apprun ValidateGenomeCnvsUsingAlleleBalance
  exec /opt/savvysuite/bin/ValidateGenomeCnvsUsingAlleleBalance "$@"

%apphelp ValidateGenomeCnvsUsingAlleleBalance
  Checks CNV calls against the allele balance of variants in VCFs: no heterozygous
  variants in a deletion, about 1:2 in a duplication. Takes a tab-separated CNV list with
  a header line (chr, start, end, sample; sample "all" tests every sample), linkage_data
  or "none", then the indexed VCFs; -columns, given first, picks other columns.

    JAVA_OPTS=-Xmx5g singularity run --app ValidateGenomeCnvsUsingAlleleBalance savvysuite.sif cnv_list.tsv none *.vcf.gz > cnv_validation.txt

  Docs: https://github.com/rdemolgen/SavvySuite/blob/2a15928/README.md#validategenomecnvsusingallelebalance

%test
  set -eu
  workdir=$(mktemp -d)
  cd "${workdir}" || exit 1
  # A one-read SAM file: CoverageBinner reads it with htsjdk and records the sample name.
  seq=AAAAAAAAAACCCCCCCCCCGGGGGGGGGGTTTTTTTTTTAAAAAAAAAA
  {
    printf '@HD\tVN:1.6\tSO:coordinate\n'
    printf '@SQ\tSN:chr1\tLN:100000\n'
    printf '@RG\tID:rg1\tSM:idiatestsample\n'
    printf 'read1\t0\tchr1\t1000\t60\t50M\t*\t0\t0\t%s\t*\tRG:Z:rg1\n' "${seq}"
  } > test.sam
  /opt/savvysuite/bin/CoverageBinner test.sam > test.coverageBinner
  /opt/savvysuite/bin/CoverageBinner info test.coverageBinner | grep -q '^sample: idiatestsample$'
  /opt/savvysuite/bin/CoverageBinner dump test.coverageBinner chr1 200 | grep -qx "$(printf '5\t1000\t1')"
  # JAMA (used by SavvyCNV and SelectControlSamples) loads and computes.
  /opt/java/openjdk/bin/java -cp /opt/savvysuite/lib/jama.jar Jama.examples.MagicSquareExample > /dev/null
  # gnuplot has the PDF terminal SavvyCNV's graphs use.
  gnuplot -e 'set terminal pdf noenhanced; set output "test.pdf"; plot sin(x)'
  test -s test.pdf
  test -s /opt/savvysuite/LICENSE
  cd / || exit 1
  rm -rf "${workdir}"
  echo "SavvySuite OK"
Download bioinformatics-savvysuite_1.0-2a15928.def
#!/bin/sh

  if [ "$#" -eq 0 ]; then
    echo "Usage: singularity run <image> <program> [args...]" >&2
    echo "Programs:" >&2
    ls /opt/savvysuite/bin >&2
    exit 1
  fi
  program="$1"
  shift
  if [ ! -x "/opt/savvysuite/bin/${program}" ]; then
    echo "Unknown program: ${program}. Choose one of:" >&2
    ls /opt/savvysuite/bin >&2
    exit 1
  fi
  exec "/opt/savvysuite/bin/${program}" "$@"
#!/bin/sh

  set -eu
  workdir=$(mktemp -d)
  cd "${workdir}" || exit 1
  # A one-read SAM file: CoverageBinner reads it with htsjdk and records the sample name.
  seq=AAAAAAAAAACCCCCCCCCCGGGGGGGGGGTTTTTTTTTTAAAAAAAAAA
  {
    printf '@HD\tVN:1.6\tSO:coordinate\n'
    printf '@SQ\tSN:chr1\tLN:100000\n'
    printf '@RG\tID:rg1\tSM:idiatestsample\n'
    printf 'read1\t0\tchr1\t1000\t60\t50M\t*\t0\t0\t%s\t*\tRG:Z:rg1\n' "${seq}"
  } > test.sam
  /opt/savvysuite/bin/CoverageBinner test.sam > test.coverageBinner
  /opt/savvysuite/bin/CoverageBinner info test.coverageBinner | grep -q '^sample: idiatestsample$'
  /opt/savvysuite/bin/CoverageBinner dump test.coverageBinner chr1 200 | grep -qx "$(printf '5\t1000\t1')"
  # JAMA (used by SavvyCNV and SelectControlSamples) loads and computes.
  /opt/java/openjdk/bin/java -cp /opt/savvysuite/lib/jama.jar Jama.examples.MagicSquareExample > /dev/null
  # gnuplot has the PDF terminal SavvyCNV's graphs use.
  gnuplot -e 'set terminal pdf noenhanced; set output "test.pdf"; plot sin(x)'
  test -s test.pdf
  test -s /opt/savvysuite/LICENSE
  cd / || exit 1
  rm -rf "${workdir}"
  echo "SavvySuite OK"
# /.singularity.d/env/10-docker2singularity.sh
#!/bin/sh
export PATH="/opt/java/openjdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
export JAVA_HOME="${JAVA_HOME:-"/opt/java/openjdk"}"
export LANG="${LANG:-"en_US.UTF-8"}"
export LANGUAGE="${LANGUAGE:-"en_US:en"}"
export LC_ALL="${LC_ALL:-"en_US.UTF-8"}"
export JAVA_VERSION="${JAVA_VERSION:-"jdk-17.0.21+9"}"
# /.singularity.d/env/90-environment.sh
#!/bin/sh
# Custom environment shell code should follow


  export SAVVYSUITE_HOME=/opt/savvysuite
  export PATH=/opt/savvysuite/bin:${PATH}
  # So that upstream's "java SavvyCNV ..." examples work as written.
  export CLASSPATH=/opt/savvysuite/savvysuite.jar:/opt/savvysuite/lib/jama.jar:/opt/savvysuite/lib/picard.jar