Skip to main content

A pipeline to align, quality control, and summarize tiled amplicon coverage (of a virus, probably) from sequencing reads.

Project description

PyPI version

๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ
๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐Ÿฆ๐Ÿฆ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐Ÿฆ๐Ÿฆ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ
๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ
๐ŸŒŠ๐ŸŒŠ๐Ÿฆ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐Ÿฆ๐Ÿฆ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ
๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐ŸŒŠ๐Ÿฆ๐Ÿฆ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐Ÿฆ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ
๐ŸŒŠ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐Ÿฆ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ
๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐Ÿฆ๐ŸŒŠ
๐ŸŒŠ๐Ÿฆ๐Ÿฆ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ
๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐Ÿฆ๐Ÿฆ๐ŸŒŠ๐ŸŒŠ๐Ÿฆ๐Ÿฆ๐ŸŒŠ๐ŸŒŠ๐Ÿฆ๐Ÿฆ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ
๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐Ÿฆ๐Ÿฆ๐ŸŒŠ๐ŸŒŠ๐Ÿฆ๐Ÿฆ๐ŸŒŠ๐ŸŒŠ๐Ÿฆ๐Ÿฆ๐ŸŒŠ๐ŸŒŠ๐Ÿฆ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ๐ŸŒŠ

scampiman

A pipeline to align, quality control, and summarize tiled amplicon coverage (of a virus, probably) from sequencing reads.

Rationale: We noticed 1) that tiled amplicon data can come in many forms from many technologies, and 2) errors introduced in library prep can lead to sequencing artifacts that, if not handled properly, can cause issues with downstream analysis.

Requires: Reads, Reference Genome(s), Primer .bed File

Produces: Alignment Summary, Samtools Ampliconstats File, Table of Amplicon Coverage .tsv

  • Input formats .fastq or .bam
  • Input logic file(s) or directory (with files)
  • Seq tech illumina short read or ONT
  • Read config single-end or paired-end
  1. Align reads to reference (mappy) and filter unwanted alignments
  2. pysam: sort, ampliconclip, ampliconstats
  3. Parse ampliconstats output into table, output .tsv

Alignment Filtering

Subpar alignments are filtered out before amplicon analysis is performed. This step attempts to remove issues that may have arisen during library preparation, for either singleโ€‘ or pairedโ€‘end reads, that can cause misrepresentation of amplicon diversity.

The number of removed alignments is reported in the alignment summary as 'removed_reads_primary' and is saved within the failed.bam output along with unmapped reads.

Singleโ€‘end Reads

The filtering parameters for singleโ€‘end reads are designed to correct for ligationโ€‘based errors that may occur, particularly in ONT ligationโ€‘based sequencing kits (e.g., SQKโ€‘NBD114).

The filtering parameters are as follows:

  • Removes reads with supplementary alignments that overlap <50% with the primary alignmentโ€™s reference region.
  • Removes reads that produce supplementary alignments mapping to the same strand as the primary alignment.

Removal of these reads is important because it accounts for:

  1. ligation between amplicons originating from different regions of the genome.
  2. ligation between segments originating from different sources. For example, different barcodes of ONT kits.

Pairedโ€‘end Reads

Scampiman assumes that pairedโ€‘end reads were generated on an Illumina or similar platform.

The filtering parameters are as follows:

  • Removes paired reads that align to the same strand.
  • Removes paired reads that have unequal numbers of alignments (indicating mapping error).
  • Removes paired reads where one mate is unmapped.
  • Removes paired reads whose reference alignments do not overlap.

Removal of these reads is important because it accounts for:

  1. Illumina's platform sequencing paired reads from opposing strands of the same DNA fragment.
  2. potential ligation or mapping errors.
  3. the necessity for the entire (gap-less) amplicon to be represented in the analysis.

Install

Note: consider making an isolated environment (conda or venv) for scampiman.

Easiest Way

  1. Simply install scampiman using pip.
pip install scampiman

Alternative Methods:

  1. clone this repo or download and unpack release.

  2. pip install scampiman

From the terminal:

cd scampiman

pip install .

  • Either method should install scampiman as a runnable command from the terminal.

Running scampiman

Highly Recommended: quality filter reads before running scampiman with e.g. fastp (short reads) or fastplong (long reads)!

With a directory of unaligned .bam files from an ONT run:

scampiman -r proj1/bam_pass/barcode24 -b SARS-CoV-2.ARTIC_5.3.2.primer.bed -g sars_cov2_MN908947.3.fasta -s barcode24 -o proj1_scampi -f bam -t directory -c single-end --seqtech ont

You can also specify multiple directories:

scampiman -r flowcell1/bam_pass/barcode24 flowcell2/bam_pass/barcode24 -b SARS-CoV-2.ARTIC_5.3.2.primer.bed -g sars_cov2_MN908947.3.fasta -s barcode24 -o proj1_scampi -f bam -t directory -c single-end --seqtech ont

With some unaligned .bam files from an ONT run:

scampiman -r proj1/bam_pass/barcode24/*bam -b SARS-CoV-2.ARTIC_5.3.2.primer.bed -g sars_cov2_MN908947.3.fasta -s barcode24 -o proj1_scampi -f bam -t files -c single-end --seqtech ont

It's better to use -t directory if you are using all files in a directory.

With .fastq files:

from a paired-end Illumina run:

scampiman -r my_fastqs/seq1.R1.fastq my_fastqs/seq1.R2.fastq -b SARS-CoV-2.ARTIC_5.3.2.primer.bed -g sars_cov2_MN908947.3.fasta -s seq1 -o proj2_scampi -f fastq -t files -c paired-end --seqtech illumina

Single-end (e.g. ONT) works too:

scampiman -r my_fastqs/seq1.ONT.fastq -b SARS-CoV-2.ARTIC_5.3.2.primer.bed -g sars_cov2_MN908947.3.fasta -s seq1 -o proj2_scampi -f fastq -t files -c single-end --seqtech ont

Keeping aligned .bam files for downstream analysis:

Commonly, you will want to keep the properly filtered .bam file to run downstream analysis to determine lineage, derive consensus genome, or analyze allele frequency.

scampiman -r my_fastqs/seq1.ONT.fastq -b SARS-CoV-2.ARTIC_5.3.2.primer.bed -g sars_cov2_MN908947.3.fasta -s seq1 -o proj2_scampi -f fastq -t files -c single-end --seqtech ont --keep bam

Plotting data (not thoroughly tested/robust)

See conda environment requirements below.

This needs an index file in .xlsx format with (at least) the following header columns:

  • Barcode ID
  • Sample ID
Rscript scampiman/plot_script/plot_scampiman_batch1.R scampi_projects my_amplicons_projs1to4.pdf

terminal command to add R plotting capabilities

conda activate scampiman

conda install -c conda-forge conda-forge::r-rprojroot conda-forge::r-tidyverse conda-forge::r-cowplot conda-forge::r-readxl

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scampiman-0.1.3.tar.gz (20.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scampiman-0.1.3-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file scampiman-0.1.3.tar.gz.

File metadata

  • Download URL: scampiman-0.1.3.tar.gz
  • Upload date:
  • Size: 20.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for scampiman-0.1.3.tar.gz
Algorithm Hash digest
SHA256 77f08fe8fb154653185f76fd041ec115f3a178b70abfce5e062e7c8ec77c6785
MD5 68bcbd96bb9d4d1836d91fbc2f706f89
BLAKE2b-256 3b98c55adc29931639866c85ab08d7cd66019c9471768f9f7003e11520e13308

See more details on using hashes here.

Provenance

The following attestation bundles were made for scampiman-0.1.3.tar.gz:

Publisher: publish.yml on tiszalab/scampiman

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file scampiman-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: scampiman-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 17.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for scampiman-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1de8a6f59c7a6df54289a58d70748825622cb005feadb44a0f0a225f8c0f70f5
MD5 a9e6be655d246811b046a28c074e058e
BLAKE2b-256 6ab7c224d882c0cba659cb281f5027293b3f1af08a8bd5dfc77b19536a67b3df

See more details on using hashes here.

Provenance

The following attestation bundles were made for scampiman-0.1.3-py3-none-any.whl:

Publisher: publish.yml on tiszalab/scampiman

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page