Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
uses: mamba-org/setup-micromamba@v2
with:
environment-file: environment.yml
environment-name: sprite
environment-name: wisp
create-args: >-
python=${{ matrix.python-version }}
init-shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.DS_Store

.git.broken
src/sprite_mask/__pycache__/
src/wisp_mask/__pycache__/
__pycache__/
*.py[cod]
*.py.tmp.*
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Read the Docs configuration file for sprite.
# Read the Docs configuration file for wisp.
# See https://docs.readthedocs.io/en/stable/config-file/v2.html

version: 2
Expand Down
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
`sprite`<img src="https://raw.githubusercontent.com/samuk-lab/sprite/master/docs/images/sprite_logo.png" align="right" width="20%">
`wisp`<img src="https://raw.githubusercontent.com/samuk-lab/wisp/master/docs/images/wisp_logo.png" align="right" width="20%">
====================

`sprite` builds population count masks from BAM/CRAM alignments or all-sites VCFs. It is a companion tool for [pixy](https://github.com/ksamuk/pixy/), though it works equally well on its own.
`wisp` builds population count masks from BAM/CRAM alignments or all-sites VCFs. It is a companion tool for [pixy](https://github.com/ksamuk/pixy/), though it works equally well on its own.

Population count masks let you correctly compute the denominators of π, d<sub>xy</sub>, Watterson's θ, and Tajima's D when working from a variants-only VCF — callable sites are counted per population rather than collapsed into a single cohort-wide pass/fail.

Sprite is inspired by [mop](https://github.com/RILAB/mop), [clam](https://github.com/cademirch/clam), and makes heavy use of [mosdepth](https://github.com/brentp/mosdepth).
Wisp is inspired by [mop](https://github.com/RILAB/mop), [clam](https://github.com/cademirch/clam), and makes heavy use of [mosdepth](https://github.com/brentp/mosdepth).

> **Note:** `sprite` is pre-release (alpha) and pending validation. It will be distributed on Bioconda as `sprite-mask` once stable.
> **Note:** `wisp` is pre-release (alpha) and pending validation. It will be distributed on Bioconda as `wisp-mask` once stable.

## Installation

```bash
mamba create -n sprite python=3.11 pip git -c conda-forge
mamba activate sprite
mamba create -n wisp python=3.11 pip git -c conda-forge
mamba activate wisp
mamba install -c conda-forge samtools bcftools htslib mosdepth
python -m pip install "git+https://github.com/samuk-lab/sprite.git"
python -m pip install "git+https://github.com/samuk-lab/wisp.git"
```

## Usage

### From BAM/CRAM alignments

`sprite` runs [mosdepth](https://github.com/brentp/mosdepth) on each sample and collapses per-sample pass intervals into a population count mask:
`wisp` runs [mosdepth](https://github.com/brentp/mosdepth) on each sample and collapses per-sample pass intervals into a population count mask:

```bash
sprite from-alignments \
wisp from-alignments \
--samples samples.tsv \
--variants-vcf variants.vcf.gz \
--out results \
Expand All @@ -43,7 +43,7 @@ sample_2 popB /path/sample_2.cram

If BAM/CRAM read groups include sample names, they must match the corresponding `sample_id`.

When `--variants-vcf` is provided, `sprite` uses the variants-only VCF to fill in omitted
When `--variants-vcf` is provided, `wisp` uses the variants-only VCF to fill in omitted
alignment thresholds: `--min-dp`/`--max-dp` from per-sample `FORMAT/DP` and `--min-mapq`
from `INFO/MQ` when those fields are available. Manually supplied threshold flags take
precedence. The same VCF is also scanned for indels, symbolic structural variants, breakends,
Expand All @@ -54,7 +54,7 @@ population.
### From an all-sites VCF

```bash
sprite from-vcf \
wisp from-vcf \
--all-sites-vcf all_sites.vcf.gz \
--popfile populations.tsv \
--min-dp 10 \
Expand All @@ -73,19 +73,19 @@ sample_2 popB
A few things to know about VCF mode:

- Every sample in the population file must appear in the VCF. VCF samples absent from the population file are ignored (with a warning).
- Records may carry any `FILTER` value — the input is assumed to have been filtered as desired before running `sprite`.
- Records may carry any `FILTER` value — the input is assumed to have been filtered as desired before running `wisp`.
- A sample passes a site when `FORMAT/DP >= --min-dp`, if supplied `FORMAT/DP <= --max-dp`, and, when `FORMAT/GT` is present, the genotype is not missing.
- At duplicate `CHROM:POS` records, a sample passes a site if any duplicate passes the depth thresholds. Duplicates must be contiguous, as in a coordinate-sorted VCF.
- By default, all record types are used (SNPs, indels, symbolic alleles, invariant sites). Pass `--snps-only` to exclude indel sites while retaining invariant sites.

## Output

`sprite` writes two files to `--out`:
`wisp` writes two files to `--out`:

| File | Description |
|---|---|
| `sprite.bed.gz` | bgzip-compressed, tabix-indexed population count mask |
| `sprite.bed.gz.tbi` | tabix index |
| `wisp.bed.gz` | bgzip-compressed, tabix-indexed population count mask |
| `wisp.bed.gz.tbi` | tabix index |

Use `--output-prefix` to change the filename stem; `.bed.gz` is always appended.

Expand Down
12 changes: 6 additions & 6 deletions docs/about.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
About
*****

``sprite`` creates population count masks for population genomic workflows.
``wisp`` creates population count masks for population genomic workflows.
Where a conventional depth mask gives a single cohort-wide pass/fail per
site, ``sprite`` reports how many samples in each population clear the depth
site, ``wisp`` reports how many samples in each population clear the depth
threshold.

Why population count masks?
Expand All @@ -29,13 +29,13 @@ Input modes
BAM/CRAM mode
-------------

In alignment mode, ``sprite`` runs ``mosdepth`` once per sample using a
In alignment mode, ``wisp`` runs ``mosdepth`` once per sample using a
two-bin quantization: below threshold and at-or-above threshold. It extracts
the passing intervals, optionally clips them to a mask BED, intersects all
sample pass BEDs with ``bedtools multiinter``, and assembles them into a
population count mask.

An optional variants-only VCF can modify this alignment workflow. ``sprite``
An optional variants-only VCF can modify this alignment workflow. ``wisp``
can estimate omitted depth and mapping-quality thresholds from the VCF, and
it subtracts indel, structural-variant, breakend, and multi-nucleotide
polymorphism spans from every sample pass BED. Because the final BED is
Expand All @@ -45,7 +45,7 @@ zero passing samples in every population.
All-sites VCF mode
------------------

In VCF mode, ``sprite`` reads ``FORMAT/DP`` values directly from an all-sites
In VCF mode, ``wisp`` reads ``FORMAT/DP`` values directly from an all-sites
VCF. A sample passes a base when its DP value is greater than or equal to
``--min-dp`` and, if ``--max-dp`` is supplied, less than or equal to
``--max-dp``. When ``FORMAT/GT`` is present, the genotype must also be
Expand All @@ -57,6 +57,6 @@ coordinate-sorted VCF.
Sparse output
=============

``sprite`` omits intervals where all population counts are zero. Consumers
``wisp`` omits intervals where all population counts are zero. Consumers
should treat missing intervals as zero passing samples per population, not as
unknown or skipped.
10 changes: 5 additions & 5 deletions docs/api.rst
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
API Reference
*************

The public interface is the ``sprite`` command line tool, but these modules are
The public interface is the ``wisp`` command line tool, but these modules are
useful when reading or extending the implementation.

Configuration
=============

.. automodule:: sprite_mask.config
.. automodule:: wisp_mask.config
:members:

Workflow
========

.. automodule:: sprite_mask.workflow
.. automodule:: wisp_mask.workflow
:members: run_workflow, workflow_output_paths

Samples
=======

.. automodule:: sprite_mask.samples
.. automodule:: wisp_mask.samples
:members:

Output summaries
================

.. automodule:: sprite_mask.summaries
.. automodule:: wisp_mask.summaries
:members: summarize_population_count_bed
20 changes: 10 additions & 10 deletions docs/arguments.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Arguments
*********

All arguments are listed below. ``sprite --help`` shows the same information.
All arguments are listed below. ``wisp --help`` shows the same information.

Commands
========

``sprite`` has two subcommands:
``wisp`` has two subcommands:

**from-alignments**
Build a population count mask from BAM/CRAM files via ``mosdepth``.
Expand All @@ -26,7 +26,7 @@ Core arguments
is supplied.

**--out PATH**
Output directory for the final ``sprite.bed.gz`` and tabix index.
Output directory for the final ``wisp.bed.gz`` and tabix index.

Input-specific arguments
========================
Expand Down Expand Up @@ -66,20 +66,20 @@ Shared optional arguments
intervals are emitted.

**--output-prefix TEXT**
Output filename stem within ``--out``. Defaults to ``sprite``,
producing ``sprite.bed.gz`` and ``sprite.bed.gz.tbi``. ``.bed.gz``
Output filename stem within ``--out``. Defaults to ``wisp``,
producing ``wisp.bed.gz`` and ``wisp.bed.gz.tbi``. ``.bed.gz``
is always appended.

**--keep-work**
Keep intermediate files in the working directory. By default, work
files are removed after a successful run.

**--force**
Overwrite existing final outputs. Without this flag, ``sprite`` refuses
to replace ``sprite.bed.gz`` or ``sprite.bed.gz.tbi``.
Overwrite existing final outputs. Without this flag, ``wisp`` refuses
to replace ``wisp.bed.gz`` or ``wisp.bed.gz.tbi``.

**--version**
Print the installed ``sprite`` version and exit.
Print the installed ``wisp`` version and exit.

**--help**
Print the full help message and exit.
Expand Down Expand Up @@ -125,7 +125,7 @@ BAM/CRAM mode:

.. code-block:: console

sprite from-alignments \
wisp from-alignments \
--samples tests/test_data/1000g_5sample_chr20_smoke/samples.tsv \
--min-dp 10 \
--variants-vcf validation/cohort.variants.vcf.gz \
Expand All @@ -140,7 +140,7 @@ All-sites VCF mode:

.. code-block:: console

sprite from-vcf \
wisp from-vcf \
--all-sites-vcf validation/cohort.all_sites.vcf.gz \
--popfile validation/sample_populations.tsv \
--min-dp 10 \
Expand Down
2 changes: 1 addition & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ Highlights:
depth/MAPQ thresholds and exclude indel, structural-variant, breakend, and
multi-nucleotide polymorphism spans.
* Build the same output from prefiltered all-sites VCF ``FORMAT/DP`` values.
* Write bgzipped and tabix-indexed ``sprite.bed.gz`` output.
* Write bgzipped and tabix-indexed ``wisp.bed.gz`` output.
* Include JSON metadata and population column headers in the output BED.
20 changes: 10 additions & 10 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
sys.path.insert(0, str(ROOT / "src"))


project = "sprite"
copyright = "2026, sprite contributors"
author = "sprite contributors"
project = "wisp"
copyright = "2026, wisp contributors"
author = "wisp contributors"

with (ROOT / "pyproject.toml").open("rb") as handle:
release = tomllib.load(handle)["project"]["version"]
Expand All @@ -42,27 +42,27 @@
html_static_path = []
html_title = f"{project} {release}"

htmlhelp_basename = "spritedoc"
htmlhelp_basename = "wispdoc"

latex_documents = [
(
master_doc,
"sprite.tex",
"sprite Documentation",
"wisp.tex",
"wisp Documentation",
author,
"manual",
),
]

man_pages = [(master_doc, "sprite", "sprite Documentation", [author], 1)]
man_pages = [(master_doc, "wisp", "wisp Documentation", [author], 1)]

texinfo_documents = [
(
master_doc,
"sprite",
"sprite Documentation",
"wisp",
"wisp Documentation",
author,
"sprite",
"wisp",
"Build sparse depth-threshold mask BEDs from cohort alignment data or all-sites VCFs.",
"Miscellaneous",
),
Expand Down
8 changes: 4 additions & 4 deletions docs/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Set up a development environment
.. code-block:: console

mamba env create -f environment.yml
conda activate sprite
conda activate wisp
python -m pip install -e ".[dev,docs]"

Run checks
Expand Down Expand Up @@ -38,15 +38,15 @@ Project layout

.. code-block:: text

src/sprite_mask/ package source
src/wisp_mask/ package source
tests/ unit and workflow tests
tests/test_data/ small 1000 Genomes fixtures and download scripts
docs/ Sphinx documentation

Implementation overview
=======================

The public CLI is defined in ``sprite_mask.cli``. Parsed arguments are converted
The public CLI is defined in ``wisp_mask.cli``. Parsed arguments are converted
to ``RunConfig`` and passed to ``run_workflow``. The workflow validates the input
mode, runs either the BAM/CRAM or VCF builder, writes ``sprite.bed.gz``,
mode, runs either the BAM/CRAM or VCF builder, writes ``wisp.bed.gz``,
and creates the tabix index.
Loading
Loading