polars-bio

Perform genomic interval operations and bioinformatics file I/O on Polars DataFrames.

46.6k|4.2k|Updated Oct 19, 2025
One-click install
npx skills add https://github.com/K-Dense-AI/claude-scientific-skills --skill polars-bio-k-dense-ai
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: polars-bio
Source: https://github.com/K-Dense-AI/claude-scientific-skills/tree/main/skills/polars-bio
Command: npx skills add https://github.com/K-Dense-AI/claude-scientific-skills --skill polars-bio-k-dense-ai

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires polars-bio, polars, and includes references (resource) components.

What problem does it solve? Genomic interval analysis with tools like bioframe is slow and memory-bound on large datasets. This Skill provides high-performance interval arithmetic (overlap, nearest, merge, coverage, complement, subtract) and file I/O for BED, VCF, BAM, CRAM, GFF/GTF, FASTA, and FASTQ, with streaming execution and cloud-native reads from S3, GCS, and Azure. ## Core Features & Use Cases - Interval Operations: Run overlap, nearest, merge, cluster, coverage, complement, and subtract on Polars DataFrames with chrom/start/end columns, returning LazyFrames for out-of-core processing. - Bioinformatics File I/O: Read, scan, write, and sink BED, VCF, BAM, CRAM, GFF, GTF, FASTA, FASTQ, SAM, and Hi-C pairs files, including BGZF-compressed and cloud-hosted files. - SQL and Pileup: Register genomic files as DataFusion SQL tables and compute CIGAR-aware per-base read depth from BAM/CRAM alignments. - Use Case: Overlap millions of ChIP-seq peaks against gene annotations by scanning BED files lazily, running pb.overlap with parallel partitions, and collecting results with the streaming engine without loading everything into RAM. ## Quick Start Ask the AI to install polars-bio and find overlapping intervals between two BED files using pb.scan_bed and pb.overlap, then collect the result as a Polars DataFrame.

Frequently Asked Questions about polars-bio

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I find overlapping genomic intervals in Python?▼

Use pb.overlap(df1, df2) from polars-bio on Polars DataFrames with chrom, start, and end columns. It returns a LazyFrame by default, so call .collect() or pass output_type="polars.DataFrame" to materialize results.

polars-bio vs bioframe for genomic interval operations?▼

polars-bio is a drop-in replacement for bioframe's core operations, delivering 6.5-38x speedups via a Rust and DataFusion backend. It uses Polars instead of pandas, returns LazyFrames by default, and adds streaming support for datasets larger than RAM.

Does polars-bio support reading VCF and BAM files from S3?▼

Yes, read_* and scan_* functions accept s3://, gs://, and az:// URIs directly with parameters like allow_anonymous, max_retries, and timeout. Authentication uses standard cloud SDK environment variables only when cloud paths are accessed.

Why does polars-bio return a LazyFrame instead of a DataFrame?▼

All interval operations and pb.sql() return LazyFrames by default to enable lazy evaluation and streaming execution. Call .collect() to materialize results, or pass output_type="polars.DataFrame" for eager evaluation.

How do I compute read depth from a BAM file in Python?▼

Use pb.depth("aligned.bam") for CIGAR-aware per-block read depth, or set per_base=True for per-position output. You can filter reads with min_mapping_quality and filter_flag parameters, then collect the LazyFrame result.

What are the limitations of polars-bio for genomic analysis?▼

Genomic positions are stored as 32-bit integers, limiting coordinates to about 2.1 billion. BAM reading requires a .bai index, CRAM needs a reference FASTA, and parallelism defaults to one partition unless configured via set_option.