Inferensys

Glossary

Pileup Image Encoding

A technique that transforms a vertical stack of aligned sequencing reads at a candidate genomic locus into a multi-channel image where pixel intensities represent base identities, quality scores, and strand information for input into a convolutional neural network.
Developer demonstrating multi-agent tool use, agent tool selection interface on laptop, casual tech demo moment.
VARIANT CALLING PREPROCESSING

What is Pileup Image Encoding?

Pileup image encoding is a data transformation technique that converts the vertical stack of aligned sequencing reads at a candidate genomic locus into a multi-channel image, enabling convolutional neural networks to perform variant calling as a visual classification task.

Pileup image encoding is the process of rendering aligned reads, reference bases, and associated quality metrics into a structured, tensor-like representation where each pixel column corresponds to a genomic position and each row to a read. The red, green, and blue channels are explicitly assigned to encode distinct biological data types—typically the reference base, the alternate allele, and strand or mapping quality information—creating a rich, multi-dimensional feature map for deep learning models.

This encoding strategy, pioneered by DeepVariant, reframes variant calling from a statistical inference problem into an image classification task. By preserving the spatial relationships between reads and the reference genome, the pileup image allows a convolutional neural network to learn complex visual features such as strand bias artifacts, homopolymer indel errors, and mapping quality drop-offs directly from the raw alignment data without relying on hand-crafted statistical filters.

MECHANISM

Key Features of Pileup Image Encoding

Pileup image encoding transforms raw sequence alignment data into a structured visual representation, enabling convolutional neural networks to perform variant calling as an image classification task.

01

Multi-Channel RGB Representation

The core innovation is mapping biological data to standard image channels. Each pixel column represents a genomic position, and each row is a read. The red channel encodes the reference base and reads matching it. The green channel encodes reads with the alternate allele. The blue channel encodes base quality scores. An additional alpha channel often represents strand orientation (forward vs. reverse). This allows a CNN to learn spatial features like strand bias artifacts directly from the pixel patterns.

02

Candidate Locus Windowing

Encoding does not occur genome-wide. A candidate variant locus is first identified by a traditional caller or heuristic. A fixed-size window (e.g., 221x100 pixels for DeepVariant) is centered on the candidate site. This window captures the local alignment context, including flanking reference sequence and nearby reads that may span the variant. The fixed dimensions ensure a consistent input tensor size for the neural network, regardless of the actual depth of coverage at the locus.

03

Read Realignment and Haplotype Sorting

Before pixel generation, reads overlapping the candidate window are locally realigned to the reference using algorithms like Smith-Waterman. This corrects for alignment artifacts near indels. Reads are then sorted by haplotype or alignment score to create a consistent vertical ordering. This sorting is critical: it transforms an unordered set of reads into a spatially coherent image where the CNN can learn vertical patterns associated with heterozygous alleles or mapping errors.

04

Quality Score Encoding in Pixel Intensity

Base quality scores (Phred scale) are not discarded but embedded directly into pixel intensity. A high-quality base matching the reference produces a bright pixel in the red channel. A low-quality base produces a dim pixel. This allows the CNN to learn to down-weight noisy signals automatically. The model learns to distinguish a true variant supported by high-quality mismatches from a sequencing error supported by low-quality mismatches, all from the visual pattern of pixel brightness.

05

Strand-Specific Channel Encoding

To detect strand bias artifacts, the encoding separates reads by strand. Forward-strand reads and reverse-strand reads are often placed in distinct rows or encoded with different alpha values. A true heterozygous variant should show the alternate allele on both strands. If the green channel signal appears only in the forward-strand rows, the CNN learns to recognize this as a systematic artifact, likely from oxidative damage during library preparation, and will down-weight the variant call.

06

Reference Sequence as Visual Anchor

The reference genome sequence is always included as the top row of the pileup image, providing a visual anchor for the CNN. This row is encoded in the red channel. The model learns to compare each read row against this reference row to identify mismatches. This explicit representation of the reference eliminates the need for the model to infer the expected base from the read pileup, simplifying the learning task and improving accuracy at repetitive loci.

PILEUP IMAGE ENCODING

Frequently Asked Questions

Clear, technically precise answers to the most common questions about converting aligned sequencing reads into image-based representations for deep learning variant callers.

Pileup image encoding is the process of converting a vertical stack of aligned sequencing reads at a candidate genomic locus into a multi-channel red-green-blue (RGB) image where each channel encodes distinct biological and technical information. The reference genome and all reads overlapping a target position are aligned, and for each pixel row (representing a single read) and column (representing a genomic offset), the red channel encodes the base identity (A, C, G, T), the green channel encodes the per-base quality score, and the blue channel encodes strand orientation and other auxiliary signals. This transformation recasts the statistical variant calling problem into a visual classification task solvable by convolutional neural networks like DeepVariant, which learn to recognize patterns of true variants versus sequencing artifacts directly from the image texture.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.