matchChromosomes: Match seqlevels of input GRanges to reference GRanges or...

View source: R/matchChromosomes.R

matchChromosomesR Documentation

Match seqlevels of input GRanges to reference GRanges or BioString objects

Description

A convenient wrapper to match seqlevels of a query GRanges object to a reference object that contain seqlevels information. Reference can be a GRanges, GRangesList, BioString or DNAString object. Seqlevels which fail to match will be dropped.

Usage

matchChromosomes(x, to)

Arguments

x

GRanges object with seqnames to change

to

GRanges object from which seqnames is referenced

Value

Corrected input GRanges

Author(s)

Fursham Hamid

Examples

## ---------------------------------------------------------------------
## EXAMPLE USING TOY DATASET
## ---------------------------------------------------------------------
require(GenomicRanges)

## Create toy GRanges objects
gr1 <- GRanges("1", IRanges(start = c(1, 101), width = c(20, 20)), "+")
gr2 <- GRanges("chr1", IRanges(start = c(1, 101), width = c(20, 20)), "+")

## Match Ensembl-style chromosomes from gr1 to UCSC-style gr2
matchChromosomes(gr1, gr2)

## Possible to match chrosomomes from GRanges object to a Biostrings 
#    object containing seqlevels
x0 <- c("chr2" = "CTCACCAGTAT", "chr3" = "TGTCAGTCGA")
dna <- Biostrings::DNAStringSet(x0)

## Match gr1 to dna
matchChromosomes(gr1, dna)

fursham-h/factR documentation built on Aug. 20, 2023, 1:58 p.m.