Skip to content

Commit

Permalink
Documentation progress
Browse files Browse the repository at this point in the history
Quick start is pretty solid, now
  • Loading branch information
ACEnglish committed Jan 7, 2025
1 parent 07dd27b commit 46310bf
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
37 changes: 37 additions & 0 deletions docs/api/truvari.examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,40 @@ size of SVs one wants to analyze which can be leveraged via:
results = [entry for entry in vcf if not entry.size_filter()]
Additional filtering for things such as monomorphic reference sites or single-end BNDs are available by calling `entry.filter_call()`

A common operation one needs to perform on a VCF is subsetting to regions from e.g. a bed file. This can be performed by
truvari by simply calling

.. code-block:: python
for entry in vcf.bed_fetch("regions.bed"):
print(entry.var_type(), entry.size())
In cases where your regions of interest aren't in a bed file, but an in-memory object, the `.regions_fetch`
method allows iteration over the variants of interest.

.. code-block:: 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.regions_fetch(tree):
count += 1
print(f"Total of {count} variants")
Furthermore, you can iterate variant that aren't within the regions via `vcf.regions_fetch(tree, within=False)`.

A particularly pesky problem to deal with is parsing BND information out of VCF entries. Truvari can help with that,
also.

.. code-block:: 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')
5 changes: 3 additions & 2 deletions truvari/bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,9 @@ class Bench():
m_bench = truvari.Bench(matcher, base_vcf, comp_vcf, outdir)
output = m_bench.run()
Note that running on files must write to an output directory and is the only way to use things like 'includebed'.
However, the returned `BenchOutput` has attributes pointing to all the results.
.. note::
Running on files must write to an output directory and is the only way to use things like 'includebed'.
However, the returned `BenchOutput` has attributes pointing to all the results.
"""

def __init__(self, matcher=None, base_vcf=None, comp_vcf=None, outdir=None,
Expand Down

0 comments on commit 46310bf

Please sign in to comment.