[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6J9WABB0ND4ZT718KADGAKZ":3,"skill-same:01M6J9WABB0ND4ZT718KADGAKZ":76},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":41,"linkOnly":42,"markdownContent":43,"markdownBody":44,"frontMatter":45,"refName":55,"commitSha":56,"skillDirectory":57,"forksCount":49,"repositoryHtmlUrl":58,"repositoryHomepageUrl":6,"ownerHtmlUrl":59,"ownerBlogUrl":60,"ownerDescription":61,"updatedAt":62,"install":63,"resources":75},"01M6J9WABB0ND4ZT718KADGAKZ","science-polars-bio",null,"High-performance genomic interval operations and bioinformatics file I\u002FO on Polars DataFrames. Overlap, nearest, merge, coverage, complement, subtract for BED\u002FVCF\u002FBAM\u002FGFF intervals. Streaming, cloud-native, faster bioframe alternative.","Flissel\u002Fvibemind-os","Flissel","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F104565236?v=4","01M6J8Q88NWAJGKPC5TEG9YCNV","Felix Baumann","01M6J8Q8D7XAFY44P70XTJFZBW",1,"MIT","https:\u002F\u002Fgithub.com\u002FFlissel\u002Fvibemind-os\u002Fblob\u002Fmaster\u002Fskills\u002Fscience\u002Fpolars-bio\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40],"polars","science polars","science polars bio","science","polars bio","bed","2026","source","for","true","native","high-performance","vcf","performance","dataframes","imported","cloud-native","coverage","repo","file","streaming","merge","2026-11-10 10:12:30",false,"---\nname: science-polars-bio\ndescription: High-performance genomic interval operations and bioinformatics file\n  I\u002FO on Polars DataFrames. Overlap, nearest, merge, coverage, complement, subtract\n  for BED\u002FVCF\u002FBAM\u002FGFF intervals. Streaming, cloud-native, faster bioframe alternative.\napp: science\nrequires_approval: true\nagents:\n- '*'\ninputs: []\nexpected_state:\n  description: Imported skill — behavior matches source repo\n  verification_tool: none\nconfidence: 1.0\nattempts: 0\nsuccesses: 0\nlast_adjusted: '2026-05-11T21:21:44+00:00'\n---\n\n# polars-bio\n\n## Overview\n\npolars-bio is a high-performance Python library for genomic interval operations and bioinformatics file I\u002FO, built on Polars, Apache Arrow, and Apache DataFusion. It provides a familiar DataFrame-centric API for interval arithmetic (overlap, nearest, merge, coverage, complement, subtract) and reading\u002Fwriting common bioinformatics formats (BED, VCF, BAM, CRAM, GFF\u002FGTF, FASTA, FASTQ).\n\nKey value propositions:\n- **6-38x faster** than bioframe on real-world genomic benchmarks\n- **Streaming\u002Fout-of-core** support for large genomes via DataFusion\n- **Cloud-native** file I\u002FO (S3, GCS, Azure) with predicate pushdown\n- **Two API styles**: functional (`pb.overlap(df1, df2)`) and method-chaining (`df1.lazy().pb.overlap(df2)`)\n- **SQL interface** for genomic data via DataFusion SQL engine\n\n## When to Use This Skill\n\nUse this skill when:\n- Performing genomic interval operations (overlap, nearest, merge, coverage, complement, subtract)\n- Reading\u002Fwriting bioinformatics file formats (BED, VCF, BAM, CRAM, GFF\u002FGTF, FASTA, FASTQ)\n- Processing large genomic datasets that don't fit in memory (streaming mode)\n- Running SQL queries on genomic data files\n- Migrating from bioframe to a faster alternative\n- Computing read depth\u002Fpileup from BAM\u002FCRAM files\n- Working with Polars DataFrames containing genomic intervals\n\n## Quick Start\n\n### Installation\n\n```bash\npip install polars-bio\n# or\nuv pip install polars-bio\n```\n\nFor pandas compatibility:\n```bash\npip install polars-bio[pandas]\n```\n\n### Basic Overlap Example\n\n```python\nimport polars as pl\nimport polars_bio as pb\n\n# Create two interval DataFrames\ndf1 = pl.DataFrame({\n    \"chrom\": [\"chr1\", \"chr1\", \"chr1\"],\n    \"start\": [1, 5, 22],\n    \"end\":   [6, 9, 30],\n})\n\ndf2 = pl.DataFrame({\n    \"chrom\": [\"chr1\", \"chr1\"],\n    \"start\": [3, 25],\n    \"end\":   [8, 28],\n})\n\n# Functional API (returns LazyFrame by default)\nresult = pb.overlap(df1, df2)\nresult_df = result.collect()\n\n# Get a DataFrame directly\nresult_df = pb.overlap(df1, df2, output_type=\"polars.DataFrame\")\n\n# Method-chaining API (via .pb accessor on LazyFrame)\nresult = df1.lazy().pb.overlap(df2)\nresult_df = result.collect()\n```\n\n### Reading a BED File\n\n```python\nimport polars_bio as pb\n\n# Eager read (loads entire file)\ndf = pb.read_bed(\"regions.bed\")\n\n# Lazy scan (streaming, for large files)\nlf = pb.scan_bed(\"regions.bed\")\nresult = lf.collect()\n```\n\n## Core Capabilities\n\n### 1. Genomic Interval Operations\n\npolars-bio provides 8 core interval operations for genomic range arithmetic. All operations accept Polars DataFrames with `chrom`, `start`, `end` columns (configurable). All operations return a `LazyFrame` by default (use `output_type=\"polars.DataFrame\"` for eager results).\n\n**Operations:**\n- `overlap` \u002F `count_overlaps` - Find or count overlapping intervals between two sets\n- `nearest` - Find nearest intervals (with configurable `k`, `overlap`, `distance` params)\n- `merge` - Merge overlapping\u002Fbookended intervals within a set\n- `cluster` - Assign cluster IDs to overlapping intervals\n- `coverage` - Compute per-interval coverage counts (two-input operation)\n- `complement` - Find gaps between intervals within a genome\n- `subtract` - Remove portions of intervals that overlap another set\n\n**Example:**\n```python\nimport polars_bio as pb\n\n# Find overlapping intervals (returns LazyFrame)\nresult = pb.overlap(df1, df2, suffixes=(\"_1\", \"_2\"))\n\n# Count overlaps per interval\ncounts = pb.count_overlaps(df1, df2)\n\n# Merge overlapping intervals\nmerged = pb.merge(df1)\n\n# Find nearest intervals\nnearest = pb.nearest(df1, df2)\n\n# Collect any LazyFrame result to DataFrame\nresult_df = result.collect()\n```\n\n**Reference:** See `references\u002Finterval_operations.md` for detailed documentation on all operations, parameters, output schemas, and performance considerations.\n\n### 2. Bioinformatics File I\u002FO\n\nRead and write common bioinformatics formats with `read_*`, `scan_*`, `write_*`, and `sink_*` functions. Supports cloud storage (S3, GCS, Azure) and compression (GZIP, BGZF).\n\n**Supported formats:**\n- **BED** - Genomic intervals (`read_bed`, `scan_bed`, `write_*` via generic)\n- **VCF** - Genetic variants (`read_vcf`, `scan_vcf`, `write_vcf`, `sink_vcf`)\n- **BAM** - Aligned reads (`read_bam`, `scan_bam`, `write_bam`, `sink_bam`)\n- **CRAM** - Compressed alignments (`read_cram`, `scan_cram`, `write_cram`, `sink_cram`)\n- **GFF** - Gene annotations (`read_gff`, `scan_gff`)\n- **GTF** - Gene annotations (`read_gtf`, `scan_gtf`)\n- **FASTA** - Reference sequences (`read_fasta`, `scan_fasta`)\n- **FASTQ** - Sequencing reads (`read_fastq`, `scan_fastq`, `write_fastq`, `sink_fastq`)\n- **SAM** - Text alignments (`read_sam`, `scan_sam`, `write_sam`, `sink_sam`)\n- **Hi-C pairs** - Chromatin contacts (`read_pairs`, `scan_pairs`)\n\n**Example:**\n```python\nimport polars_bio as pb\n\n# Read VCF file\nvariants = pb.read_vcf(\"samples.vcf.gz\")\n\n# Lazy scan BAM file (streaming)\nalignments = pb.scan_bam(\"aligned.bam\")\n\n# Read GFF annotations\ngenes = pb.read_gff(\"annotations.gff3\")\n\n# Cloud storage (individual params, not a dict)\ndf = pb.read_bed(\"s3:\u002F\u002Fbucket\u002Fregions.bed\",\n                 allow_anonymous=True)\n```\n\n**Reference:** See `references\u002Ffile_io.md` for per-format column schemas, parameters, cloud storage options, and compression support.\n\n### 3. SQL Data Processing\n\nRegister bioinformatics files as tables and query them using DataFusion SQL. Combines the power of SQL with polars-bio's genomic-aware readers.\n\n```python\nimport polars as pl\nimport polars_bio as pb\n\n# Register files as SQL tables (path first, name= keyword)\npb.register_vcf(\"samples.vcf.gz\", name=\"variants\")\npb.register_bed(\"target_regions.bed\", name=\"regions\")\n\n# Query with SQL (returns LazyFrame)\nresult = pb.sql(\"SELECT chrom, start, end, ref, alt FROM variants WHERE qual > 30\")\nresult_df = result.collect()\n\n# Register a Polars DataFrame as a SQL table\npb.from_polars(\"my_intervals\", df)\nresult = pb.sql(\"SELECT * FROM my_intervals WHERE chrom = 'chr1'\").collect()\n```\n\n**Reference:** See `references\u002Fsql_processing.md` for register functions, SQL syntax, and examples.\n\n### 4. Pileup Operations\n\nCompute per-base read depth from BAM\u002FCRAM files with CIGAR-aware depth calculation.\n\n```python\nimport polars_bio as pb\n\n# Compute depth across a BAM file\ndepth_lf = pb.depth(\"aligned.bam\")\ndepth_df = depth_lf.collect()\n\n# With quality filter\ndepth_lf = pb.depth(\"aligned.bam\", min_mapping_quality=20)\n```\n\n**Reference:** See `references\u002Fpileup_operations.md` for parameters and integration patterns.\n\n## Key Concepts\n\n### Coordinate Systems\n\npolars-bio defaults to **1-based** coordinates (genomic convention). This can be changed globally:\n\n```python\nimport polars_bio as pb\n\n# Switch to 0-based coordinates\npb.set_option(\"coordinate_system\", \"0-based\")\n\n# Switch back to 1-based (default)\npb.set_option(\"coordinate_system\", \"1-based\")\n```\n\nI\u002FO functions also accept `use_zero_based` to set coordinate metadata on the resulting DataFrame:\n\n```python\n# Read BED with explicit 0-based metadata\ndf = pb.read_bed(\"regions.bed\", use_zero_based=True)\n```\n\n**Important:** BED files are always 0-based half-open in the file format. polars-bio handles the conversion automatically when reading BED files. Coordinate metadata is attached to DataFrames by I\u002FO functions and propagated through operations.\n\n### Two API Styles\n\n**Functional API** - standalone functions, explicit inputs:\n```python\nresult = pb.overlap(df1, df2, suffixes=(\"_1\", \"_2\"))\nmerged = pb.merge(df)\n```\n\n**Method-chaining API** - via `.pb` accessor on **LazyFrames** (not DataFrames):\n```python\nresult = df1.lazy().pb.overlap(df2)\nmerged = df.lazy().pb.merge()\n```\n\n**Important:** The `.pb` accessor for interval operations is only available on `LazyFrame`. On `DataFrame`, `.pb` provides write operations only (`write_bam`, `write_vcf`, etc.).\n\nMethod-chaining enables fluent pipelines:\n```python\n# Chain interval operations (note: overlap outputs suffixed columns,\n# so rename before merge which expects chrom\u002Fstart\u002Fend)\nresult = (\n    df1.lazy()\n    .pb.overlap(df2)\n    .filter(pl.col(\"start_2\") > 1000)\n    .select(\n        pl.col(\"chrom_1\").alias(\"chrom\"),\n        pl.col(\"start_1\").alias(\"start\"),\n        pl.col(\"end_1\").alias(\"end\"),\n    )\n    .pb.merge()\n    .collect()\n)\n```\n\n### Probe-Build Architecture\n\nFor two-input operations (overlap, nearest, count_overlaps, coverage), polars-bio uses a probe-build join strategy:\n- The **first** DataFrame is the **probe** (iterated over)\n- The **second** DataFrame is the **build** (indexed for lookup)\n\nFor best performance, pass the larger DataFrame as the first argument (probe) and the smaller one as the second (build).\n\n### Column Conventions\n\nBy default, polars-bio expects columns named `chrom`, `start`, `end`. Custom column names can be specified via lists:\n\n```python\nresult = pb.overlap(\n    df1, df2,\n    cols1=[\"chromosome\", \"begin\", \"finish\"],\n    cols2=[\"chr\", \"pos_start\", \"pos_end\"],\n)\n```\n\n### Return Types and Collecting Results\n\nAll interval operations and `pb.sql()` return a **LazyFrame** by default. Use `.collect()` to materialize results, or pass `output_type=\"polars.DataFrame\"` for eager evaluation:\n\n```python\n# Lazy (default) - collect when needed\nresult_lf = pb.overlap(df1, df2)\nresult_df = result_lf.collect()\n\n# Eager - get DataFrame directly\nresult_df = pb.overlap(df1, df2, output_type=\"polars.DataFrame\")\n```\n\n### Streaming and Out-of-Core Processing\n\nFor datasets larger than available RAM, use `scan_*` functions and streaming execution:\n\n```python\n# Scan files lazily\nlf = pb.scan_bed(\"large_intervals.bed\")\n\n# Process with streaming\nresult = lf.collect(streaming=True)\n```\n\nDataFusion streaming is enabled by default for interval operations, processing data in batches without loading the full dataset into memory.\n\n## Common Pitfalls\n\n1. **`.pb` accessor on DataFrame vs LazyFrame:** Interval operations (overlap, merge, etc.) are only on `LazyFrame.pb`. `DataFrame.pb` only has write methods. Use `.lazy()` to convert before chaining interval ops.\n\n2. **LazyFrame returns:** All interval operations and `pb.sql()` return `LazyFrame` by default. Don't forget `.collect()` or use `output_type=\"polars.DataFrame\"`.\n\n3. **Column name mismatches:** polars-bio expects `chrom`, `start`, `end` by default. Use `cols1`\u002F`cols2` parameters (as lists) if your columns have different names.\n\n4. **Coordinate system metadata:** When constructing DataFrames manually (not via `read_*`\u002F`scan_*`), polars-bio warns about missing coordinate metadata. Use `pb.set_option(\"coordinate_system\", \"0-based\")` globally, or use I\u002FO functions that set metadata automatically.\n\n5. **Probe-build order matters:** For overlap, nearest, and coverage, the first DataFrame is probed against the second. Swapping arguments changes which intervals appear in the left vs right output columns, and can affect performance.\n\n6. **INT32 position limit:** Genomic positions are stored as 32-bit integers, limiting coordinates to ~2.1 billion. This is sufficient for all known genomes but may be an issue with custom coordinate spaces.\n\n7. **BAM index requirements:** `read_bam` and `scan_bam` require a `.bai` index file alongside the BAM. Create one with `samtools index` if missing.\n\n8. **Parallel execution disabled by default:** DataFusion parallelism defaults to 1 partition. Enable for large datasets:\n   ```python\n   pb.set_option(\"datafusion.execution.target_partitions\", 8)\n   ```\n\n9. **CRAM has separate functions:** Use `read_cram`\u002F`scan_cram`\u002F`register_cram` for CRAM files (not `read_bam`). CRAM functions require a `reference_path` parameter.\n\n## Best Practices\n\n1. **Use `scan_*` for large files:** Prefer `scan_bed`, `scan_vcf`, etc. over `read_*` for files larger than available RAM. Scan functions enable streaming and predicate pushdown.\n\n2. **Configure parallelism for large datasets:**\n   ```python\n   import os\n   pb.set_option(\"datafusion.execution.target_partitions\", os.cpu_count())\n   ```\n\n3. **Use BGZF compression:** BGZF-compressed files (`.bed.gz`, `.vcf.gz`) support parallel block decompression, significantly faster than plain GZIP.\n\n4. **Select columns early:** When only specific columns are needed, select them early to reduce memory usage:\n   ```python\n   df = pb.read_vcf(\"large.vcf.gz\").select(\"chrom\", \"start\", \"end\", \"ref\", \"alt\")\n   ```\n\n5. **Use cloud paths directly:** Pass S3\u002FGCS\u002FAzure URIs directly to read\u002Fscan functions instead of downloading files first:\n   ```python\n   df = pb.read_bed(\"s3:\u002F\u002Fmy-bucket\u002Fregions.bed\", allow_anonymous=True)\n   ```\n\n6. **Prefer functional API for single operations, method-chaining for pipelines:** Use `pb.overlap()` for one-off operations and `.lazy().pb.overlap()` when building multi-step pipelines.\n\n## Resources\n\n### references\u002F\n\nDetailed documentation for each major capability:\n\n- **interval_operations.md** - All 8 interval operations with parameters, examples, output schemas, and performance tips. Core reference for genomic range arithmetic.\n\n- **file_io.md** - Supported formats table, per-format column schemas, cloud storage configuration, compression support, and common parameters.\n\n- **sql_processing.md** - Register functions, DataFusion SQL syntax, combining SQL with interval operations, and example queries.\n\n- **pileup_operations.md** - Per-base read depth computation from BAM\u002FCRAM files, parameters, and integration with interval operations.\n\n- **configuration.md** - Global settings (parallelism, coordinate systems, streaming modes), logging, and metadata management.\n\n- **bioframe_migration.md** - Operation mapping table, API differences, performance comparison, migration code examples, and pandas compatibility mode.\n","# polars-bio\n\n## Overview\n\npolars-bio is a high-performance Python library for genomic interval operations and bioinformatics file I\u002FO, built on Polars, Apache Arrow, and Apache DataFusion. It provides a familiar DataFrame-centric API for interval arithmetic (overlap, nearest, merge, coverage, complement, subtract) and reading\u002Fwriting common bioinformatics formats (BED, VCF, BAM, CRAM, GFF\u002FGTF, FASTA, FASTQ).\n\nKey value propositions:\n- **6-38x faster** than bioframe on real-world genomic benchmarks\n- **Streaming\u002Fout-of-core** support for large genomes via DataFusion\n- **Cloud-native** file I\u002FO (S3, GCS, Azure) with predicate pushdown\n- **Two API styles**: functional (`pb.overlap(df1, df2)`) and method-chaining (`df1.lazy().pb.overlap(df2)`)\n- **SQL interface** for genomic data via DataFusion SQL engine\n\n## When to Use This Skill\n\nUse this skill when:\n- Performing genomic interval operations (overlap, nearest, merge, coverage, complement, subtract)\n- Reading\u002Fwriting bioinformatics file formats (BED, VCF, BAM, CRAM, GFF\u002FGTF, FASTA, FASTQ)\n- Processing large genomic datasets that don't fit in memory (streaming mode)\n- Running SQL queries on genomic data files\n- Migrating from bioframe to a faster alternative\n- Computing read depth\u002Fpileup from BAM\u002FCRAM files\n- Working with Polars DataFrames containing genomic intervals\n\n## Quick Start\n\n### Installation\n\n```bash\npip install polars-bio\n# or\nuv pip install polars-bio\n```\n\nFor pandas compatibility:\n```bash\npip install polars-bio[pandas]\n```\n\n### Basic Overlap Example\n\n```python\nimport polars as pl\nimport polars_bio as pb\n\n# Create two interval DataFrames\ndf1 = pl.DataFrame({\n    \"chrom\": [\"chr1\", \"chr1\", \"chr1\"],\n    \"start\": [1, 5, 22],\n    \"end\":   [6, 9, 30],\n})\n\ndf2 = pl.DataFrame({\n    \"chrom\": [\"chr1\", \"chr1\"],\n    \"start\": [3, 25],\n    \"end\":   [8, 28],\n})\n\n# Functional API (returns LazyFrame by default)\nresult = pb.overlap(df1, df2)\nresult_df = result.collect()\n\n# Get a DataFrame directly\nresult_df = pb.overlap(df1, df2, output_type=\"polars.DataFrame\")\n\n# Method-chaining API (via .pb accessor on LazyFrame)\nresult = df1.lazy().pb.overlap(df2)\nresult_df = result.collect()\n```\n\n### Reading a BED File\n\n```python\nimport polars_bio as pb\n\n# Eager read (loads entire file)\ndf = pb.read_bed(\"regions.bed\")\n\n# Lazy scan (streaming, for large files)\nlf = pb.scan_bed(\"regions.bed\")\nresult = lf.collect()\n```\n\n## Core Capabilities\n\n### 1. Genomic Interval Operations\n\npolars-bio provides 8 core interval operations for genomic range arithmetic. All operations accept Polars DataFrames with `chrom`, `start`, `end` columns (configurable). All operations return a `LazyFrame` by default (use `output_type=\"polars.DataFrame\"` for eager results).\n\n**Operations:**\n- `overlap` \u002F `count_overlaps` - Find or count overlapping intervals between two sets\n- `nearest` - Find nearest intervals (with configurable `k`, `overlap`, `distance` params)\n- `merge` - Merge overlapping\u002Fbookended intervals within a set\n- `cluster` - Assign cluster IDs to overlapping intervals\n- `coverage` - Compute per-interval coverage counts (two-input operation)\n- `complement` - Find gaps between intervals within a genome\n- `subtract` - Remove portions of intervals that overlap another set\n\n**Example:**\n```python\nimport polars_bio as pb\n\n# Find overlapping intervals (returns LazyFrame)\nresult = pb.overlap(df1, df2, suffixes=(\"_1\", \"_2\"))\n\n# Count overlaps per interval\ncounts = pb.count_overlaps(df1, df2)\n\n# Merge overlapping intervals\nmerged = pb.merge(df1)\n\n# Find nearest intervals\nnearest = pb.nearest(df1, df2)\n\n# Collect any LazyFrame result to DataFrame\nresult_df = result.collect()\n```\n\n**Reference:** See `references\u002Finterval_operations.md` for detailed documentation on all operations, parameters, output schemas, and performance considerations.\n\n### 2. Bioinformatics File I\u002FO\n\nRead and write common bioinformatics formats with `read_*`, `scan_*`, `write_*`, and `sink_*` functions. Supports cloud storage (S3, GCS, Azure) and compression (GZIP, BGZF).\n\n**Supported formats:**\n- **BED** - Genomic intervals (`read_bed`, `scan_bed`, `write_*` via generic)\n- **VCF** - Genetic variants (`read_vcf`, `scan_vcf`, `write_vcf`, `sink_vcf`)\n- **BAM** - Aligned reads (`read_bam`, `scan_bam`, `write_bam`, `sink_bam`)\n- **CRAM** - Compressed alignments (`read_cram`, `scan_cram`, `write_cram`, `sink_cram`)\n- **GFF** - Gene annotations (`read_gff`, `scan_gff`)\n- **GTF** - Gene annotations (`read_gtf`, `scan_gtf`)\n- **FASTA** - Reference sequences (`read_fasta`, `scan_fasta`)\n- **FASTQ** - Sequencing reads (`read_fastq`, `scan_fastq`, `write_fastq`, `sink_fastq`)\n- **SAM** - Text alignments (`read_sam`, `scan_sam`, `write_sam`, `sink_sam`)\n- **Hi-C pairs** - Chromatin contacts (`read_pairs`, `scan_pairs`)\n\n**Example:**\n```python\nimport polars_bio as pb\n\n# Read VCF file\nvariants = pb.read_vcf(\"samples.vcf.gz\")\n\n# Lazy scan BAM file (streaming)\nalignments = pb.scan_bam(\"aligned.bam\")\n\n# Read GFF annotations\ngenes = pb.read_gff(\"annotations.gff3\")\n\n# Cloud storage (individual params, not a dict)\ndf = pb.read_bed(\"s3:\u002F\u002Fbucket\u002Fregions.bed\",\n                 allow_anonymous=True)\n```\n\n**Reference:** See `references\u002Ffile_io.md` for per-format column schemas, parameters, cloud storage options, and compression support.\n\n### 3. SQL Data Processing\n\nRegister bioinformatics files as tables and query them using DataFusion SQL. Combines the power of SQL with polars-bio's genomic-aware readers.\n\n```python\nimport polars as pl\nimport polars_bio as pb\n\n# Register files as SQL tables (path first, name= keyword)\npb.register_vcf(\"samples.vcf.gz\", name=\"variants\")\npb.register_bed(\"target_regions.bed\", name=\"regions\")\n\n# Query with SQL (returns LazyFrame)\nresult = pb.sql(\"SELECT chrom, start, end, ref, alt FROM variants WHERE qual > 30\")\nresult_df = result.collect()\n\n# Register a Polars DataFrame as a SQL table\npb.from_polars(\"my_intervals\", df)\nresult = pb.sql(\"SELECT * FROM my_intervals WHERE chrom = 'chr1'\").collect()\n```\n\n**Reference:** See `references\u002Fsql_processing.md` for register functions, SQL syntax, and examples.\n\n### 4. Pileup Operations\n\nCompute per-base read depth from BAM\u002FCRAM files with CIGAR-aware depth calculation.\n\n```python\nimport polars_bio as pb\n\n# Compute depth across a BAM file\ndepth_lf = pb.depth(\"aligned.bam\")\ndepth_df = depth_lf.collect()\n\n# With quality filter\ndepth_lf = pb.depth(\"aligned.bam\", min_mapping_quality=20)\n```\n\n**Reference:** See `references\u002Fpileup_operations.md` for parameters and integration patterns.\n\n## Key Concepts\n\n### Coordinate Systems\n\npolars-bio defaults to **1-based** coordinates (genomic convention). This can be changed globally:\n\n```python\nimport polars_bio as pb\n\n# Switch to 0-based coordinates\npb.set_option(\"coordinate_system\", \"0-based\")\n\n# Switch back to 1-based (default)\npb.set_option(\"coordinate_system\", \"1-based\")\n```\n\nI\u002FO functions also accept `use_zero_based` to set coordinate metadata on the resulting DataFrame:\n\n```python\n# Read BED with explicit 0-based metadata\ndf = pb.read_bed(\"regions.bed\", use_zero_based=True)\n```\n\n**Important:** BED files are always 0-based half-open in the file format. polars-bio handles the conversion automatically when reading BED files. Coordinate metadata is attached to DataFrames by I\u002FO functions and propagated through operations.\n\n### Two API Styles\n\n**Functional API** - standalone functions, explicit inputs:\n```python\nresult = pb.overlap(df1, df2, suffixes=(\"_1\", \"_2\"))\nmerged = pb.merge(df)\n```\n\n**Method-chaining API** - via `.pb` accessor on **LazyFrames** (not DataFrames):\n```python\nresult = df1.lazy().pb.overlap(df2)\nmerged = df.lazy().pb.merge()\n```\n\n**Important:** The `.pb` accessor for interval operations is only available on `LazyFrame`. On `DataFrame`, `.pb` provides write operations only (`write_bam`, `write_vcf`, etc.).\n\nMethod-chaining enables fluent pipelines:\n```python\n# Chain interval operations (note: overlap outputs suffixed columns,\n# so rename before merge which expects chrom\u002Fstart\u002Fend)\nresult = (\n    df1.lazy()\n    .pb.overlap(df2)\n    .filter(pl.col(\"start_2\") > 1000)\n    .select(\n        pl.col(\"chrom_1\").alias(\"chrom\"),\n        pl.col(\"start_1\").alias(\"start\"),\n        pl.col(\"end_1\").alias(\"end\"),\n    )\n    .pb.merge()\n    .collect()\n)\n```\n\n### Probe-Build Architecture\n\nFor two-input operations (overlap, nearest, count_overlaps, coverage), polars-bio uses a probe-build join strategy:\n- The **first** DataFrame is the **probe** (iterated over)\n- The **second** DataFrame is the **build** (indexed for lookup)\n\nFor best performance, pass the larger DataFrame as the first argument (probe) and the smaller one as the second (build).\n\n### Column Conventions\n\nBy default, polars-bio expects columns named `chrom`, `start`, `end`. Custom column names can be specified via lists:\n\n```python\nresult = pb.overlap(\n    df1, df2,\n    cols1=[\"chromosome\", \"begin\", \"finish\"],\n    cols2=[\"chr\", \"pos_start\", \"pos_end\"],\n)\n```\n\n### Return Types and Collecting Results\n\nAll interval operations and `pb.sql()` return a **LazyFrame** by default. Use `.collect()` to materialize results, or pass `output_type=\"polars.DataFrame\"` for eager evaluation:\n\n```python\n# Lazy (default) - collect when needed\nresult_lf = pb.overlap(df1, df2)\nresult_df = result_lf.collect()\n\n# Eager - get DataFrame directly\nresult_df = pb.overlap(df1, df2, output_type=\"polars.DataFrame\")\n```\n\n### Streaming and Out-of-Core Processing\n\nFor datasets larger than available RAM, use `scan_*` functions and streaming execution:\n\n```python\n# Scan files lazily\nlf = pb.scan_bed(\"large_intervals.bed\")\n\n# Process with streaming\nresult = lf.collect(streaming=True)\n```\n\nDataFusion streaming is enabled by default for interval operations, processing data in batches without loading the full dataset into memory.\n\n## Common Pitfalls\n\n1. **`.pb` accessor on DataFrame vs LazyFrame:** Interval operations (overlap, merge, etc.) are only on `LazyFrame.pb`. `DataFrame.pb` only has write methods. Use `.lazy()` to convert before chaining interval ops.\n\n2. **LazyFrame returns:** All interval operations and `pb.sql()` return `LazyFrame` by default. Don't forget `.collect()` or use `output_type=\"polars.DataFrame\"`.\n\n3. **Column name mismatches:** polars-bio expects `chrom`, `start`, `end` by default. Use `cols1`\u002F`cols2` parameters (as lists) if your columns have different names.\n\n4. **Coordinate system metadata:** When constructing DataFrames manually (not via `read_*`\u002F`scan_*`), polars-bio warns about missing coordinate metadata. Use `pb.set_option(\"coordinate_system\", \"0-based\")` globally, or use I\u002FO functions that set metadata automatically.\n\n5. **Probe-build order matters:** For overlap, nearest, and coverage, the first DataFrame is probed against the second. Swapping arguments changes which intervals appear in the left vs right output columns, and can affect performance.\n\n6. **INT32 position limit:** Genomic positions are stored as 32-bit integers, limiting coordinates to ~2.1 billion. This is sufficient for all known genomes but may be an issue with custom coordinate spaces.\n\n7. **BAM index requirements:** `read_bam` and `scan_bam` require a `.bai` index file alongside the BAM. Create one with `samtools index` if missing.\n\n8. **Parallel execution disabled by default:** DataFusion parallelism defaults to 1 partition. Enable for large datasets:\n   ```python\n   pb.set_option(\"datafusion.execution.target_partitions\", 8)\n   ```\n\n9. **CRAM has separate functions:** Use `read_cram`\u002F`scan_cram`\u002F`register_cram` for CRAM files (not `read_bam`). CRAM functions require a `reference_path` parameter.\n\n## Best Practices\n\n1. **Use `scan_*` for large files:** Prefer `scan_bed`, `scan_vcf`, etc. over `read_*` for files larger than available RAM. Scan functions enable streaming and predicate pushdown.\n\n2. **Configure parallelism for large datasets:**\n   ```python\n   import os\n   pb.set_option(\"datafusion.execution.target_partitions\", os.cpu_count())\n   ```\n\n3. **Use BGZF compression:** BGZF-compressed files (`.bed.gz`, `.vcf.gz`) support parallel block decompression, significantly faster than plain GZIP.\n\n4. **Select columns early:** When only specific columns are needed, select them early to reduce memory usage:\n   ```python\n   df = pb.read_vcf(\"large.vcf.gz\").select(\"chrom\", \"start\", \"end\", \"ref\", \"alt\")\n   ```\n\n5. **Use cloud paths directly:** Pass S3\u002FGCS\u002FAzure URIs directly to read\u002Fscan functions instead of downloading files first:\n   ```python\n   df = pb.read_bed(\"s3:\u002F\u002Fmy-bucket\u002Fregions.bed\", allow_anonymous=True)\n   ```\n\n6. **Prefer functional API for single operations, method-chaining for pipelines:** Use `pb.overlap()` for one-off operations and `.lazy().pb.overlap()` when building multi-step pipelines.\n\n## Resources\n\n### references\u002F\n\nDetailed documentation for each major capability:\n\n- **interval_operations.md** - All 8 interval operations with parameters, examples, output schemas, and performance tips. Core reference for genomic range arithmetic.\n\n- **file_io.md** - Supported formats table, per-format column schemas, cloud storage configuration, compression support, and common parameters.\n\n- **sql_processing.md** - Register functions, DataFusion SQL syntax, combining SQL with interval operations, and example queries.\n\n- **pileup_operations.md** - Per-base read depth computation from BAM\u002FCRAM files, parameters, and integration with interval operations.\n\n- **configuration.md** - Global settings (parallelism, coordinate systems, streaming modes), logging, and metadata management.\n\n- **bioframe_migration.md** - Operation mapping table, API differences, performance comparison, migration code examples, and pandas compatibility mode.\n",{"app":22,"name":5,"agents":46,"inputs":48,"attempts":49,"successes":49,"confidence":14,"description":7,"last_adjusted":50,"expected_state":51,"requires_approval":54},[47],"*",[],0,"2026-05-11T21:21:44+00:00",{"description":52,"verification_tool":53},"Imported skill — behavior matches source repo","none",true,"master","5f13b5d2b532c0ab6f847e3aa24d4bfe66f7d461","skills\u002Fscience\u002Fpolars-bio","https:\u002F\u002Fgithub.com\u002FFlissel\u002Fvibemind-os","https:\u002F\u002Fgithub.com\u002FFlissel","https:\u002F\u002Fvibemind.space","Co-founder & CTO, VibeMind - a voice-first agentic OS for non-technical founders. Agents that do the work, not describe it.","2026-11-15 02:57:54",{"source":8,"skillName":5,"commands":64,"prompt":74,"zipAvailable":54},[65,68,71],{"tool":66,"command":67},"npx","npx skills add Flissel\u002Fvibemind-os --skill science-polars-bio",{"tool":69,"command":70},"bunx","bunx skills add Flissel\u002Fvibemind-os --skill science-polars-bio",{"tool":72,"command":73},"pnpm","pnpm dlx skills add Flissel\u002Fvibemind-os --skill science-polars-bio","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FFlissel\u002Fvibemind-os\u002Fblob\u002Fmaster\u002Fskills\u002Fscience\u002Fpolars-bio\u002FSKILL.md",[],[77,85,93,100,127,135],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":84},"01M7DTM31MG69FRRMZF1E414G8","event-task-image-uploads","Foto aus dem Chat an eine Aufgabe der Event-App hängen.","https:\u002F\u002Fgithub.com\u002FFlissel\u002Fvibemind-os\u002Fblob\u002Fmaster\u002Fspaces\u002Fevent_management\u002Fconfig\u002Fworkspace-legacy\u002Fskills\u002Fevent-task-image-uploads\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":41},"01M6JAA67M92TRE7GWDJDBTA9T","review","Review a change.","https:\u002F\u002Fgithub.com\u002FFlissel\u002Fvibemind-os\u002Fblob\u002Fmaster\u002Fspaces\u002Frowboat\u002Frowboat\u002Fpackages\u002Fopenai-plugin-runtime\u002Ftest\u002Ffixtures\u002Fcomplete-plugin\u002Fskills\u002Freview\u002FSKILL.md",[],[87,92],"change",{"skillNo":94,"name":95,"nameZh":6,"description":96,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":97,"categories":98,"keywords":99,"publishedAt":41},"01M6JAA3DZR55G8ZY493BE9NBB","triage","Triage a change.","https:\u002F\u002Fgithub.com\u002FFlissel\u002Fvibemind-os\u002Fblob\u002Fmaster\u002Fspaces\u002Frowboat\u002Frowboat\u002Fpackages\u002Fopenai-plugin-runtime\u002Ftest\u002Ffixtures\u002Fcomplete-plugin\u002Fskills\u002Fgroup\u002Ftriage\u002FSKILL.md",[],[95,92],{"skillNo":101,"name":102,"nameZh":6,"description":103,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":104,"categories":105,"keywords":106,"publishedAt":41},"01M6JA9XPVHENK0FQN7HBK54NV","zentrale-werkzeuge","Werkzeuge der Zentrale – nutzen bei GitHub-Fragen (Projekte updaten, Repos, Issues, PRs, Commits, CI\u002FActions-Status, README), bei Fragen zum eigenen Gitea (Sicherung\u002FSpiegel, Repos, Issues, Commits), wenn neueste Docs\u002FDoku zu einer Bibliothek oder einem Dienst geholt werden sollen, wenn ein Dashboard aus meinen Daten gebaut werden soll und wenn ich sage 'auf meinem PC suchen' oder 'such auf dem Rechner nach …'.","https:\u002F\u002Fgithub.com\u002FFlissel\u002Fvibemind-os\u002Fblob\u002Fmaster\u002Fspaces\u002Frowboat\u002Fdeploy\u002Fheadless\u002Fskills\u002Fzentrale-werkzeuge\u002FSKILL.md",[],[107,108,109,110,111,112,113,114,38,115,116,117,118,119,120,121,122,123,124,125,126],"zentrale werkzeuge","issues","repos","grep","status","list","docs","URL","add","prs","ci","mkdir","actions","README","commits","github","gitea","dashboard","fetch","todo",{"skillNo":128,"name":129,"nameZh":6,"description":130,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":131,"categories":132,"keywords":133,"publishedAt":41},"01M6JA9SQPX187CVC148SQT1SP","wissen-suchen","Bedeutungssuche im Rowboat-Wissen – IMMER zuerst nutzen, wenn nach Kunden, Kontakten, Themen, Interessen, Notizen oder 'was wissen wir über …' gefragt wird, besonders wenn die genauen Wörter unklar sind.","https:\u002F\u002Fgithub.com\u002FFlissel\u002Fvibemind-os\u002Fblob\u002Fmaster\u002Fspaces\u002Frowboat\u002Fdeploy\u002Fheadless\u002Fskills\u002Fwissen-suchen\u002FSKILL.md",[],[134],"wissen suchen",{"skillNo":136,"name":137,"nameZh":6,"description":138,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":139,"categories":140,"keywords":141,"publishedAt":41},"01M6JA9P6GNFPE21101SDZS3BT","reel-aus-material","Reel aus vorhandenen Laura-Videos: passende Stellen im Transkript finden; spricht dort eine Person, bleibt ihr Originalton (mit Untertiteln aus dem Transkript), sonst trägt ein eingesprochener Satz den Clip. Bei Aufträgen der Art 'material'.","https:\u002F\u002Fgithub.com\u002FFlissel\u002Fvibemind-os\u002Fblob\u002Fmaster\u002Fspaces\u002Fmarketing\u002Fvideo_claw\u002Fskills\u002Freel-aus-material\u002FSKILL.md",[],[142,143,144,145,146,147,148],"reel","reel aus material","material","clip","Art","videos","person"]