Logo: Bioconductor Genomicranges

Bioconductor Genomicranges

Organisatioun
bioMate-AI
bioconductor-genomicranges

D'Fäegkeet, genomesch Annotatiounen an Alignementer effizient duerzestellen an ze manipuléieren, spillt eng zentral Roll bei der Analyse vun Héichduerchsaz-Sequenzéierungsdaten (och NGS-Daten genannt). De GenomicRanges-Package definéiert allgemeng Zwecker

Add to TypingMind

Iwwersiicht

EditeurbioMate-AI
Repositorybiomate-bioconductor-kb
Skill-Nummbioconductor-genomicranges
Stären
804
Forks
66
Matgeliwwert Dateien
Nëmmen Instruktiounen
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • Alles an den Instruktiounen

    Alles, wat de Modell brauch, steet an den Instruktiounen — keng zousätzlech Dateien ze synchroniséieren.

  • Open Source

    bioMate-AI huet de Skill op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Bioconductor Genomicranges an TypingMind, fir e mat all LLM ze benotzen, oder setzt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vu GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier, déi hei drënner steet, an a bestätegt d'Installatioun.
    https://github.com/bioMate-AI/biomate-bioconductor-kb/tree/main/skills/genomics/genomicranges
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill derbäisetzen → Iwwer eng GitHub-URL. Pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an d'Skill-Verzeechnes vun deem KI-Agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/bioMate-AI/biomate-bioconductor-kb.git /tmp/biomate-bioconductor-kb
mkdir -p .claude/skills
cp -r /tmp/biomate-bioconductor-kb/skills/genomics/genomicranges .claude/skills/bioconductor-genomicranges
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Bioconductor Genomicranges an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Bioconductor Genomicranges automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Bioconductor Genomicranges net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Schlësselen.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

GenomicRanges — Comprehensive Skill Guide

Domain: Genomics Infrastructure Bioconductor: GenomicRanges Paper: Lawrence M et al. (2013). PLOS Computational Biology, 9:e1003118.

Infrastructure for representing and manipulating genomic intervals. The core workhorse for any genomic coordinate arithmetic in Bioconductor.

Dependencies & Environment

Package-intrinsic requirements from the Bioconductor landing page — reproduce in any R environment.

  • Version: 1.64.0 · Bioconductor: 3.23 · R: ≥ 4.6
  • Depends: BiocGenerics, S4Vectors, IRanges, Seqinfo
  • Install: BiocManager::install("GenomicRanges")

When to Use

  • Overlap queries between genomic features
  • Peak annotation and TSS proximity
  • Windowed genome coverage computation
  • Import/export BED/GFF/VCF/BigWig regions
  • Tiling genome for ChIP-seq/ATAC-seq windows

Alternatives: IRanges (integer ranges only), plyranges (tidyverse-style)

Do NOT Use When

  • Sequence manipulation (use Biostrings instead).
  • Annotation retrieval (use AnnotationHub, biomaRt, or TxDb).
  • Genome-wide statistics directly (use BSgenome or rtracklayer for coverage).

Data Requirements

RequirementDetails
Input FormatBED, GFF/GTF (via rtracklayer), or programmatic construction from data frames

Installation

r
if (!require("BiocManager", quietly=TRUE))
    install.packages("BiocManager")
BiocManager::install("GenomicRanges")
library(GenomicRanges)

Workflows

Genomic interval manipulation and overlap analysis

Core operations: construct, manipulate, and intersect GRanges objects

Build and manipulate GRanges
r
library(GenomicRanges)

# Create GRanges from scratch
gr <- GRanges(
    seqnames = c("chr1","chr1","chr2"),
    ranges   = IRanges(start=c(100,200,150), end=c(200,300,250)),
    strand   = c("+","-","*"),
    gene_id  = c("GENE1","GENE2","GENE3")
)

# Resize to 500bp around centre (e.g. for peak centering)
gr_centered <- resize(gr, width=500, fix="center")

# Extend 200bp upstream
gr_extended <- flank(gr, width=200, start=TRUE)
Find overlaps between two sets
r
peaks <- readRDS("chip_peaks.rds")    # GRanges of ChIP peaks
genes <- readRDS("gene_models.rds")   # GRanges of gene bodies

# Which peaks overlap any gene?
hits <- findOverlaps(peaks, genes)
peak_in_gene <- peaks[queryHits(hits)]

# Count overlaps per peak
ov_counts <- countOverlaps(peaks, genes)
peaks$n_genes_overlapped <- ov_counts
Coverage and binning
r
# Per-base coverage
cov <- coverage(gr)

# Bin genome into 1kb windows and count reads
bins <- tileGenome(seqinfo(gr), tilewidth=1000, cut.last.tile.in.chrom=TRUE)
bin_counts <- countOverlaps(bins, gr)

Key Functions & Parameters

GRanges()

Create genomic ranges object

ParameterDescription
seqnameschromosome names (Rle)
rangesIRanges object with start/end
strand'+' | '-' | '*'
...any additional metadata columns

findOverlaps()

Find overlaps between two GRanges; returns Hits object

ParameterDescription
queryGRanges
subjectGRanges
type'any' (default) | 'start' | 'end' | 'within' | 'equal'
select'all' | 'first' | 'last' | 'arbitrary'
maxgapmax gap allowed between ranges (default -1L = 0 gap)
minoverlapmin overlap required (default 1L)
ignore.strandlogical (default FALSE)

subsetByOverlaps()

Subset GRanges to those overlapping another set

ParameterDescription
xGRanges to subset
rangesGRanges to overlap with
maxgapsame as findOverlaps
minoverlapsame as findOverlaps

coverage()

Compute per-base coverage as Rle/RleList

ParameterDescription
xGRanges or GAlignments
shiftshift each range (default 0)
widthseqlength per chromosome
weightper-range weights (default 1)

resize()

Resize ranges (e.g. extend TSS windows)

ParameterDescription
xGRanges
widthnew width in bp
fix'start' | 'end' | 'center'
ignore.strandlogical

promoters()

Extract promoter regions upstream of TSS

ParameterDescription
xTxDb or GRanges of transcripts
upstreambp upstream of TSS (default 2000)
downstreambp downstream of TSS (default 200)

Scientific Assumptions

The method assumes the following about your data and experiment:

  • Genomic intervals are 1-based, closed by default in R (not 0-based BED); subtract 1 when importing BED files.

Result Interpretation

  • findOverlaps() result: queryHits = indices into query, subjectHits = indices into subject; many-to-many mapping.
  • nearest() / distanceToNearest(): returns index of nearest feature in subject and distance in bp.
  • coverage() result: RleList per chromosome; sum() gives total depth.

Best Practices

  • Always use consistent chromosome naming style (UCSC: chr1 vs NCBI: 1); use seqlevelsStyle() to convert.
  • Set seqinfo(gr) <- seqinfo(bsgenome) to attach chromosome lengths before coverage().
  • Use plyranges package for a dplyr-style API: gr %>% filter_by_overlaps(other).
  • Import BED files with rtracklayer::import('file.bed') → returns GRanges directly.
  • Sort GRanges with sort() before most operations for efficiency.
  • Use reduce() to merge overlapping ranges; disjoin() to split at every boundary.

When to Choose This vs Alternatives

AlternativePrefer this tool whenPrefer alternative when
pybedtools (Python)You work in Python or need BEDTools command-line compatibility.You are in the Bioconductor R ecosystem and want integration with GRanges-aware packages.

Benchmark Evidence

GenomicRanges is foundational infrastructure; citations measure ecosystem adoption.

  • Lawrence M et al. (2013). PLoS Comput Biol 9:e1003118. PMID:23950696 Original GenomicRanges paper. Demonstrates O(n log n) interval overlap algorithm scaling to whole-genome datasets (billions of intervals) with <1GB RAM footprint.

  • Huber W et al. (2015). Nature Methods 12:115. PMID:25633503 Bioconductor overview paper; GenomicRanges is cited as the core interoperability layer used by >500 downstream Bioconductor packages, indicating community validation.

Common Errors & Troubleshooting

seqlevels mismatch between query and subject

Cause: chr1 vs 1 naming discrepancy

Fix: seqlevelsStyle(gr1) <- seqlevelsStyle(gr2) or keepStandardChromosomes()

Additional Notes from Official Documentation

Extracted from the GenomicRanges Bioconductor vignette(s)

Contents

1 Introduction 2 GRanges : Genomic Ranges 2.1 Splitting and combining GRanges objects 2.2 Subsetting GRanges objects 2.3 Basic interval operations for GRanges objects 2.4 Interval set operations for GRanges objects 2.1 Splitting and combining GRanges objects 2.2 Subsetting GRanges objects 2.3 Basic interval operations for GRanges objects 2.4 Interval set operations for GRanges objects 3 GRangesList : Groups of Genomic Ranges 3.1 Basic GRangesList accessors 3.2 Combining GRangesList objects 3.3 Basic interval operations for GRangesList objects 3.4 Subsetting GRangesList objects 3.5 Looping over GRangesList objects 3.1 Basic GRangesList accessors 3.2 Combining GRangesList objects 3.3 Basic interval operations for GRangesList objects 3.4 Subsetting GRangesList objects 3.5 Looping over GRange

1 Introduction

The GenomicRanges package serves as the foundation for representing genomic locations within the Bioconductor project. In the Bioconductor package hierarchy, it builds upon the IRanges (infrastructure) package and provides support for the BSgenome (infrastructure), Rsamtools (I/O), ShortRead (I/O & QA), rtracklayer (I/O), GenomicFeatures (infrastructure), GenomicAlignments (sequence reads), VariantAnnotation (called variants), and many other Bioconductor packages. This package lays a foundation for genomic analysis by introducing three classes ( GRanges , GPos , and GRangesList ), which are used to represent genomic ranges, genomic positions, and groups of genomic ranges. This vignette focuses on the GRanges and GRangesList classes and their associated methods. The GenomicRanges package i

r
if (!require("BiocManager"))
    install.packages("BiocManager")
BiocManager::install("GenomicRanges")
r
library(GenomicRanges)

2 GRanges : Genomic Ranges

The GRanges class represents a collection of genomic ranges that each have a single start and end location on the genome. It can be used to store the location of genomic features such as contiguous binding sites, transcripts, and exons. These objects can be created by using the GRanges constructor function. For example, creates a GRanges object with 10 genomic ranges. The output of the GRanges show method separates the information into a left and right hand region that are separated by | symbols. The genomic coordinates (seqnames, ranges, and strand) are located on the left-hand side and the metadata columns (annotation) are located on the right. For this example, the metadata is comprised of score and GC information, but almost anything can be stored in the metadata portion of a GRanges

r
gr <- GRanges(
    seqnames = Rle(c("chr1", "chr2", "chr1", "chr3"), c(1, 3, 2, 4)),
    ranges = IRanges(101:110, end = 111:120, names = head(letters, 10)),
    strand = Rle(strand(c("-", "+", "*", "+", "-")), c(1, 2, 2, 3, 2)),
    score = 1:10,
    GC = seq(1, 0, length=10))
gr
r
## GRanges object with 10 ranges and 2 metadata columns:
##     seqnames    ranges strand |     score        GC
##        <Rle> <IRanges>  <Rle> | <integer> <numeric>
##   a     chr1   101-111      - |         1  1.000000
##   b     chr2   102-112      + |         2  0.888889
##   c     chr2   103-113      + |         3  0.777778
##   d     chr2   104-114      * |         4  0.666667
##   e     chr1   105-115      * |         5  0.555556
##   f     chr1   106-116      + |         6  0.444444
##   g     chr3   107-117      + |         7  0.333333
##   h     chr3   108-118      + |         8  0.222222
##   i     chr3   109-119      - |         9  0.111111
##   j     chr3   110-120      - |        10  0.000000
##   -------
##   seqinfo: 3 sequences from an unspecified genome; no seqlengths

2.1 Splitting and combining GRanges objects

GRanges objects can be divided into groups using the split method. This produces a GRangesList object, a class that will be discussed in detail in the next section. Separate GRanges instances can be concatenated by using the c and append methods.

r
sp <- split(gr, rep(1:2, each=5))
sp
r
## GRangesList object of length 2:
## $`1`
## GRanges object with 5 ranges and 2 metadata columns:
##     seqnames    ranges strand |     score        GC
##        <Rle> <IRanges>  <Rle> | <integer> <numeric>
##   a     chr1   101-111      - |         1  1.000000
##   b     chr2   102-112      + |         2  0.888889
##   c     chr2   103-113      + |         3  0.777778
##   d     chr2   104-114      * |         4  0.666667
##   e     chr1   105-115      * |         5  0.555556
##   -------
##   seqinfo: 3 sequences from an unspecified genome
## 
## $`2`
## GRanges object with 5 ranges and 2 metadata columns:
##     seqnames    ranges strand |     score        GC
##        <Rle> <IRanges>  <Rle> | <integer> <numeric>
##   f     chr1   106-116      + |         6  0.444444
##   g     chr3   107-117      + |         7  0.333333
##   h     chr3   108-118      + |         8  0.222222
##   i     chr3   109-119      - |         9  0.111111
##   j     chr3   110-120      - |        10  0.000000
##   -------
##   seqinfo: 3 sequences from an unspecified genome

2.2 Subsetting GRanges objects

GRanges objects act like vectors of ranges, with the expected vector-like subsetting operations available A second argument to the [ subset operator can be used to specify which metadata columns to extract from the GRanges object. For example, Elements can also be assigned to the GRanges object. Here is an example where the second row of a GRanges object is replaced with the first row of gr . There are methods to repeat, reverse, or select specific portions of GRanges objects.

r
gr[2:3]
r
## GRanges object with 2 ranges and 2 metadata columns:
##     seqnames    ranges strand |     score        GC
##        <Rle> <IRanges>  <Rle> | <integer> <numeric>
##   b     chr2   102-112      + |         2  0.888889
##   c     chr2   103-113      + |         3  0.777778
##   -------
##   seqinfo: 3 sequences from an unspecified genome

2.3 Basic interval operations for GRanges objects

Basic interval characteristics of GRanges objects can be extracted using the start , end , width , and range methods. The GRanges class also has many methods for manipulating the ranges. The methods can be classified as intra-range methods , inter-range methods , and between-range methods . Intra-range methods operate on each element of a GRanges object independent of the other ranges in the object. For example, the flank method can be used to recover regions flanking the set of ranges represented by the GRanges object. So to get a GRanges object containing the ranges that include the 10 bases upstream of the ranges: And to include the downstream bases: Other examples of intra-range methods include resize and shift . The shift method will move the ranges by a specific number of base pairs

r
g <- gr[1:3]
g <- append(g, singles[[10]])
start(g)
r
## [1] 101 102 103 110

2.4 Interval set operations for GRanges objects

Between-range methods calculate relationships between different GRanges objects. Of central importance are findOverlaps and related operations; these are discussed below. Additional operations treat GRanges as mathematical sets of coordinates; union(g, g2) is the union of the coordinates in g and g2 . Here are examples for calculating the union , the intersect and the asymmetric difference (using setdiff ). Related methods are available when the structure of the GRanges objects are âparallelâ to one another, i.e., element 1 of object 1 is related to element 1 of object 2, and so on. These operations all begin with a p , which is short for parallel. The methods then perform element-wise, e.g., the union of element 1 of object 1 with element 1 of object 2, etc. A requirement for these o

r
g2 <- head(gr, n=2)
union(g, g2)
r
## GRanges object with 3 ranges and 0 metadata columns:
##       seqnames    ranges strand
##          <Rle> <IRanges>  <Rle>
##   [1]     chr1   101-111      -
##   [2]     chr2   102-113      +
##   [3]     chr3   110-120      -
##   -------
##   seqinfo: 3 sequences from an unspecified genome

3 GRangesList : Groups of Genomic Ranges

Some important genomic features, such as spliced transcripts that are comprised of exons, are inherently compound structures. Such a feature makes much more sense when expressed as a compound object such as a GRangesList . Whenever genomic features consist of multiple ranges that are grouped by a parent feature, they can be represented as a GRangesList object. Consider the simple example of the two transcript GRangesList below created using the GRangesList constructor. The show method for a GRangesList object displays it as a named list of GRanges objects, where the names of this list are considered to be the names of the grouping feature. In the example above, the groups of individual exon ranges are represented as separate GRanges objects which are further organized into a list structur

r
gr1 <- GRanges(
    seqnames = "chr2",
    ranges = IRanges(103, 106),
    strand = "+",
    score = 5L, GC = 0.45)
gr2 <- GRanges(
    seqnames = c("chr1", "chr1"),
    ranges = IRanges(c(107, 113), width = 3),
    strand = c("+", "-"),
    score = 3:4, GC = c(0.3, 0.5))
grl <- GRangesList("txA" = gr1, "txB" = gr2)
grl
r
## GRangesList object of length 2:
## $txA
## GRanges object with 1 range and 2 metadata columns:
##       seqnames    ranges strand |     score        GC
##          <Rle> <IRanges>  <Rle> | <integer> <numeric>
##   [1]     chr2   103-106      + |         5      0.45
##   -------
##   seqinfo: 2 sequences from an unspecified genome; no seqlengths
## 
## $txB
## GRanges object with 2 ranges and 2 metadata columns:
##       seqnames    ranges strand |     score        GC
##          <Rle> <IRanges>  <Rle> | <integer> <numeric>
##   [1]     chr1   107-109      + |         3       0.3
##   [2]     chr1   113-115      - |         4       0.5
##   -------
##   seqinfo: 2 sequences from an unspecified genome; no seqlengths

Resources



Run this on BioMate

This skill is the knowledge layer — when, why, and how to use genomicranges. To run this analysis on your own data with managed compute, automated QC, and reproducible outputs, use BioMate — free to start.

▶ Open genomicranges on BioMate →

Heefeg gestallte Froen

Wat mécht de KI-Skill Bioconductor Genomicranges?

D'Fäegkeet, genomesch Annotatiounen an Alignementer effizient duerzestellen an ze manipuléieren, spillt eng zentral Roll bei der Analyse vun Héichduerchsaz-Sequenzéierungsdaten (och NGS-Daten genannt). De GenomicRanges-Package definéiert allgemeng Zwecker

Firwat Bioconductor Genomicranges op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Bioconductor Genomicranges besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt, amplaz en Abonnement pro Benotzerplaz ze bezuelen. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Bioconductor Genomicranges an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/bioMate-AI/biomate-bioconductor-kb/tree/main/skills/genomics/genomicranges an. TypingMind liest d'Datei SKILL.md an installéiert de Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Bioconductor Genomicranges benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Bioconductor Genomicranges benotzen?

Esou vill wéi Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Bioconductor Genomicranges domat benotzen – zum Beispill mat GPT, Claude, Gemini, Grok, DeepSeek, Mistral oder Llama – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Bioconductor Genomicranges gratis?

bioMate-AI huet de Skill op GitHub publizéiert. Kuckt am Repository no de Lizenzbedéngungen. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbare Pak vun Instruktiounen, deen engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt e maache soll a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a kee Lafzäitëmfeld a funktionéiere mat all Modell.

Alleguer weisen

Elo Ären eegene KI-Aarbechtsberäich ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇