Converts transcript-relative coordinates to positions within the CDS (if the transcript encodes a protein).

transcriptToCds(x, db, id = "name")

Arguments

x

IRanges with the coordinates within the transcript. Coordinates are expected to be relative to the transcription start (the first nucleotide of the transcript). The Ensembl IDs of the corresponding transcripts have to be provided either as names of the IRanges, or in one of its metadata columns.

db

EnsDb object.

id

character(1) specifying where the transcript identifier can be found. Has to be either "name" or one of colnames(mcols(prng)).

Value

IRanges with the same length (and order) than the input IRanges

x. Each element in IRanges provides the coordinates within the transcripts CDS. The transcript-relative coordinates are provided as metadata columns. IRanges with a start coordinate of -1 is returned for transcripts that are not known in the database, non-coding transcripts or if the provided start and/or end coordinates are not within the coding region.

Author

Johannes Rainer

Examples


library(EnsDb.Hsapiens.v86)
## Defining transcript-relative coordinates for 4 transcripts of the gene
## BCL2
txcoords <- IRanges(start = c(1463, 3, 143, 147), width = 1,
    names = c("ENST00000398117", "ENST00000333681",
    "ENST00000590515", "ENST00000589955"))

## Map the coordinates.
transcriptToCds(txcoords, EnsDb.Hsapiens.v86)
#> Warning: 1 of 4 transcript(s) are non-coding: ENST00000590515
#> Warning: Coordinates for 1 of 4 transcript(s) are not in the coding region: ENST00000333681
#> IRanges object with 4 ranges and 2 metadata columns:
#>                       start       end     width |  tx_start    tx_end
#>                   <integer> <integer> <integer> | <integer> <integer>
#>   ENST00000398117         1         1         1 |      1463      1463
#>   ENST00000333681        -1        -1         1 |         3         3
#>   ENST00000590515        -1        -1         1 |       143       143
#>   ENST00000589955         1         1         1 |       147       147

## ENST00000590515 does not encode a protein and thus -1 is returned
## The coordinates within ENST00000333681 are outside the CDS and thus also
## -1 is reported.