Skip to content

Commit 757c2eb

Browse files
committed
Prerelease
1 parent 9c640c3 commit 757c2eb

21 files changed

+1503
-2
lines changed

docs/v3.3.0/Citations.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Citing Truvari
2+
3+
Pre-print on Biorxiv while in submission:
4+
5+
Truvari: Refined Structural Variant Comparison Preserves Allelic Diversity
6+
doi: https://doi.org/10.1101/2022.02.21.481353
7+
8+
# Citations
9+
10+
List of publications using Truvari. Most of these are just pulled from a [Google Scholar Search](https://scholar.google.com/scholar?q=truvari). Please post in the [show-and-tell](https://github.com/spiralgenetics/truvari/discussions/categories/show-and-tell) to have your publication added to the list.
11+
* [A robust benchmark for detection of germline large deletions and insertions](https://www.nature.com/articles/s41587-020-0538-8)
12+
* [Leveraging a WGS compression and indexing format with dynamic graph references to call structural variants](https://www.biorxiv.org/content/10.1101/2020.04.24.060202v1.abstract)
13+
* [Duphold: scalable, depth-based annotation and curation of high-confidence structural variant calls](https://academic.oup.com/gigascience/article/8/4/giz040/5477467?login=true)
14+
* [Parliament2: Accurate structural variant calling at scale](https://academic.oup.com/gigascience/article/9/12/giaa145/6042728)
15+
* [Learning What a Good Structural Variant Looks Like](https://www.biorxiv.org/content/10.1101/2020.05.22.111260v1.full)
16+
* [Long-read trio sequencing of individuals with unsolved intellectual disability](https://www.nature.com/articles/s41431-020-00770-0)
17+
* [lra: A long read aligner for sequences and contigs](https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1009078)
18+
* [Samplot: a platform for structural variant visual validation and automated filtering](https://genomebiology.biomedcentral.com/articles/10.1186/s13059-021-02380-5)
19+
* [AsmMix: A pipeline for high quality diploid de novo assembly](https://www.biorxiv.org/content/10.1101/2021.01.15.426893v1.abstract)
20+
* [Accurate chromosome-scale haplotype-resolved assembly of human genomes](https://www.nature.com/articles/s41587-020-0711-0)
21+
* [Accurate circular consensus long-read sequencing improves variant detection and assembly of a human genome](https://www.nature.com/articles/s41587-019-0217-9)
22+
* [NPSV: A simulation-driven approach to genotyping structural variants in whole-genome sequencing data](https://academic.oup.com/bioinformatics/article-abstract/37/11/1497/5466452)
23+
* [SVIM-asm: structural variant detection from haploid and diploid genome assemblies](https://academic.oup.com/bioinformatics/article/36/22-23/5519/6042701?login=true)
24+
* [Readfish enables targeted nanopore sequencing of gigabase-sized genomes](https://www.nature.com/articles/s41587-020-00746-x)
25+
* [stLFRsv: A Germline Structural Variant Analysis Pipeline Using Co-barcoded Reads](https://internal-journal.frontiersin.org/articles/10.3389/fgene.2021.636239/full)
26+
* [Long-read-based human genomic structural variation detection with cuteSV](https://genomebiology.biomedcentral.com/articles/10.1186/s13059-020-02107-y)
27+
* [An international virtual hackathon to build tools for the analysis of structural variants within species ranging from coronaviruses to vertebrates](https://f1000research.com/articles/10-246)
28+
* [Paragraph: a graph-based structural variant genotyper for short-read sequence data](https://link.springer.com/article/10.1186/s13059-019-1909-7)
29+
* [Genome-wide investigation identifies a rare copy-number variant burden associated with human spina bifida](https://www.nature.com/articles/s41436-021-01126-9)
30+
* [TT-Mars: Structural Variants Assessment Based on Haplotype-resolved Assemblies](https://www.biorxiv.org/content/10.1101/2021.09.27.462044v1.abstract)
31+
* [An ensemble deep learning framework to refine large deletions in linked-reads](https://www.biorxiv.org/content/10.1101/2021.09.27.462057v1.abstract)
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
A frequent application of comparing SVs is to perform a 'bakeoff' of performance
2+
between two SV programs against a single set of base calls.
3+
4+
Beyond looking at the Truvari results/report, you may like to investigate what calls
5+
are different between the programs.
6+
7+
Below is a set of scripts that may help you generate those results. For our examples,
8+
we'll be comparing arbitrary programs Asvs and Bsvs aginst base calls Gsvs.
9+
10+
*_Note_* - This assumes that each record in Gsvs has a unique ID in the vcf.
11+
12+
Generate the Truvari report for Asvs and Bsvs
13+
=============================================
14+
15+
```bash
16+
truvari bench -b Gsvs.vcf.gz -c Asvs.vcf.gz -o cmp_A/ ...
17+
truvari bench -b Gsvs.vcf.gz -c Bsvs.vcf.gz -o cmp_B/ ...
18+
```
19+
20+
Combine the TPs within each report
21+
==================================
22+
23+
```bash
24+
cd cmp_A/
25+
paste <(grep -v "#" tp-base.vcf) <(grep -v "#" tp-call.vcf) > combined_tps.txt
26+
cd ../cmp_B/
27+
paste <(grep -v "#" tp-base.vcf) <(grep -v "#" tp-call.vcf) > combined_tps.txt
28+
```
29+
30+
Grab the FNs missed by only one program
31+
=======================================
32+
33+
```bash
34+
(grep -v "#" cmp_A/fn.vcf && grep -v "#" cmp_B/fn.vcf) | cut -f3 | sort | uniq -c | grep "^ *1 " | cut -f2- -d1 > missed_names.txt
35+
```
36+
37+
Pull the TP sets' difference
38+
============================
39+
40+
```bash
41+
cat missed_names.txt | xargs -I {} grep -w {} cmp_A/combined_tps.txt > missed_by_B.txt
42+
cat missed_names.txt | xargs -I {} grep -w {} cmp_B/combined_tps.txt > missed_by_A.txt
43+
```
44+
45+
To look at the base-calls that Bsvs found, but Asvs didn't, run `cut -f1-12 missed_by_A.txt`.
46+
47+
To look at the Asvs that Bsvs didn't find, run `cut -f13- missed_by_B.txt`.
48+
49+
Calculate the overlap
50+
=====================
51+
52+
One may wish for summary numbers of how many calls are shared/unique between the two programs.
53+
Truvari has a program to help. See [[Consistency-report|consistency]] for details.
54+
55+
Shared FPs between the programs
56+
===============================
57+
58+
All of the work above has been about how to analyze the TruePositives. If you'd like to see which calls are shared between Asvs and Bsvs that aren't in Gsvs, simply run Truvari again.
59+
60+
```bash
61+
bgzip cmp_B/fp.vcf && tabix -p vcf cmp_B/fp.vcf.gz
62+
truvari bench -b cmp_A/fp.vcf -c cmp_B/fp.vcf.gz -o shared_fps ...
63+
```

docs/v3.3.0/Development.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Truvari API
2+
Many of the helper methods/objects are documented such that developers can reuse truvari in their own code. To see developer documentation, visit [readthedocs](https://truvari.readthedocs.io/en/latest/).
3+
4+
Documentation can also be seen using
5+
```python
6+
import truvari
7+
help(truvari)
8+
```
9+
10+
# docker
11+
12+
A Dockerfile exists to build an image of Truvari. To make a Docker image, clone the repository and run
13+
```bash
14+
docker build -t truvari .
15+
```
16+
17+
You can then run Truvari through docker using
18+
```bash
19+
docker run -v `pwd`:/data -it truvari
20+
```
21+
Where `pwd` can be whatever directory you'd like to mount in the docker to the path `/data/`, which is the working directory for the Truvari run. You can provide parameters directly to the entry point.
22+
```bash
23+
docker run -v `pwd`:/data -it truvari anno svinfo -i example.vcf.gz
24+
```
25+
26+
If you'd like to interact within the docker container for things like running the CI/CD scripts
27+
```bash
28+
docker run -v `pwd`:/data --entrypoint /bin/bash -it truvari
29+
```
30+
You'll now be inside the container and can run FuncTests or run Truvari directly
31+
```bash
32+
bash repo_utils/truvari_ssshtests.sh
33+
truvari anno svinfo -i example.vcf.gz
34+
```
35+
36+
# CI/CD
37+
38+
Scripts that help ensure the tool's quality. Extra dependencies need to be installed in order to run Truvari's CI/CD scripts.
39+
40+
```bash
41+
pip install pylint anybadge coverage
42+
```
43+
44+
Check code formatting with
45+
```bash
46+
python repo_utils/pylint_maker.py
47+
```
48+
We use [autopep8](https://pypi.org/project/autopep8/) (via [vim-autopep8](https://github.com/tell-k/vim-autopep8)) for formatting.
49+
50+
Test the code and generate a coverage report with
51+
```bash
52+
bash repo_utils/truvari_ssshtests.sh
53+
```
54+
55+
Truvari leverages github actions to perform these checks when new code is pushed to the repository. We've noticed that the actions sometimes hangs through no fault of the code. If this happens, cancel and resubmit the job. Once FuncTests are successful, it uploads an artifact of the `coverage html` report which you can download to see a line-by-line accounting of test coverage.
56+
57+
# git flow
58+
59+
To organize the commits for the repository, we use [git-flow](https://danielkummer.github.io/git-flow-cheatsheet/). Therefore, `develop` is the default branch, the latest tagged release is on `master`, and new, in-development features are within `feature/<name>`
60+
61+
When contributing to the code, be sure you're working off of develop and have run `git flow init`.
62+
63+
# versioning
64+
65+
Truvari uses [Semantic Versioning](https://semver.org/). As of v3.0.0, a single version is kept in the code under `truvari/__init__.__version__`. We try to keep the suffix `-dev` on the version in the develop branch. When cutting a new release, we may replace the suffix with `-rc` if we've built a release candidate that may need more testing/development. Once we've committed to a full release that will be pushed to PyPi, no suffix is placed on the version.
66+
67+
# docs
68+
69+
The github wiki serves the documentation most relevant to the `develop/` branch. When cutting a new release, we freeze and version the wiki's documentation with the helper utility `docs/freeze_wiki.sh`.
70+
71+
# Creating a release
72+
Follow these steps to create a release
73+
74+
0) Bump release version
75+
1) Run tests locally
76+
2) Update API Docs
77+
3) Freeze the Wiki
78+
4) Ensure all code is checked in
79+
5) Do a [git-flow release](https://danielkummer.github.io/git-flow-cheatsheet/)
80+
6) Use github action to make a testpypi release
81+
7) Check test release
82+
```bash
83+
python3 -m venv test_truvari
84+
python3 -m pip install --index-url https://test.pypi.org/simple --extra-index-url https://pypi.org/simple/ truvari
85+
```
86+
8) Use GitHub action to make a pypi release
87+
9) Change Updates Wiki
88+
10) Download release-tarball.zip from step #8’s action
89+
11) Create release (include #9) from the tag
90+
12) Checkout develop and Bump to dev version and README ‘commits since’ badge
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
By default, Truvari uses [edlib](https://github.com/Martinsos/edlib) to calculate the edit distance between two SV calls. Optionally, the [Levenshtein edit distance ratio](https://en.wikipedia.org/wiki/Levenshtein_distance) can be used to compute the `--pctsim` between two variants. These measures are different than the sequence similarity calculated by [Smith-Waterman alignment](https://en.wikipedia.org/wiki/Smith%E2%80%93Waterman_algorithm).
2+
3+
To show this difference, consider the following two sequences.:
4+
5+
```
6+
AGATACAGGAGTACGAACAGTACAGTACGA
7+
|||||||||||||||*||||||||||||||
8+
ATCACAGATACAGGAGTACGTACAGTACAGTACGA
9+
10+
30bp Aligned
11+
1bp Mismatched (96% similarity)
12+
5bp Left-Trimmed (~14% of the bottom sequence)
13+
```
14+
15+
The code below runs swalign, Levenshtein, and edlib to compute the `--pctsim` between the two sequences.
16+
17+
18+
```python
19+
import swalign
20+
import Levenshtein
21+
import edlib
22+
23+
seq1 = "AGATACAGGAGTACGAACAGTACAGTACGA"
24+
seq2 = "ATCACAGATACAGGAGTACGTACAGTACAGTACGA"
25+
26+
scoring = swalign.NucleotideScoringMatrix(2, -1)
27+
alner = swalign.LocalAlignment(scoring, gap_penalty=-2, gap_extension_decay=0.5)
28+
aln = alner.align(seq1, seq2)
29+
mat_tot = aln.matches
30+
mis_tot = aln.mismatches
31+
denom = float(mis_tot + mat_tot)
32+
if denom == 0:
33+
ident = 0
34+
else:
35+
ident = mat_tot / denom
36+
scr = edlib.align(seq1, seq2)
37+
totlen = len(seq1) + len(seq2)
38+
39+
print('swalign', ident)
40+
# swalign 0.966666666667
41+
print('levedit', Levenshtein.ratio(seq1, seq2))
42+
# levedit 0.892307692308
43+
print('edlib', (totlen - scr["editDistance"]) / totlen)
44+
# edlib 0.9076923076923077
45+
```
46+
47+
Because the swalign procedure only considers the number of matches and mismatches, the `--pctsim` is higher than the edlib and Levenshtein ratio.
48+
49+
If we were to account for the 5 'trimmed' bases from the Smith-Waterman alignment when calculating the `--pctsim` by counting each trimmed base as a mismatch, we would see the similarity drop to ~83%.
50+
51+
[This post](https://stackoverflow.com/questions/14260126/how-python-levenshtein-ratio-is-computed) has a nice response describing exactly how the Levenshtein ratio is computed.
52+
53+
The Smith-Waterman alignment is much more expensive to compute compared to the Levenshtein ratio, and does not account for 'trimmed' sequence difference.
54+
55+
However, edlib is the fastest comparison method and is used by default. Levenshtein can be specified with `--use-lev` in `bench` and `collapse`.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
As part of the GIAB analysis, tandem repeat (TR) stratifications for false positives (FP), false negatives (FN), and true positives (TP) were analyzed. See [this discussion](https://groups.google.com/d/msg/giab-analysis-team/tAtVBm9Fdrw/I2qeazh8AwAJ) for details.
2+
3+
The stratifications.sh script automates the procedure above by taking a Truvari bench output directory as the first argument and TR repeat annotations (found in the link above) to create the following files in the output directory.
4+
5+
Running this script requires `bedtools`, `vcf-sort`, and `bgzip` to be in your environment.
6+
7+
8+
| FileName | Description |
9+
|---------------------|---------------------------------------|
10+
| fn_ins_nonTR.vcf.gz | FN insertions not found in TR regions |
11+
| fn_ins_TR.vcf.gz | FN insertions found in TR regions |
12+
| fp_ins_nonTR.vcf.gz | FP insertions not found in TR regions |
13+
| fp_ins_TR.vcf.gz | FP insertions found in TR regions |
14+
| fn_del_nonTR.vcf.gz | FN insertions not found in TR regions |
15+
| fn_del_TR.vcf.gz | FN insertions found in TR regions |
16+
| fp_del_nonTR.vcf.gz | FP insertions not found in TR regions |
17+
| fp_del_TR.vcf.gz | FP insertions found in TR regions |

docs/v3.3.0/Home.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
The wiki holds documentation most relevant for develop. For information on a specific version of Truvari, see [`docs/`](https://github.com/spiralgenetics/truvari/tree/develop/docs)
2+
3+
Truvari: Refined Structural Variant Comparison Preserves Allelic Diversity
4+
doi: https://doi.org/10.1101/2022.02.21.481353
5+
6+
# Before you start
7+
VCFs aren't always created with a strong adherence to the format's specification.
8+
9+
Truvari expects input VCFs to be valid so that it will only output valid VCFs.
10+
11+
We've developed a separate tool that runs multiple validation programs and standard VCF parsing libraries in order to validate a VCF.
12+
13+
Run [this program](https://github.com/acenglish/usable_vcf) over any VCFs that are giving Truvari trouble.
14+
15+
Furthermore, Truvari expects 'resolved' SVs (e.g. DEL/INS) and will not interpret BND signals across SVTYPEs (e.g. combining two BND lines to match a DEL call). A brief description of Truvari bench methodology is linked below.
16+
17+
# Index
18+
19+
- [[Updates|Updates]]
20+
- [[Installation|Installation]]
21+
- Truvari Commands:
22+
- [[bench|bench]]
23+
- [[The multimatch parameter|The--multimatch-parameter]]
24+
- [[Edit Distance Ratio vs Sequence Similarity|Edit-Distance-Ratio-vs-Sequence-Similarity]]
25+
- [[Multi-allelic VCFs|Multi-allelic-VCFs]]
26+
- [[stratifications.sh|GIAB-stratifications.sh]]
27+
- [[Comparing two SV programs|Comparing-two-SV-programs]]
28+
- [[consistency|consistency]]
29+
- [[anno|anno]]
30+
- [[collapse|collapse]]
31+
- [[vcf2df|vcf2df]]
32+
- [[segment|segment]]
33+
- [[Development|Development]]
34+
- [[Citations|Citations]]
35+
- [[Resources|Resources]]

docs/v3.3.0/Installation.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
Recommended
2+
===========
3+
For stable versions of Truvari, use pip
4+
```
5+
python3 -m pip install truvari
6+
```
7+
Specific versions can be installed via
8+
```
9+
python3 -m pip install truvari==3.0.0
10+
```
11+
See [pypi](https://pypi.org/project/Truvari/#history) for a history of all distributed releases.
12+
13+
Manual Installation
14+
===================
15+
To build Truvari directly, clone the repository and switch to a specific tag.
16+
```
17+
git clone https://github.com/spiralgenetics/truvari.git
18+
git checkout tags/v3.0.0
19+
python3 setup.py install
20+
```
21+
To see a list of all available tags, run:
22+
```
23+
git tag -l
24+
```
25+
If you have an older clone of the repository, but don't see the version you're looking for in tags, make sure to pull the latest changes:
26+
```
27+
git pull
28+
git fetch --all --tags
29+
```
30+
31+
Mamba
32+
=====
33+
Users can follow instructions here (https://mamba.readthedocs.io/en/latest/installation.html) to install mamba. (A faster alternative conda compatible package manager.)
34+
35+
Creating an environment with Truvari and its dependencies.
36+
```
37+
mamba create -c conda-forge -c bioconda -n truvari truvari
38+
```
39+
Note: as of May 4, 2022 mamba is up to date with Truvari's v3.2.0 release. Until we implement an auto-deployment to our github actions, mamba official releases may lag behind.
40+
41+
Building from develop
42+
=====================
43+
The default branch is `develop`, which holds in-development changes. This is for developers or those wishing to try experimental features and is not recommended for production. Development is versioned higher than the most recent stable release with an added suffix (e.g. Current stable release is `3.0.0`, develop holds `3.1.0-dev`). If you'd like to install develop, repeat the steps above but without `git checkout tags/v3.0.0`. See [wiki](https://github.com/spiralgenetics/truvari/wiki/Development#git-flow) for details on how branching is handled.
44+
45+
Docker
46+
======
47+
See [Development](https://github.com/spiralgenetics/truvari/wiki/Development#docker) for details on building a docker container.

docs/v3.3.0/MatchIds.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Using `bench` MatchId
2+
=====================
3+
4+
MatchIds are used to tie base/comparison calls together. MatchIds have a structure of `{chunkid}.{baseid}.{compid}`.
5+
Where:
6+
- chunkid - Unique id per-chunk of calls. All calls sharing chunkid were within `--chunksize` distance and were
7+
compared.
8+
- baseid - The number of the base call from this chunk
9+
- compid - The number of the comp call from this chunk
10+
11+
Doing basic pairing with MatchIds when results didn't have `--multimatch` is straight forward. For example, to tie tp-base.vcf and tp-call.vcf calls together, they will have identical MatchIds.
12+
13+
MatchIds with `_` for the baseid or compid are calls that were in a chunk without a counterpart (e.g. `5._.0` is the
14+
first comparison call from the fifth chunk, which had no base calls.)
15+
16+
Tieing a false positives/negatives to their closest matching counter part is a little tricker.
17+
For example, a false negative with MatchId `3.1.0`, we'll need to look in both the `fp.vcf` and `tp-call.vcf` for
18+
`3.*.0`.
19+
20+
When using `--multimatch` there can be instances such as:
21+
```
22+
VCF MatchId
23+
tp-base 3.0.0
24+
tp-call 3.0.0
25+
tp-call 3.0.1
26+
```
27+
Here, the 0th base/comp call match to one another. Additionally, the 1st comp call `3.0.1` also matches to the 0th base call `tp-base 3.0.0`.

docs/v3.3.0/Multi-allelic-VCFs.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Truvari only runs on comparing the first alternate allele in the base and comparison calls. If VCFs containing multi-allelic sites:
2+
3+
```
4+
chr2 1948201 . T TACAACACGTACGATCAGTAGAC,TCAACACACAACACGTACGATCAGTAGAC ....
5+
```
6+
7+
Pre-process the VCFs with bcftools to get a more complete result:
8+
9+
```bash
10+
bcftools norm -m-any base_calls.vcf.gz | bgzip > base_calls_split.vcf.gz
11+
```

docs/v3.3.0/Resources.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*page in progress*
2+
3+
Use `git-lfs` to pull the resources. Currently only useful for `truvari anno trf`

0 commit comments

Comments
 (0)