### Example pVCF with three variants for --pick demonstration Source: https://github.com/acenglish/truvari/blob/develop/docs/bench.md Shows a pVCF with three variants and two samples used to illustrate the effect of the --pick parameter on matching. The genotypes are 1/1, 1/0, 0/0, 0/1, 0/0, 1/1. ```vcf CHROM POS ID REF ALT base comp chr20 17785968 ID1 A ACGCGCGCGCG 1/1 1/0 chr20 17785968 ID2 A ACGCGCGCGCGCG 0/0 0/1 chr20 17785969 ID3 C CGCGCGCGCGCGC 0/0 1/1 ``` -------------------------------- ### Clone and install Truvari from source Source: https://github.com/acenglish/truvari/wiki/Installation Clones the Truvari repository, checks out a specific tag (e.g., v3.0.0), and installs it with pip. ```bash git clone https://github.com/ACEnglish/truvari.git git checkout tags/v3.0.0 python3 -m pip install . ``` -------------------------------- ### truvari consistency example command Source: https://github.com/acenglish/truvari/wiki/consistency Example command that runs truvari consistency on three VCF files: fileA.vcf, fileB.vcf, and fileC.vcf. ```bash truvari consistency fileA.vcf fileB.vcf fileC.vcf ``` -------------------------------- ### bcftools merge output example Source: https://github.com/acenglish/truvari/blob/develop/docs/collapse.md Shows the result of running bcftools merge on the example input VCFs. Calls with identical chrom, pos, ref, and alt have their sample information pasted together; non-matching positions get missing genotypes (./.). ```text >> merge.vcf: chr1 1 ... GT 0/1 1/1 chr1 5 ... GT 1/1 ./. chr1 7 ... GT ./. 0/1 ``` -------------------------------- ### Install CI/CD dependencies Source: https://github.com/acenglish/truvari/blob/develop/docs/Development.md Installs extra dependencies needed to run Truvari's CI/CD scripts. ```bash pip install pylint anybadge coverage ``` -------------------------------- ### Install stable Truvari with pip Source: https://github.com/acenglish/truvari/wiki/Installation Installs the latest stable version of Truvari from PyPI. ```bash python3 -m pip install truvari ``` -------------------------------- ### Install CI/CD Dependencies Source: https://github.com/acenglish/truvari/wiki/Development Install extra dependencies needed for CI/CD scripts. ```APIDOC ## pip install ### Description Install extra dependencies needed for CI/CD scripts. ### Method bash ### Endpoint N/A ### Parameters None ### Request Example ```bash pip install pylint anybadge coverage ``` ### Response #### Success Response - **exit_code** (integer) - The exit code of the pip install command. #### Response Example ``` 0 ``` ``` -------------------------------- ### --intra example: consolidating sample columns Source: https://github.com/acenglish/truvari/wiki/collapse Shows how `--intra` consolidates multiple sample columns into one and adds a `FORMAT/SUPP` field indicating which columns had a present genotype. The example shows two calls that collapse into one with `SUPP=3`. ```text #Call FORMAT S1 S2 Call1 GT:GQ:AD 1/1 ./. Call2 GT:GQ:AD ./. 1/1 # Into #Call FORMAT S1 Call1 GT:GQ:AD:SUPP 1/1:3 ``` -------------------------------- ### Build Truvari from develop branch Source: https://github.com/acenglish/truvari/blob/develop/docs/Installation.md Installs the in-development version of Truvari from the develop branch by cloning and installing without checking out a tag. ```bash git clone https://github.com/ACEnglish/truvari.git python3 -m pip install . ``` -------------------------------- ### Install Truvari with pip Source: https://github.com/acenglish/truvari/blob/develop/README.md Install Truvari using pip. Requires Python 3.6 or higher. ```bash python3 -m pip install Truvari ``` -------------------------------- ### Install Truvari with bwa extra for annotations Source: https://github.com/acenglish/truvari/wiki/Installation Installs Truvari with the 'bwa' extra, required for some annotation commands like 'truvari anno remap'. ```bash python3 -m pip install truvari[bwa] ``` -------------------------------- ### gt_matrix table representation Source: https://github.com/acenglish/truvari/blob/develop/docs/bench.md Human-readable table representation of the gt_matrix example, showing base genotypes as rows and comp genotypes as columns. ```text comp (0,1) (1,1) base (0,1) 500 10 (1,1) 20 800 ``` -------------------------------- ### Example input VCFs for bcftools merge Source: https://github.com/acenglish/truvari/blob/develop/docs/collapse.md Example VCF contents showing two input files (one.vcf and two.vcf) with calls at different positions. These are used to illustrate how bcftools merge pastes sample information for calls with identical chrom, pos, ref, and alt. ```text >> one.vcf: chr1 1 ... GT 0/1 chr1 5 ... GT 1/1 >> two.vcf: chr1 1 ... GT 1/1 chr1 7 ... GT 0/1 ``` -------------------------------- ### Run truvari stratify on a bench directory Source: https://github.com/acenglish/truvari/wiki/stratify Counts variants per region in input.bed using the bench/ directory. Output is tab-separated with columns chrom, start, end, tpbase, tp, fn, fp. The example output shows counts for three regions. ```bash truvari stratify input.bed bench/ ``` ```text chrom start end tpbase tp fn fp chr20 280300 280900 0 0 0 0 chr20 100000 200000 1 1 0 0 chr20 642000 642350 1 1 2 1 ``` -------------------------------- ### Install Truvari with conda Source: https://github.com/acenglish/truvari/wiki/Installation Installs Truvari from the bioconda channel using conda. ```bash conda install -c bioconda truvari ``` -------------------------------- ### Example of --intra collapse with sample consolidation Source: https://github.com/acenglish/truvari/blob/develop/docs/collapse.md Shows how --intra consolidates multiple sample columns into one and adds a FORMAT/SUPP field indicating which columns had a present GT. The example shows two calls that collapse into one with SUPP=3. ```text #Call FORMAT S1 S2 Call1 GT:GQ:AD 1/1 ./. Call2 GT:GQ:AD ./. 1/1 # Into #Call FORMAT S1 Call1 GT:GQ:AD:SUPP 1/1:3 ``` -------------------------------- ### Install specific Truvari version with pip Source: https://github.com/acenglish/truvari/wiki/Installation Installs a specific version of Truvari, e.g., 3.2.0. See PyPI for available versions. ```bash python3 -m pip install truvari==3.2.0 ``` -------------------------------- ### Run truvari bench with base and comp VCFs Source: https://github.com/acenglish/truvari/blob/develop/docs/bench.md Executes Truvari bench comparing a truth set (base) against a comparison set (comp), writing results to the specified output directory. Use this as the primary benchmarking command. ```bash truvari bench -b base_calls.vcf -c comp_calls.vcf -o output_dir/ ``` -------------------------------- ### Test Truvari release from TestPyPI Source: https://github.com/acenglish/truvari/blob/develop/docs/Development.md Creates a virtual environment and installs Truvari from TestPyPI to check the test release. ```bash python3 -m venv test_truvari python3 -m pip install --index-url https://test.pypi.org/simple --extra-index-url https://pypi.org/simple/ truvari ``` -------------------------------- ### truvari consistency example report Source: https://github.com/acenglish/truvari/wiki/consistency Example output report from truvari consistency. It shows the total number of calls, per-file call counts, a summary of consistency, and a breakdown of VCFs' consistency by group. The Group field uses 1/0 to indicate presence/absence of a call in each VCF. ```text # # Total 5534 calls across 3 VCFs # #File NumCalls fileA.vcf 4706 fileB.vcf 4827 fileC.vcf 4882 # # Summary of consistency # #VCFs Calls Pct 3 3973 71.79% 2 935 16.90% 1 626 11.31% # # Breakdown of VCFs' consistency # #Group Total TotalPct PctOfFileCalls 111 3973 71.79% 84.42% 82.31% 81.38% 011 351 6.34% 7.27% 7.19% 101 308 5.57% 6.54% 6.31% 110 276 4.99% 5.86% 5.72% 001 250 4.52% 5.12% 010 227 4.10% 4.70% 100 149 2.69% 3.17% ``` -------------------------------- ### Example collapse output Source: https://github.com/acenglish/truvari/blob/develop/docs/collapse.md Shows the result of collapsing the example merge.vcf by matching calls within 3bp. The kept variant at chr1:1 and chr1:5 are written to truvari_merge.vcf, while the redundant call at chr1:7 is placed in truvari_collapsed.vcf. ```text >> truvari_merge.vcf chr1 1 ... GT 0/1 1/1 chr1 5 ... GT 1/1 0/1 >> truvari_collapsed.vcf chr1 7 ... GT ./. 0/1 ``` -------------------------------- ### Consistency report JSON output example Source: https://github.com/acenglish/truvari/blob/develop/docs/consistency.md Example JSON output from the Truvari consistency report. It shows the input VCF paths, total calls, per-VCF counts, shared call statistics across 1, 2, or 3 VCFs, and detailed per-group breakdowns with percentages. ```json { "vcfs": [ "repo_utils/test_files/variants/input1.vcf.gz", "repo_utils/test_files/variants/input2.vcf.gz", "repo_utils/test_files/variants/input3.vcf.gz" ], "total_calls": 3513, "num_vcfs": 3, "vcf_counts": { "repo_utils/test_files/variants/input1.vcf.gz": 2151, "repo_utils/test_files/variants/input2.vcf.gz": 1783, "repo_utils/test_files/variants/input3.vcf.gz": 2065 }, "shared": [ { "vcf_count": 3, "num_calls": 701, "call_pct": 0.1995445488186735 }, { "vcf_count": 2, "num_calls": 1084, "call_pct": 0.3085681753487048 }, { "vcf_count": 1, "num_calls": 1728, "call_pct": 0.4918872758326217 } ], "detailed": [ { "group": "111", "total": 701, "total_pct": 0.1995445488186735, "repo_utils/test_files/variants/input1.vcf.gz": 0.32589493258949326, "repo_utils/test_files/variants/input2.vcf.gz": 0.393157599551318, "repo_utils/test_files/variants/input3.vcf.gz": 0.3394673123486683 }, { "group": "001", "total": 645, "total_pct": 0.18360375747224594, "repo_utils/test_files/variants/input1.vcf.gz": 0, "repo_utils/test_files/variants/input2.vcf.gz": 0, "repo_utils/test_files/variants/input3.vcf.gz": 0.31234866828087166 }, { "group": "100", "total": 598, "total_pct": 0.17022487902077996, "repo_utils/test_files/variants/input1.vcf.gz": 0.2780102278010228, "repo_utils/test_files/variants/input2.vcf.gz": 0, "repo_utils/test_files/variants/input3.vcf.gz": 0 }, { "group": "101", "total": 487, "total_pct": 0.1386279533162539, "repo_utils/test_files/variants/input1.vcf.gz": 0.22640632264063226, "repo_utils/test_files/variants/input2.vcf.gz": 0, "repo_utils/test_files/variants/input3.vcf.gz": 0.2358353510895884 }, { "group": "010", "total": 485, "total_pct": 0.13805863933959578, "repo_utils/test_files/variants/input1.vcf.gz": 0, "repo_utils/test_files/variants/input2.vcf.gz": 0.27201346045989905, "repo_utils/test_files/variants/input3.vcf.gz": 0 }, { "group": "110", "total": 365, "total_pct": 0.10389980074010817, "repo_utils/test_files/variants/input1.vcf.gz": 0.1696885169688517, "repo_utils/test_files/variants/input2.vcf.gz": 0.2047111609646663, "repo_utils/test_files/variants/input3.vcf.gz": 0 }, { "group": "011", "total": 232, "total_pct": 0.06604042129234272, "repo_utils/test_files/variants/input1.vcf.gz": 0, "repo_utils/test_files/variants/input2.vcf.gz": 0.13011777902411667, "repo_utils/test_files/variants/input3.vcf.gz": 0.11234866828087167 } ] } ``` -------------------------------- ### gt_matrix JSON example Source: https://github.com/acenglish/truvari/wiki/bench Example of the gt_matrix output, a JSON object mapping base genotypes to comp genotypes with counts. ```json { "(0, 1)": { "(0, 1)": 500, "(1, 1)": 10 }, "(1, 1)": { "(1, 1)": 800, "(0, 1)": 20 } } ``` -------------------------------- ### Test PyPI Release Source: https://github.com/acenglish/truvari/wiki/Development Install Truvari from the test PyPI repository to verify the release. ```APIDOC ## pip install from testpypi ### Description Install Truvari from the test PyPI repository to verify the release. ### Method bash ### Endpoint N/A ### Parameters None ### Request Example ```bash python3 -m venv test_truvari python3 -m pip install --index-url https://test.pypi.org/simple --extra-index-url https://pypi.org/simple/ truvari ``` ### Response #### Success Response - **exit_code** (integer) - The exit code of the pip install command. #### Response Example ``` 0 ``` ``` -------------------------------- ### Matching parameter diagrams for refdist, pctsize, pctovl, pctseq Source: https://github.com/acenglish/truvari/blob/develop/docs/bench.md ASCII diagrams illustrating how each matching parameter works: refdist (max reference distance), pctsize (size similarity), pctovl (reciprocal overlap), and pctseq (sequence similarity). These are visual aids for understanding the thresholds. ```text █ = Deletion ^ = Insertion --refdist REFDIST (500) Max reference location distance ACTGATCATGAT |--████--| █████ Calls are within reference distance of 2 --pctsize PCTSIZE (0.7) Min pct allele size similarity ACTGATCATGA sizes █████ -> 5bp ████ -> 4bp variants have 0.8 size similarity --pctovl PCTOVL (0.0) Min pct reciprocal overlap ACTGATCATGA ranges █████ [2,7) ████ [4,8) variants have 0.6 reciprocial overlap --pctseq PCTSEQ (0.7) Min percent allele sequence similarity A-CTG-ACTG ^ ^ haplotypes | └ACTG -> CTGACTGA └CTGA -> CTGACTGA haplotypes have 100% sequence similarity ``` -------------------------------- ### Workaround for edlib compilation error Source: https://github.com/acenglish/truvari/wiki/Installation Commands to create a virtual environment and install Truvari with a workaround for a known edlib build error involving 'longintrepr.h'. ```bash python3 -m venv my_env source my_env/bin/activate python3 -m pip install --no-cache-dir cython setuptools wheel EDLIB_USE_CYTHON=1 python3 -m pip install truvari --no-cache ``` -------------------------------- ### Compare two variants with entry.match() Source: https://github.com/acenglish/truvari/blob/develop/docs/api/truvari.examples.rst Given two truvari.VariantRecords, this example shows how to compare them using the match() method, which returns a MatchResult with sequence similarity, size similarity, and match state. ```python # Given two `truvari.VariantRecords`, entry1 and entry2 match = entry1.match(entry2) print("Entries' Sequence Similarity:", match.seqsim) print("Entries' Size Similarity:", match.sizesim) print("Is the match above thresholds:", match.state) ``` -------------------------------- ### Subset VCF to in-memory regions with fetch_regions Source: https://github.com/acenglish/truvari/blob/develop/docs/api/truvari.examples.rst Use fetch_regions() with an in-memory IntervalTree to subset variants by regions. This example builds an interval tree and counts variants in the specified regions. ```python from collections import defaultdict from pyintervaltree import IntervalTree tree = defaultdict(IntervalTree) tree['chr1'].addi(10, 100) tree['chr2'].addi(2000, 2200) count = 0 for entry in vcf.fetch_regions(tree): count += 1 print(f"Total of {count} variants") ``` -------------------------------- ### Example MatchIds in tp-base.vcf and tp-comp.vcf for multi-matching variants Source: https://github.com/acenglish/truvari/wiki/MatchIds Shows how MatchIds appear in the base and comparison VCFs when one base variant matches multiple comparison variants under --pick ac|multi. The base variant has MatchId=4.0,4.1 and the comparison variants have MatchId=4.0,4.1 and MatchId=4.0,4.2, indicating both comparison variants point to base variant 4.0. ```text # tp-base.vcf MatchId=4.0,4.1 # tp-comp.vcf MatchId=4.0,4.1 MatchId=4.0,4.2 ``` -------------------------------- ### Interact with Truvari Docker container Source: https://github.com/acenglish/truvari/blob/develop/docs/Development.md Starts an interactive bash shell inside the Truvari Docker container, allowing you to run CI/CD scripts or Truvari directly. ```bash docker run -v `pwd`:/data --entrypoint /bin/bash -it truvari ``` -------------------------------- ### truvari bench command for comparing samples within the same VCF Source: https://github.com/acenglish/truvari/blob/develop/docs/bench.md Command to compare two samples (base and comp) inside the same VCF using --bSample and --cSample. The --no-ref a option is used to exclude reference alleles. ```bash truvari bench -b input.vcf.gz -c input.vcf.gz -o output/ --bSample base --cSample comp --no-ref a ``` -------------------------------- ### Subset VCF to regions from a BED file Source: https://github.com/acenglish/truvari/blob/develop/docs/api/truvari.examples.rst Iterate over variants in regions specified by a BED file using the fetch_bed() method. This example prints the variant type and size for each entry in the regions. ```python for entry in vcf.fetch_bed("regions.bed"): print("Entry's variant type:", entry.var_type()) print("Entry's variant size:", entry.var_size()) ``` -------------------------------- ### Customize matching thresholds with VariantParams Source: https://github.com/acenglish/truvari/blob/develop/docs/api/truvari.examples.rst Create a VariantParams object to disable sequence and size similarity and enable reciprocal overlap, then use it when opening the VCF file. This example shows how to match two entries with custom parameters. ```python # Disable sequence and size similarity; enable reciprocal overlap p = truvari.VariantParams(pctseq=0, pctsize=0, pctovl=0.5) vcf = truvari.VariantFile("input.vcf.gz", params=p) entry1 = next(vcf) entry2 = next(vcf) match = entry1.match(entry2) ``` -------------------------------- ### Generate SV density counts with truvari anno chunks Source: https://github.com/acenglish/truvari/wiki/Collapse-on-Regions-with-a-High‐Density-of-SVs Run `truvari anno chunks` on the input VCF to produce a BED file with SV counts per chunk. The output has chromosome, start, end, and three additional columns: total SV count, sub-chunk counts after separating by svtype and svlen, and sub-chunk counts after re-chunking by distance. ```bash truvari anno chunks input.vcf.gz > counts.bed ``` -------------------------------- ### Symbolic variants: bcftools merge -m id Source: https://github.com/acenglish/truvari/wiki/collapse Shows how to correctly merge symbolic variants (e.g., ``) by giving each variant a unique ID and using `bcftools merge -m id`. The example shows that `-m none` prematurely collapses variants with the same position, while `-m id` keeps them separate. This bug was replicated with bcftools 1.18 and 1.21. ```text # A.vcf chr1 147022730 SV1 N . PASS SVLEN=-570334;END=147593064 # B.vcf chr1 147022730 SV2 N . PASS SVLEN=-990414;END=148013144 # bcftools merge -m none A.vcf B.vcf # Premature collapse chr1 147022730 SV1;SV2 N . PASS SVLEN=-570334;END=147593064 # bcftools merge -m id A.vcf B.vcf chr1 147022730 SV1 N . PASS SVLEN=-570334;END=147593064 chr1 147022730 SV2 N . PASS SVLEN=-990414;END=148013144 ``` -------------------------------- ### Run truvari bench to create a result directory Source: https://github.com/acenglish/truvari/wiki/refine Basic command to create a `bench` result directory that `refine` will later process. The output directory is `result/`. ```bash truvari bench -b base.vcf.gz -c comp.vcf.gz -f ref.fa -o result/ ``` -------------------------------- ### Run truvari bench and refine Source: https://github.com/acenglish/truvari/wiki/bench Commands to run truvari bench and then refine the output using the generated candidate.refine.bed file. ```bash truvari bench -b base.vcf.gz -c comp.vcf.gz --reference reference.fasta -o result/ truvari refine result/ ``` -------------------------------- ### stratify command-line help Source: https://github.com/acenglish/truvari/wiki/stratify Shows the full usage and options for the stratify command: positional arguments BED and VCF, and optional flags -o/--output, --header, -w/--within, and --debug. ```text usage: stratify [-h] [-o OUT] [--header] [-w] [--debug] BED VCF Count variants per-region in vcf positional arguments: BED Regions to process VCF Truvari bench result directory or a single VCF optional arguments: -h, --help show this help message and exit -o OUT, --output OUT Output bed-like file --header Input regions have header to preserve in output -w, --within Only count variants completely contained within region boundaries --debug Verbose logging ``` -------------------------------- ### View Truvari API documentation with help() Source: https://github.com/acenglish/truvari/blob/develop/docs/Development.md Shows how to access Truvari's developer documentation directly from Python. Use this to explore available helper methods and objects. ```python import truvari help(truvari) ``` -------------------------------- ### vcf2df command-line usage and options Source: https://github.com/acenglish/truvari/wiki/vcf2df Shows the full command-line help for truvari vcf2df, including positional arguments and all options for parsing INFO/FORMAT fields, handling bench directories, and output format. ```text usage: vcf2df [-h] [-b] [-i] [-f] [-s SAMPLE] [-n] [-S] [-c LVL] [-a] [-p] [--debug] VCF JL Takes a vcf and creates a data frame. Can parse a bench output directory positional arguments: VCF VCF to parse JL Output joblib to save options: -h, --help show this help message and exit -b, --bench-dir Input is a truvari bench directory -i, --info Attempt to put the INFO fields into the dataframe -f, --format Attempt to put the FORMAT fileds into the dataframe -s SAMPLE, --sample SAMPLE SAMPLE name to parse when building columns for --format -n, --no-prefix Don't prepend sample name to format columns -S, --skip-compression Skip the attempt to optimize the dataframe's size -c LVL, --compress LVL Compression level for joblib 0-9 (3) -a, --alleles Add REF/ALT alleles into the dataframe -p, --parquet Write a parquet file instead of joblib dump --debug Verbose logging ``` -------------------------------- ### Build Truvari Docker image Source: https://github.com/acenglish/truvari/blob/develop/docs/Development.md Builds a Docker image of Truvari from the cloned repository. Run this from the repository root. ```bash docker build -t truvari . ``` -------------------------------- ### Run truvari bench with --refine flag Source: https://github.com/acenglish/truvari/wiki/bench Command to run truvari bench with the --refine flag to automatically run refinement with default parameters. ```bash truvari bench -b base.vcf.gz -c comp.vcf.gz --reference reference.fasta -o result/ --refine ``` -------------------------------- ### abpoa memory allocation error example Source: https://github.com/acenglish/truvari/blob/develop/docs/phab.md Example error message from abpoa when a job fails due to memory allocation failure. Phab monitors these processes and may still exit with status 0 even if some tasks fail. ```text [SIMDMalloc] posix_memalign fail! Size: 274877906944, Error: ENOMEM ``` -------------------------------- ### truvari anno trf usage and options Source: https://github.com/acenglish/truvari/wiki/anno Shows the command-line usage and all options for truvari anno trf, including required arguments for input, repeats, and reference, plus optional parameters for TRF execution and filtering. ```text usage: trf [-h] -i INPUT [-o OUTPUT] [-e EXECUTABLE] [-T TRF_PARAMS] -r REPEATS -f REFERENCE [-s MOTIF_SIMILARITY] [-m MIN_LENGTH] [-R] [--no-estimate] [-C CHUNK_SIZE] [-t THREADS] [--debug] Intersect vcf with reference tandem repeats and annotate variants with the best fitting repeat motif and its copy number relative to the reference options: -h, --help show this help message and exit -i INPUT, --input INPUT VCF to annotate -o OUTPUT, --output OUTPUT Output filename (stdout) -e EXECUTABLE, --executable EXECUTABLE Path to tandem repeat finder (trf409.linux64) -T TRF_PARAMS, --trf-params TRF_PARAMS Default parameters to send to trf (3 7 7 80 5 40 500 -h -ngs) -r REPEATS, --repeats REPEATS Reference repeat annotations -f REFERENCE, --reference REFERENCE Reference fasta file -s MOTIF_SIMILARITY, --motif-similarity MOTIF_SIMILARITY Motif similarity threshold (0.9) -m MIN_LENGTH, --min-length MIN_LENGTH Minimum size of entry to annotate (50) -R, --regions-only Only write variants within --repeats regions (False) --no-estimate Skip INS estimation procedure and run everything through TRF. (False) -C CHUNK_SIZE, --chunk-size CHUNK_SIZE Size (in mbs) of reference chunks for parallelization (5) -t THREADS, --threads THREADS Number of threads to use (1) --debug Verbose logging ``` -------------------------------- ### Run truvari refine on a bench result Source: https://github.com/acenglish/truvari/wiki/refine Basic command to run `refine` on a `bench` result directory. The result directory is `result/`. ```bash truvari refine result/ ``` -------------------------------- ### Docker Run with Parameters Source: https://github.com/acenglish/truvari/wiki/Development Run Truvari through Docker with additional parameters passed to the entry point. ```APIDOC ## docker run with parameters ### Description Run Truvari through Docker with additional parameters passed to the entry point. ### Method bash ### Endpoint N/A ### Parameters #### Path Parameters - **pwd** (string) - Required - The local directory to mount to /data. #### Query Parameters - **params** (string) - Required - The parameters to pass to the Truvari command. ### Request Example ```bash docker run -v `pwd`:/data -it truvari anno svinfo -i example.vcf.gz ``` ### Response #### Success Response - **exit_code** (integer) - The exit code of the Truvari command. #### Response Example ``` 0 ``` ``` -------------------------------- ### gt_matrix table representation Source: https://github.com/acenglish/truvari/wiki/bench Tabular representation of the gt_matrix example, showing base genotypes as rows and comp genotypes as columns. ```text comp (0,1) (1,1) base (0,1) 500 10 (1,1) 20 800 ``` -------------------------------- ### truvari divide command-line usage and options Source: https://github.com/acenglish/truvari/wiki/divide Shows the full usage and options for `truvari divide`, including positional arguments (VCF, DIR) and optional flags for buffer size, minimum variants, compression, and threading. ```text usage: divide [-h] [-b BUFFER] [-m MIN] [--no-compress] [-T THREADS] VCF DIR Divide a VCF into independent parts positional arguments: VCF VCF to split DIR Output directory to save parts options: -h, --help show this help message and exit -b BUFFER, --buffer BUFFER Buffer to make mini-clusters (1000) -m MIN, --min MIN Minimum number of entries per-vcf (100) --no-compress Don't attempt to compress/index sub-VCFs -T THREADS, --threads THREADS Number of threads for compressing/indexing sub-VCFs (1) ``` -------------------------------- ### Run Tests and Generate Coverage Source: https://github.com/acenglish/truvari/wiki/Development Run the test suite and generate a coverage report. ```APIDOC ## bash repo_utils/truvari_ssshtests.sh ### Description Run the test suite and generate a coverage report. ### Method bash ### Endpoint N/A ### Parameters None ### Request Example ```bash bash repo_utils/truvari_ssshtests.sh ``` ### Response #### Success Response - **exit_code** (integer) - The exit code of the test suite. #### Response Example ``` 0 ``` ``` -------------------------------- ### Parse BND information from VCF entries Source: https://github.com/acenglish/truvari/blob/develop/docs/api/truvari.examples.rst Parse BND (breakend) information from a VCF entry using bnd_position() and bnd_direction_strand(). The example shows the output for a sample BND entry. ```python # Example entry: # chr1 23272628 SV_1 G G]chr5:52747359] . PASS SVTYPE=BND;EVENTTYPE=TRA:UNBALANCED;SUBCLONAL=n;COMPLEX=n;MATEID=SV_171 GT:PSL:PSO 0/1:.:. print(entry.bnd_position()) # ('chr5', 52747359) print(entry.bnd_direction_strand()) # ('right', 'direct') ``` -------------------------------- ### Docker Build Source: https://github.com/acenglish/truvari/wiki/Development Build a Docker image of Truvari from the repository. ```APIDOC ## docker build ### Description Build a Docker image of Truvari from the repository. ### Method bash ### Endpoint N/A ### Parameters None ### Request Example ```bash docker build -t truvari . ``` ### Response #### Success Response - **image** (string) - The built Docker image tagged as 'truvari'. #### Response Example ``` Successfully built ``` ``` -------------------------------- ### List available git tags Source: https://github.com/acenglish/truvari/wiki/Installation Shows all tags in the Truvari repository, useful for finding version numbers. ```bash git tag -l ``` -------------------------------- ### Run truvari bench on phab test files Source: https://github.com/acenglish/truvari/wiki/phab Benchmarks the base and comparison VCFs over the region to show initial variant matching. Uses --sizemin 0 to include SNPs, --no-ref a to exclude reference homozygous sites, and samples HG002 and syndip. The resulting summary.txt shows poor precision and recall. ```bash truvari bench --base phab_base.vcf.gz \ --comp phab_comp.vcf.gz \ --sizemin 0 \ --bSample HG002 \ --cSample syndip \ --no-ref a \ --output initial_bench ``` -------------------------------- ### Convert collapse results to DataFrames with truvari vcf2df Source: https://github.com/acenglish/truvari/wiki/MatchIds Converts the kept and removed VCFs from truvari collapse to joblib files. These are used in the subsequent Python example to merge collapse results. ```bash truvari vcf2df -i kept.vcf.gz kept.jl truvari vcf2df -i removed.vcf.gz remov.jl ``` -------------------------------- ### Docker Run Source: https://github.com/acenglish/truvari/wiki/Development Run Truvari through Docker, mounting a local directory to /data. ```APIDOC ## docker run ### Description Run Truvari through Docker, mounting a local directory to /data. ### Method bash ### Endpoint N/A ### Parameters #### Path Parameters - **pwd** (string) - Required - The local directory to mount to /data. ### Request Example ```bash docker run -v `pwd`:/data -it truvari ``` ### Response #### Success Response - **exit_code** (integer) - The exit code of the Truvari command. #### Response Example ``` 0 ``` ``` -------------------------------- ### Filter variants by size with VariantParams Source: https://github.com/acenglish/truvari/blob/develop/docs/api/truvari.examples.rst Use VariantParams with sizemin and sizemax to filter variants by size. The example retrieves all variant records within the specified size range using the filter_size() method. ```python p = truvari.VariantParams(sizemin=200, sizemax=500) vcf = truvari.VariantFile("input.vcf.gz", params=p) # Retrieve all variant records within sizemin and sizemax results = [entry for entry in vcf if not entry.filter_size()] ``` -------------------------------- ### Run truvari bench to compare harmonized VCFs Source: https://github.com/acenglish/truvari/blob/develop/docs/phab.md Benchmarks two harmonized VCFs using truvari bench with specific sample and region options. The output summary shows perfect precision and recall (1.0) for the compared variants. ```bash truvari bench -b harmonized.vcf.gz \ -c harmonized.vcf.gz \ -s --no-ref a \ --bSample HG002 \ --cSample syndip \ -o harmonized_bench/ ``` ```json { "TP-base": 8, "TP-comp": 8, "FP": 0, "FN": 0, "precision": 1.0, "recall": 1.0, "f1": 1.0, } ``` -------------------------------- ### density Source: https://github.com/acenglish/truvari/wiki/anno Partitions the genome into windows and counts overlapping variants, annotating regions as 'sparse' or 'dense' based on statistical thresholds. Outputs a joblib DataFrame with columns chrom, start, end, count, anno. ```APIDOC ## density ### Description Partitions a genome into windows and counts how many variants overlap each window. Annotates regions with no variants as 'sparse' and regions with at least (mean + threshold * standard deviation) variants as 'dense'. Outputs a joblib DataFrame with columns chrom, start, end, count, anno. ### Usage ``` density [-h] -g GENOME -o OUTPUT [-m MASK] [-w WINDOWSIZE] [-s STEPSIZE] [-t THRESHOLD] [input] ``` ### Arguments - **input** (string) - Optional - Input VCF file (use /dev/stdin for standard input) ### Options - **-h, --help** - Show help message and exit - **-g, --genome** (string) - Required - Genome bed file - **-o, --output** (string) - Required - Output joblib DataFrame file - **-m, --mask** (string) - Optional - Mask bed file - **-w, --windowsize** (integer) - Optional - Window size (default: 10000) - **-s, --stepsize** (integer) - Optional - Window step size (default: 10000) - **-t, --threshold** (float) - Optional - Standard deviation multiplier for identifying 'dense' regions (default: 3) ### Output A joblib DataFrame with columns: chrom, start, end, count, anno. ``` -------------------------------- ### truvari stratp --preset mims truvari_output/ Source: https://github.com/acenglish/truvari/wiki/Stratp-Test Runs the StratP test using a preset stratification from the SMaHT MIMS SV benchmark on the specified truvari output directory. ```APIDOC ## [COMMAND] truvari stratp --preset mims truvari_output/ ### Description Runs the StratP test using a preset stratification from the SMaHT MIMS SV benchmark on the specified truvari output directory. ### Method COMMAND ### Endpoint `truvari stratp --preset mims truvari_output/` ### Parameters #### Command Line Arguments - **--preset** (string) - Required - The name of the preset stratification to use. Currently available presets are from GIAB v1.1 SVs and the SMaHT MIMS SV benchmarks. - **truvari_output/** (string) - Required - Path to the truvari output directory containing the variant calls to be analyzed. ### Request Example ```bash truvari stratp --preset mims truvari_output/ ``` ### Response #### Success Response Outputs a report with the following columns: - **feature** (string) - Stratification feature (e.g. `svtype`) - **value** (string) - Stratification value (e.g. `DEL`) - **acc** (float) - Accuracy of calls in this stratification (e.g. `TP / (TP+FN)`) - **obs** (integer) - Number of variants observed in this stratification - **delta** (float) - Observed mean ranking minus permutation tests' mean ranking - **q1** (float) - 1% Quantile of permutation tests - **q50** (float) - 50% Quantile of permutation tests - **q99** (float) - 99% Quantile of permutation tests - **pval** (float) - Raw permutation test p-value - **adj_pval** (float) - Benjamini/Hochberg multiple test correction adjusted pvalue - **reject** (boolean) - True or False based on rejection of null hypothesis at given alpha #### Response Example ``` feature value acc obs delta q1 q50 q99 pval adj_pval reject ``` ``` -------------------------------- ### Access variant properties with truvari.VariantFile Source: https://github.com/acenglish/truvari/blob/develop/docs/api/truvari.examples.rst Use truvari.VariantFile to read a VCF file and access variant INFO fields, type/size properties, genotype, and allele frequency annotations. This example shows both pysam and truvari access methods. ```python import truvari vcf = truvari.VariantFile("input.vcf.gz") for entry in vcf: # Access variant's INFO fields using pysam if 'SVTYPE' in entry.info and 'SVLEN' in entry.info: print(entry.info['SVTYPE'], entry.info['SVLEN']) # But these INFOs aren't always available. # Access type/size properties of variants using truvari print(entry.var_type(), entry.var_size()) # Access genotype (GT) # using pysam -> if 'SAMPLE' in entry.samples and 'GT' in entry.samples['SAMPLE']: print(entry.samples['SAMPLE']['GT']) # using truvari -> print(entry.gt('SAMPLE')) # Calculate variant's allele frequency with truvari print(entry.allele_freq_annos()) ``` -------------------------------- ### Convert vcf2df DataFrame to PyRanges Source: https://github.com/acenglish/truvari/blob/develop/docs/vcf2df.md Converts a vcf2df DataFrame to a PyRanges object for range queries. Requires renaming columns to 'Chromosome', 'Start', and 'End' as expected by PyRanges. ```python result = pyranges.PyRanges(df.rename(columns={'chrom':"Chromosome", "start":"Start", "end":"End"})) ``` -------------------------------- ### Run Pylint Check Source: https://github.com/acenglish/truvari/wiki/Development Check code formatting using pylint. ```APIDOC ## python repo_utils/pylint_maker.py ### Description Check code formatting using pylint. ### Method bash ### Endpoint N/A ### Parameters None ### Request Example ```bash python repo_utils/pylint_maker.py ``` ### Response #### Success Response - **exit_code** (integer) - The exit code of the pylint check. #### Response Example ``` 0 ``` ``` -------------------------------- ### Convert bench result to DataFrame with truvari vcf2df Source: https://github.com/acenglish/truvari/wiki/MatchIds Converts a truvari bench result directory to a joblib file using the --info flag. The output file data.jl is used in the subsequent Python example to combine matched variants. ```bash truvari vcf2df --info --bench-dir bench_result/ data.jl ``` -------------------------------- ### Filter VCF with bedtools intersect for includebed Source: https://github.com/acenglish/truvari/wiki/bench Command to pre-filter base and comparison calls using an include BED file, similar to Truvari's --includebed option. Note that Truvari requires start and end to be in the same region, unlike bedtools intersect. ```bash (zgrep "#" my_calls.vcf.gz && bedtools intersect -u -a my_calls.vcf.gz -b include.bed) | bgzip > filtered.vcf.gz ``` -------------------------------- ### Python state classification logic for refine.regions.txt Source: https://github.com/acenglish/truvari/blob/develop/docs/refine.md Defines per-region TP/FN/FP state using out_* columns. A region with both FP and FN is counted twice (state 'FP,FN'); regions within --refdist may get 'UNK' and are ignored in region summary. ```python false_pos = (data['out_fp'] != 0) false_neg = (data['out_fn'] != 0) any_false = false_pos | false_neg true_positives = (data['out_tp'] != 0) & (data['out_tpbase'] != 0) & ~any_false true_negatives = (data[['out_tpbase', 'out_tp', 'out_fn', 'out_fp']] == 0).all(axis=1) baseP = (data['out_tpbase'] != 0) | (data['out_fn'] != 0) compP = (data['out_tp'] != 0) | (data['out_fp'] != 0) ``` -------------------------------- ### Run Truvari tests and coverage Source: https://github.com/acenglish/truvari/blob/develop/docs/Development.md Tests the code and generates a coverage report. Once successful, it uploads an artifact of the coverage html report. ```bash bash repo_utils/truvari_ssshtests.sh ``` -------------------------------- ### Run FuncTests and Truvari inside Docker Source: https://github.com/acenglish/truvari/blob/develop/docs/Development.md Commands to run inside the Docker container: first runs the FuncTests script, then runs Truvari directly. ```bash bash repo_utils/truvari_ssshtests.sh truvari anno svinfo -i example.vcf.gz ``` -------------------------------- ### Run Truvari via Docker Source: https://github.com/acenglish/truvari/blob/develop/docs/Development.md Runs Truvari through Docker, mounting the current directory to /data, which is the working directory for the Truvari run. You can provide parameters directly to the entry point. ```bash docker run -v `pwd`:/data -it truvari ``` -------------------------------- ### Refine benchmark results with truvari refine Source: https://github.com/acenglish/truvari/blob/develop/README.md Runs the Truvari refine command to harmonize phased variants and find more matches in the benchmark output. ```bash truvari refine output_dir/ ```