본문으로 건너뛰기
Skillpedia
머신러닝51k · #3529

polars-bio

하는 일

이 도구는 유전체 서열(DNA의 유전자 등)을 비교하고 조작하도록 돕습니다. 어떤 서열이 겹치는지, 어떤 것이 가장 가까운지 찾고, 연속된 서열을 병합하고, 범위(커버리지)를 계산하는 등 다양한 연산을 할 수 있습니다.

사용하는 경우

  • ✓두 유전자 목록을 비교해 공통된 유전자를 찾을 때.
  • ✓시퀀싱되지 않은 DNA 영역을 찾을 때.
  • ✓겹치는 유전체 서열 조각을 병합할 때.

스킬 링크

https://github.com/K-Dense-AI/scientific-agent-skills/blob/main/skills/polars-bio/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/K-Dense-AI/scientific-agent-skills/blob/main/skills/polars-bio/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“목록 A의 유전자 중 목록 B의 유전자와 겹치는 것은 무엇인가요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

도구는 BED, VCF, BAM 같은 흔한 형식의 유전체 데이터를 읽고 표로 정리합니다. 그다음 수학 연산을 적용해 이 유전체 서열들의 위치를 비교합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

polars-bio

Use this skill for genomic interval arithmetic and bioinformatics file I/O through Polars and DataFusion. It targets polars-bio 0.36.0, tested with Polars 1.44.2 on Python 3.13. The upstream package requires Polars >=1.37.1, PyArrow >=23.0.1,<25, DataFusion >=53,<54 and polars-config-meta >=0.3.2,<1. Keep this environment separate from packages needing incompatible Arrow or DataFusion releases.

uv pip install "polars-bio==0.36.0" "polars==1.44.2"
# Optional pandas interoperability (requires pandas >=3):
uv pip install "polars-bio[pandas]==0.36.0" "polars==1.44.2"

Verify new releases against the official release notes and package requirements. The examples below with named files are templates: substitute actual files and check their schemas. The synthetic interval example and small local format round trips were executed during this review.

Workflow

  1. Record the assembly, contig naming, coordinate convention, strand policy and unit of analysis. Identical contig names do not prove identical assemblies.
  2. Choose readers by format; BCF has its own reader. Inspect schemas and source metadata before selecting attributes or genotypes.
  3. Normalize all inputs to one coordinate system and validate their bounds.
  4. Choose pair output, hit counts, covered bases or read depth deliberately.
  5. Filter and project lazily, then inspect a small result before scaling up.
  6. Validate output counts and boundaries against a hand-computable fixture; preserve IDs, coordinate metadata and provenance when saving results.

Coordinate contract

The default is 1-based closed, including converted BED reads. Use use_zero_based=True on genomic readers for 0-based half-open output. This argument converts positions; it is not only a metadata label. For example, BED [0,10) becomes [1,10] by default and remains [0,10) with the override. SAM text POS is 1-based, whereas BAM stores its alignment position internally as 0-based. Both readers expose the requested output convention.

For manually constructed DataFrames, metadata labels existing numbers and does not convert them. Converting closed [s,e] to half-open means s-1,e. Set metadata only after conversion. Never convert twice.

import polars as pl
import polars_bio as pb

pb.set_option("datafusion.bio.coordinate_system_zero_based", True)
pb.set_option("datafusion.bio.coordinate_system_check", True)

query = pl.DataFrame({
    "query_id": ["q1", "q2", "q3"],
    "chrom": ["chr1", "chr1", "chr2"],
    "start": [0, 10, 0], "end": [10, 20, 10],
})
target = pl.DataFrame({
    "chrom": ["chr1", "chr1"], "start": [5, 8], "end": [12, 15],
})
for frame in (query, target):
    frame.config_meta.set(coordinate_system_zero_based=True)

pairs = pb.overlap(query, target).collect()
counts = pb.count_overlaps(query, target).collect().sort("query_id")
covered = pb.coverage(query, target).collect().sort("query_id")
assert pairs.height == 4
assert counts["count"].to_list() == [2, 2, 0]
assert covered["coverage"].to_list() == [5, 5, 0]

Require non-null contigs, integer positions and valid positive-length intervals (0 <= start < end in half-open form), within the chosen assembly. Do not silently turn points/insertions into nonempty intervals: choose the biological convention. Mismatched input metadata raises CoordinateSystemMismatchError; missing metadata warns and uses the global setting by default, or raises MissingCoordinateSystemError in strict mode. Inspect pb.get_metadata(frame) after transformations and SQL. See configuration.

Choose the operation

Question Operation Interpretation
Which interval pairs intersect? overlap(a, b) Inner pair join; a query can appear repeatedly
Which query rows have any hit? overlap(a, b, overlap_output="left", distinct_output=True) One hit per original query row; duplicate input rows retain identity
How many target intervals intersect each query? count_overlaps(a, b) Target-record count, including zero for no hit
How many query bases are covered? coverage(a, b) Length of the union of target intersections; not read depth
Which targets are closest? nearest(a, b, k=1) Up to k neighbors, with nullable target/distance for no candidate

…

자주 묻는 질문

‘유전체 구간’이란 무엇인가요?

염색체나 더 큰 서열의 시작점과 끝점으로 정의된 DNA 구간입니다.

어떤 파일 형식을 지원하나요?

BED, VCF, BAM, GFF, GTF, FASTA, FASTQ 등 분자생물학에서 쓰이는 여러 형식을 지원합니다.

위치 세기(0부터 또는 1부터 시작)는 어떻게 처리하나요?

기본적으로 1 기반(닫힌) 방식을 사용하지만, 필요하면 일부 도구에서 흔히 쓰는 0 기반(반개구간) 방식으로 설정할 수 있습니다.

상세 정보

작성자의 원본 설명

Performs genomic interval overlap, nearest, merge, coverage, complement and subtraction on Polars DataFrames, and reads or writes BED, VCF, BCF, BAM, CRAM, GFF, GTF, FASTA and FASTQ data. Use for coordinate-aware genomic joins, read-depth analysis, lazy bioinformatics I/O, SQL queries or migration from bioframe.

repo: K-Dense-AI/scientific-agent-skills

인기도

GitHub 스타
51k
순위
#3529
라이선스
MIT
업데이트
2026. 10. 15.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬