pku-yuangroup/openai4s/bio-alignment-files-pileup-generation
Claude Code and agent skill by pku-yuangroup/openai4s
- community
Checking that the SKILL.md file is still in the repository.
Generate pileup data for variant calling using samtools mpileup and pysam. Use when preparing data for variant calling, analyzing per-position read data, or calculating allele frequencies.
Install
npx vskill@latest install pku-yuangroup/openai4s/bio-alignment-files-pileup-generationSKILL.md
The same SKILL.md was published earlier as pku-yuangroup/openai4s/bio-alignment-files-pileup-generation.
Version Compatibility
Reference examples tested with: bcftools 1.19+, pysam 0.22+, samtools 1.19+
Before using code patterns, verify installed versions match. If versions differ:
- Python:
pip show <package>thenhelp(module.function)to check signatures - CLI:
<tool> --versionthen<tool> --helpto confirm flags
If code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.
Pileup Generation
Generate pileup data for variant calling and position-level analysis.
"Generate pileup from BAM" -> Produce per-position read summaries showing depth, bases, and qualities.
- CLI:
samtools mpileup -f ref.fa input.bam - Python:
bam.pileup(chrom, start, end)(pysam)
"Count alleles at a position" -> Extract per-base read support at a specific genomic coordinate.
- Python: iterate
pileup_column.pileupsand count bases (pysam)
What is Pileup?
Pileup shows all reads covering each position in the reference, used for:
- Variant calling (with bcftools)
- Coverage analysis
- Allele frequency calculation
- SNP/indel detection
samtools mpileup vs bcftools mpileup (Deprecation)
samtools mpileup -g/-u (BCF output for variant calling) was deprecated in samtools 1.9 and removed in 1.15 (the option no longer exists; the usage/manpage directs users to bcftools mpileup) -- the genotype-likelihood code now lives in bcftools mpileup, which keeps mpileup logic versioned alongside bcftools call and avoids version-skew bugs.
| Use case | Recommended tool | |
|---|---|---|
| Quick allele counts at known sites | samtools mpileup or pysam pileup | |
| Germline variant calling (small genomes, simple cohorts) | bcftools mpileup -> bcftools call | |
| Germline WGS / WES production | DeepVariant or HaplotypeCaller (not mpileup) | |
| Somatic SNV/indel | Mutect2 / VarDict / VarScan2 (direct from BAM) | |
| Long-read small variants | clair3 / DeepVariant ONT (direct from BAM) | |
| Long-read SV | Sniffles / cuteSV (direct from BAM) | |
| Ultra-low-frequency (ctDNA / MRD) | fgbio consensus -> bcftools call or hot-spot Mutect2 | |
| Per-position allele counts (custom) | pysam pileup |
samtools mpileup (without -g) is still the standard tool for human-readable per-position read summaries.
Basic Pileup
Pileup Specific Region
Regions from BED
Multiple BAM Files
Output Format
Text pileup format (6 columns per sample):
| Column | Description | |
|---|---|---|
| 1 | Chromosome | |
| 2 | Position (1-based) | |
| 3 | Reference base | |
| 4 | Read depth | |
| 5 | Read bases | |
| 6 | Base qualities |
Read Bases Encoding
| Symbol | Meaning | |
|---|---|---|
. | Match on forward strand | |
, | Match on reverse strand | |
ACGT | Mismatch (uppercase = forward) | |
acgt | Mismatch (lowercase = reverse) | |
^Q | Start of read (Q = MAPQ as ASCII) | |
$ | End of read | |
+NNN | Insertion of N bases | |
-NNN | Deletion of N bases | |
* | Deleted base | |
> / < | Reference skip (intron) |
Quality Filtering Options
Minimum Mapping Quality
Minimum Base Quality
Combined Quality Filters
Maximum Depth (Critical Trap)
BAQ: Base Alignment Quality (Critical Default)
When -f ref.fa is passed, BAQ is enabled by default. BAQ Phred-scales the probability that a base is misaligned (HMM realignment over a small window) and reduces base quality near indels. Tradeoffs: ~30% slower; suppresses FP SNVs near indels; hurts indel detection sensitivity.
| Flag | Behavior | |
|---|---|---|
(default with -f) | BAQ on (computed from CIGAR if MD missing) | |
-B / --no-BAQ | Disable BAQ -- raw qualities | |
-E / --redo-BAQ | Force recompute (after BQSR; if MD stale) |
BAQ ON for: short-read germline SNV (BWA, Bowtie2, HISAT2), short-read somatic SNV.
BAQ OFF (`-B`) for: long-read variant calling (ONT, PacBio HiFi), SV calling, RNA-seq near splice junctions, viral / amplicon, ultra-deep ctDNA from consensus reads (consensus quality already inflated), aDNA (qualities pre-rescaled by mapDamage).
-A (count anomalous read pairs / orphans) is required for amplicon -- amplicon reads are by design not properly paired.
-aa (output all positions, including zero-coverage) is required for ARTIC SARS-CoV-2 consensus generation.
Library-Typed Flags Cheat Sheet
| Library | Flags | |
|---|---|---|
| Short-read germline WGS (BWA) | -q 20 -Q 20 -d 0 (BAQ on default) | |
| Short-read tumor WGS | -q 1 -Q 13 -d 0 -B (low MAPQ kept; BAQ off) | |
| Amplicon viral (ARTIC) | -aa -A -d 600000 -B -Q 20 | |
| Capture / exome | -q 20 -Q 20 -d 250 | |
| Long-read ONT R10.4+ | -q 30 -Q 0 -B -d 0; for bcftools mpileup add --max-BQ 30 (its ont preset value) | |
| PacBio HiFi | -q 20 -Q 0 -B -d 0 | |
| RNA-seq variants | -q 20 -Q 20 -B -d 0 | |
| Forensic / aDNA | -q 0 -Q 0 -A -d 0 -B |
Variant Calling Pipeline (Modern: bcftools mpileup)
Goal: Call variants from alignment data using the pileup-based approach.
Approach: Use bcftools mpileup (not samtools mpileup -g) so genotype-likelihood code is co-versioned with bcftools call. Apply quality and depth caps explicitly; annotate FORMAT fields needed for downstream filtering.
Modern Germline Calling
Multi-Sample Joint Calling
For somatic / low-VAF, prefer Mutect2 / Strelka2 / DeepVariant -- materially better than mpileup-based callers.
Overlap Detection Defaults
When fragment length < 2 * read_length, R1 and R2 overlap. Both samtools mpileup and bcftools mpileup enable overlap detection by default (per samtools-mpileup(1)) and count overlapping bases once; pass -x to disable (long form is --disable-overlap-removal in samtools since 1.16, but --ignore-overlaps in bcftools). Disabling overlap correction can inflate somatic VAFs at sites covered by overlapping pairs (especially in cfDNA / FFPE).
pysam Python Alternative
Basic Pileup
Access Reads at Position
Count Alleles at Position
Calculate Allele Frequency
Pileup with Quality Filtering
Generate Pileup Text
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/bioskills/bio-alignment-files-pileup-generation/SKILL.md
Popularity
- 7-day trend score
- 5
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Grok Build (Cursor)
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/pku-yuangroup/openai4s/bio-alignment-files-pileup-generation)