geniml
Python library for genomic interval ML. Train/apply region2vec embeddings turning BED regions into vectors, index interval datasets for ML, search embedding space with BEDSpace, and evaluate embedding quality.
Install / Use
npx skills add jaechang-hits/SciAgent-Skills --skill genimlInstalls into whichever agent you are using.
SKILL.md
Installable skill definition
Quality Score
Category
AI & Machine LearningSupported Platforms
Our assessment of geniml
geniml scores 91/100 on our quality scale, 347th of 944 AI & Machine Learning skills we index (top 37%).
Its SKILL.md is 17 KB long, well organised into 65 sections with 18 code examples: a thorough specification that gives an agent plenty to work with.
It has 367 GitHub stars, a meaningful sign that others use it.
Maintenance, license and trust
- The repository was last updated about 3 months ago, so geniml is actively maintained.
- Our last check on 2026-11-20 found the source still online.
- No license is declared. By default that means all rights are reserved: you can read it, but reusing or redistributing it is not clearly permitted. Ask the author before building on it commercially.
- Its trust signals score 88/100, with 1 caution from licensing, adoption, age or documentation. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.
Safety scan
No issues foundOur scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. An AI review of the same text found nothing harmful.
AI review by kimi-k2.7-code on 2026-10-05. Automated pattern scan on 2026-10-05. It catches known dangerous patterns, not every risk — read a skill before letting an agent act on it.
geniml compared with similar skills
All 4 of these similar skills score higher than geniml; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| geniml (this skill)by jaechang-hits | 91 | 367 | 3mo ago | SKILL.md |
| claude-memby thedotmack | 100 | 118.5k | today | CLAUDE.md |
| Agent-Reachby Panniantong | 100 | 113.3k | 12d ago | CLAUDE.md |
| Understand-Anythingby Egonex-AI | 100 | 93.3k | 1d ago | CLAUDE.md |
| headroomby headroomlabs-ai | 100 | 80.2k | today | CLAUDE.md |
Frequently asked questions
- How do I install geniml?
- Run
npx skills add jaechang-hits/SciAgent-Skills --skill geniml. The install tabs above show the steps for each supported agent. - Which AI agents does geniml work with?
- It is written for Universal, as a SKILL.md file. Other agents that read the same format can often use it too.
- Is geniml safe to use?
- Our scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. An AI review of the same text found nothing harmful. It declares no license and scores 88/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
- Is geniml still maintained?
- The repository was last updated about 3 months ago, so geniml is actively maintained.
Skill content
View source on GitHubname: "geniml" description: "Python library for genomic interval ML. Train/apply region2vec embeddings turning BED regions into vectors, index interval datasets for ML, search embedding space with BEDSpace, and evaluate embedding quality. Use for chromatin accessibility clustering, regulatory element classification, and cross-sample region comparison." license: "BSD-2-Clause"
Geniml: Genomic Interval Machine Learning
Overview
Geniml is a Python library that bridges genomic interval biology and machine learning. It provides region2vec for learning dense vector representations of genomic regions from BED files, BEDSpace for nearest-neighbor search in embedding space, dataset classes for ML-ready genomic interval loading, and evaluation utilities for embedding quality. Geniml is designed for researchers who want to apply modern ML techniques to chromatin accessibility, histone modification, or other region-based genomic data.
When to Use
- Learn dense embeddings of genomic regions from a collection of BED files to enable ML-based analysis (region2vec)
- Cluster chromatin accessibility peaks or histone modification sites by embedding similarity
- Search for genomic regions similar to a query region using approximate nearest-neighbor search (BEDSpace)
- Build training datasets for ML models from BED-format genomic intervals with a PyTorch-compatible interface
- Compare embedding quality across training runs or datasets using quantitative metrics
- Integrate genomic region representations into custom neural network architectures
- For basic BED file parsing and set operations without ML, use
gtarsorpysam-genomic-filesinstead
Prerequisites
- Python packages:
geniml,torch,numpy,pandas,anndata - Data requirements: BED files (minimum 3 columns: chr, start, end); optionally a pre-built universe file
- Environment: Python 3.8+; GPU optional but recommended for region2vec training on large datasets
pip install geniml torch numpy pandas anndata
Quick Start
from geniml.region2vec import Region2VecExModel
from geniml.io import RegionSet
# Load a collection of BED files and train region2vec embeddings
region_sets = [RegionSet("sample1.bed"), RegionSet("sample2.bed"), RegionSet("sample3.bed")]
model = Region2VecExModel("path/to/universe.bed")
model.train(region_sets, epochs=10, batch_size=32)
# Get embedding for a specific region
embedding = model.encode("chr1", 1000000, 1500000)
print(f"Embedding shape: {embedding.shape}")
# Embedding shape: (100,)
Core API
Module 1: RegionSet — Genomic Interval I/O
Load BED files into geniml's primary data structure for downstream operations.
from geniml.io import RegionSet
# Load a BED file
rs = RegionSet("peaks.bed")
print(f"Loaded {len(rs)} regions")
print(f"First region: {rs[0]}") # Region object: chr, start, end
print(f"Chromosomes: {set(r.chr for r in rs)}")
# Convert to list of Region objects
regions = list(rs)
for r in regions[:3]:
print(f" {r.chr}:{r.start}-{r.end}")
from geniml.io import RegionSet
# Create RegionSet from a list of (chr, start, end) tuples
regions_data = [
("chr1", 100000, 101000),
("chr1", 200000, 201500),
("chr2", 50000, 51200),
]
rs = RegionSet(regions_data)
print(f"RegionSet with {len(rs)} regions from list")
# Access by index
r = rs[0]
print(f"chr={r.chr}, start={r.start}, end={r.end}, width={r.end - r.start}")
Module 2: Universe Building
A universe defines the set of consensus regions used as the vocabulary for region2vec. Build it from a collection of BED files.
from geniml.universe import UniverseBuilder
from geniml.io import RegionSet
# Collect BED files representing diverse samples
bed_files = ["sample1.bed", "sample2.bed", "sample3.bed", "sample4.bed"]
region_sets = [RegionSet(f) for f in bed_files]
# Build universe (consensus non-overlapping regions)
builder = UniverseBuilder()
universe = builder.build(region_sets)
# Save universe to BED file
universe.to_bed("universe.bed")
print(f"Universe size: {len(universe)} consensus regions")
from geniml.universe import UniverseBuilder
from geniml.io import RegionSet
# Build universe with custom parameters
builder = UniverseBuilder(
fraction=0.5, # Region must appear in >= 50% of samples to be included
merge_dist=0, # Merge adjacent regions within this distance (bp)
)
bed_files = [f"sample_{i}.bed" for i in range(1, 11)]
region_sets = [RegionSet(f) for f in bed_files]
universe = builder.build(region_sets)
print(f"Filtered universe: {len(universe)} regions (fraction >= 0.5)")
Module 3: Region2Vec — Training Embeddings
Train word2vec-style embeddings on genomic regions, treating each BED file as a "document" and each region as a "word."
from geniml.region2vec import Region2VecExModel
from geniml.io import RegionSet
# Initialize model with a pre-built universe
model = Region2VecExModel(universe="universe.bed", embedding_dim=100)
# Load training data (collection of BED files = corpus)
bed_files = [f"atac_{i}.bed" for i in range(1, 51)]
region_sets = [RegionSet(f) for f in bed_files]
# Train
model.train(
region_sets,
epochs=20,
batch_size=64,
window_size=5,
min_count=1,
)
print("Training complete")
# Save trained model
model.save("region2vec_model/")
print("Model saved to region2vec_model/")
from geniml.region2vec import Region2VecExModel
# Load a pre-trained model
model = Region2VecExModel.load("region2vec_model/")
# Encode a single genomic region
embedding = model.encode("chr1", 1_000_000, 1_500_000)
print(f"Single region embedding shape: {embedding.shape}")
# Single region embedding shape: (100,)
# Encode an entire BED file → matrix of region embeddings
from geniml.io import RegionSet
rs = RegionSet("query_peaks.bed")
embeddings = model.encode_region_set(rs)
print(f"BED file embeddings shape: {embeddings.shape}")
# BED file embeddings shape: (N_regions, 100)
Module 4: BEDSpace — Embedding Nearest-Neighbor Search
Index a corpus of BED file embeddings for fast similarity search.
from geniml.bedspace import BEDSpace
from geniml.region2vec import Region2VecExModel
from geniml.io import RegionSet
# Build a BEDSpace index from a set of BED files
model = Region2VecExModel.load("region2vec_model/")
bed_files = [f"dataset_{i}.bed" for i in range(1, 101)]
region_sets = [RegionSet(f) for f in bed_files]
bedspace = BEDSpace(model)
bedspace.fit(region_sets, labels=[f"dataset_{i}" for i in range(1, 101)])
bedspace.save("bedspace_index/")
print(f"BEDSpace index built with {len(region_sets)} datasets")
from geniml.bedspace import BEDSpace
from geniml.io import RegionSet
# Load index and query
bedspace = BEDSpace.load("bedspace_index/")
query = RegionSet("query_sample.bed")
# Find top-k most similar datasets
results = bedspace.query(query, k=5)
for rank, (label, score) in enumerate(results, 1):
print(f" Rank {rank}: {label} similarity={score:.4f}")
Module 5: Genomic Interval Datasets for ML
PyTorch-compatible Dataset classes for training ML models on genomic intervals.
from geniml.datasets import TokenizedBEDDataset
from torch.utils.data import DataLoader
# Create a tokenized dataset from multiple BED files + labels
bed_files = ["condition_A_rep1.bed", "condition_A_rep2.bed",
"condition_B_rep1.bed", "condition_B_rep2.bed"]
labels = [0, 0, 1, 1]
dataset = TokenizedBEDDataset(
bed_files=bed_files,
universe="universe.bed",
labels=labels,
)
print(f"Dataset size: {len(dataset)} samples")
# Use with PyTorch DataLoader
loader = DataLoader(dataset, batch_size=8, shuffle=True)
for batch_tokens, batch_labels in loader:
print(f"Batch tokens shape: {batch_tokens.shape}")
print(f"Batch labels: {batch_labels}")
break
from geniml.datasets import RegionEmbeddingDataset
from geniml.region2vec import Region2VecExModel
import torch
# Pre-embed BED files and create a dataset for a classifier
model = Region2VecExModel.load("region2vec_model/")
bed_files = ["pos_1.bed", "pos_2.bed", "neg_1.bed", "neg_2.bed"]
labels = [1, 1, 0, 0]
emb_dataset = RegionEmbeddingDataset(
bed_files=bed_files,
model=model,
labels=labels,
aggregation="mean", # aggregate region embeddings per sample
)
X, y = emb_dataset[0]
print(f"Sample embedding shape: {X.shape}, label: {y}")
# Sample embedding shape: (100,), label: 1
Module 6: Embedding Evaluation
Assess embedding quality using neighborhood overlap and intrinsic metrics.
from geniml.eval import EmbeddingEvaluator
from geniml.region2vec import Region2VecExModel
from geniml.io import RegionSet
model = Region2VecExModel.load("region2vec_model/")
bed_files = [f"sample_{i}.bed" for i in range(1, 21)]
region_sets = [RegionSet(f) for f in bed_files]
evaluator = EmbeddingEvaluator(model)
metrics = evaluator.evaluate(region_sets)
print(f"Neighborhood overlap score: {metrics['neighborhood_overlap']:.4f}")
print(f"Silhouette score: {metrics.get('silhouette', 'N/A')}")
# Higher neighborhood overlap → more biologically coherent embeddings
Key Concepts
region2vec Training Analogy
Region2vec treats each BED file as a "sentence" (a document of co-occurring genomic regions) and each genomic region token (from the universe) as a "word." Word2vec's skip-gram objective is applied: regions that frequently co-occur in BED files are learned to have similar embeddings. This means two regions that tend to be open/active in the same set of samples will have nearby embeddings, enabling meaningful similarity search without explicit labels.
# Conceptual analogy: universe regions = vocabulary tokens
# BED file = sentence = [region_token_1, region_token_2, ...]
# Training: predict co-occurring regions within a sliding window
from geniml.io import RegionSet
rs = RegionSet("sample.bed")
print(f"This BED file contains {len(rs)} 'words' (tokens) from the universe vocabulary")
Universe as Vocabulary
The universe is a non-overlapping, genome-wide set of consensus regions that serves as the token vocabulary for region2vec. A well-chosen universe should cover the genomic regions present in your dataset while being compact enough for efficient training. Regions in a BED file that do not overlap the universe are ignored during training.
Common Workflows
Workflow 1: Train and Search Embeddings from ATAC-seq Peaks
Goal: Embed ATAC-seq peak sets, then find samples most similar to a query.
from geniml.universe import UniverseBuilder
from geniml.region2vec import Region2VecExModel
from geniml.bedspace import BEDSpace
from geniml.io import RegionSet
from pathlib import Path
# Step 1: Collect BED files
bed_dir = Path("atac_peaks/")
bed_files = sorted(bed_dir.glob("*.bed"))
region_sets = [RegionSet(str(f)) for f in bed_files]
labels = [f.stem for f in bed_files]
print(f"Loaded {len(region_sets)} ATAC-seq peak sets")
# Step 2: Build universe
builder = UniverseBuilder(fraction=0.3)
universe = builder.build(region_sets)
universe.to_bed("atac_universe.bed")
print(f"Universe: {len(universe)} regions")
# Step 3: Train region2vec
model = Region2VecExModel(universe="atac_universe.bed", embedding_dim=100)
model.train(region_sets, epochs=15, batch_size=64, window_size=5)
model.save("atac_region2vec/")
# Step 4: Build BEDSpace index
bedspace = BEDSpace(model)
bedspace.fit(region_sets, labels=labels)
bedspace.save("atac_bedspace/")
# Step 5: Query with a new sample
query = RegionSet("new_sample.bed")
results = bedspace.query(query, k=5)
print("Top 5 most similar samples:")
for rank, (label, score) in enumerate(results, 1):
print(f" {rank}. {label} (similarity={score:.4f})")
Workflow 2: ML Classification on Genomic Intervals
Goal: Train a logistic regression classifier on region2vec embeddings to classify cell typ
Truncated for display — read the full file on GitHub.
Related Skills
claude-mem
118.5kPersistent Context Across Sessions for Every Agent – Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions. Works with Claude Code, OpenClaw, Codex, Gemini, Hermes, Copilot, OpenCode + More
Agent-Reach
113.3kGive your AI agent eyes to see the entire internet. Read & search Twitter, Reddit, YouTube, GitHub, Bilibili, XiaoHongShu — one CLI, zero API fees.
Understand-Anything
93.3kGraphs that teach > graphs that impress. Turn any code into an interactive knowledge graph you can explore, search, and ask questions about. Works with Claude Code, Codex, Cursor, Copilot, Gemini CLI, and more.
headroom
80.2kCompress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.
Languages
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.
