Last data update: 2014.03.03

R: Map range coordinates between transcripts and genome space
mapToTranscriptsR Documentation

Map range coordinates between transcripts and genome space

Description

Map range coordinates between features in the transcriptome and genome (reference) space.

See ?mapToAlignments in the GenomicAlignments package for mapping coordinates between reads (local) and genome (reference) space using a CIGAR alignment.

Usage

## S4 method for signature 'ANY,MultiDb'
mapToTranscripts(x, transcripts,
          ignore.strand = TRUE,
          extractor.fun = GenomicFeatures::transcripts, ...) 

Arguments

x

GRanges-class object of positions to be mapped. x must have names when mapping to the genome.

transcripts

The OrganismDb object that will be used to extract features using the extractor.fun.

ignore.strand

When TRUE, strand is ignored in overlap operations.

extractor.fun

Function to extract genomic features from a TxDb object.

Valid extractor functions:

  • transcripts ## default

  • exons

  • cds

  • genes

  • promoters

  • disjointExons

  • microRNAs

  • tRNAs

  • transcriptsBy

  • exonsBy

  • cdsBy

  • intronsByTranscript

  • fiveUTRsByTranscript

  • threeUTRsByTranscript

...

Additional arguments passed to extractor.fun functions.

Details

  • mapToTranscripts The genomic range in x is mapped to the local position in the transcripts ranges. A successful mapping occurs when x is completely within the transcripts range, equivalent to:

          findOverlaps(..., type="within")
          

    Transcriptome-based coordinates start counting at 1 at the beginning of the transcripts range and return positions where x was aligned. The seqlevels of the return object are taken from the transcripts object and should be transcript names. In this direction, mapping is attempted between all elements of x and all elements of transcripts.

Value

An object the same class as x.

Parallel methods return an object the same shape as x. Ranges that cannot be mapped (out of bounds or strand mismatch) are returned as zero-width ranges starting at 0 with a seqname of "UNMAPPED".

Non-parallel methods return an object that varies in length similar to a Hits object. The result only contains mapped records, strand mismatch and out of bound ranges are not returned. xHits and transcriptsHits metadata columns indicate the elements of x and transcripts used in the mapping.

When present, names from x are propagated to the output. When mapping to transcript coordinates, seqlevels of the output are the names on the transcripts object; most often these will be transcript names. When mapping to the genome, seqlevels of the output are the seqlevels of transcripts which are usually chromosome names.

Author(s)

V. Obenchain, M. Lawrence and H. Pages; ported to work with OrganismDbi by Marc Carlson

See Also

  • mapToTranscripts .

Examples


## ---------------------------------------------------------------------
## A. Basic Use
## ---------------------------------------------------------------------

library(Homo.sapiens)
x <- GRanges("chr5", 
             IRanges(c(173315331,174151575), width=400, 
                     names=LETTERS[1:2])) 

## Map to transcript coordinates:
mapToTranscripts(x, Homo.sapiens)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(OrganismDbi)
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:stats':

    IQR, mad, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, cbind, colnames, do.call, duplicated, eval, evalq,
    get, grep, grepl, intersect, is.unsorted, lapply, lengths, mapply,
    match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank,
    rbind, rownames, sapply, setdiff, sort, table, tapply, union,
    unique, unsplit

Loading required package: AnnotationDbi
Loading required package: stats4
Loading required package: Biobase
Welcome to Bioconductor

    Vignettes contain introductory material; view with
    'browseVignettes()'. To cite Bioconductor, see
    'citation("Biobase")', and for packages 'citation("pkgname")'.

Loading required package: IRanges
Loading required package: S4Vectors

Attaching package: 'S4Vectors'

The following objects are masked from 'package:base':

    colMeans, colSums, expand.grid, rowMeans, rowSums

Loading required package: GenomicFeatures
Loading required package: GenomeInfoDb
Loading required package: GenomicRanges
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/OrganismDbi/coordinate-mapping-method.Rd_%03d_medium.png", width=480, height=480)
> ### Name: mapToTranscripts
> ### Title: Map range coordinates between transcripts and genome space
> ### Aliases: mapToTranscripts,ANY,MultiDb-method
> ### Keywords: methods utilities
> 
> ### ** Examples
> 
> 
> ## ---------------------------------------------------------------------
> ## A. Basic Use
> ## ---------------------------------------------------------------------
> 
> library(Homo.sapiens)
Loading required package: GO.db

Loading required package: org.Hs.eg.db

Loading required package: TxDb.Hsapiens.UCSC.hg19.knownGene
> x <- GRanges("chr5", 
+              IRanges(c(173315331,174151575), width=400, 
+                      names=LETTERS[1:2])) 
> 
> ## Map to transcript coordinates:
> mapToTranscripts(x, Homo.sapiens)
GRanges object with 5 ranges and 2 metadata columns:
    seqnames    ranges strand |     xHits transcriptsHits
       <Rle> <IRanges>  <Rle> | <integer>       <integer>
  A    21822  [1, 400]      * |         1           21822
  A    21823  [1, 400]      * |         1           21823
  A    21824  [1, 400]      * |         1           21824
  A    21825  [1, 400]      * |         1           21825
  B    21832  [1, 400]      * |         2           21832
  -------
  seqinfo: 5 sequences from an unspecified genome; no seqlengths
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>