Last data update: 2014.03.03

R: Construct a gene-features plot
geneVizR Documentation

Construct a gene-features plot

Description

Given a GRanges object specifying a region of interest, plot genomic features within that region.

Usage

geneViz(txdb, gr, genome, reduce = FALSE, gene_colour = NULL, base = c(10,
  2, 2), transform = c("Intron", "CDS", "UTR"), isoformSel = NULL,
  labelTranscript = TRUE, labelTranscriptSize = 4, plotLayer = NULL)

Arguments

txdb

Object of class TxDb giving transcription meta data for a genome assembly. See Bioconductor annotation packages.

gr

Object of class GRanges specifying the region of interest and corresponding to a single gene. See Bioconductor package GRanges.

genome

Object of class BSgenome specifying the genome sequence of interest. See Bioconductor annotation packages.

reduce

Boolean specifying whether to collapse gene isoforms within the region of interest into one representative transcript. Experimental use with caution!

gene_colour

Character string specifying the colour of the gene to be plotted.

base

Numeric vector of log bases to transform the data corresponding to the elements supplied to the variable transform See details.

transform

Character vector specifying what objects to log transform, accepts "Intron", "CDS", and "UTR" See details.

isoformSel

Character vector specifying the names (from the txdb object) of isoforms within the region of interest to display.

labelTranscript

Boolean specifying whether to plot the transcript names in the gene plot.

labelTranscriptSize

Integer specifying the size of the transcript name text in the gene plot.

plotLayer

Valid ggplot2 layer to be added to the gene plot.

Details

geneViz is an internal function which will output a list of three elements. As a convenience the function is exported however to obtain the plot from geneViz the user must call the first element of the list. geneViz is intended to plot gene features within a single gene with boundaries specified by the GRanges object, plotting more that one gene is advised against.

Typically, introns of a transcript are much larger than exons, while exons are sometimes of greater interest. To address this, genCov will by default scale the x-axis to expand track information according to region type: coding sequence (CDS), untranslated region (UTR), or intron / intergenic (Intron). The amount by which each region is scaled is controlled by the 'base' and 'transform' arguments. 'transform' specifies which regions to scale, and 'base' corresponds to the log base transform to apply to those regions. To keep one or more region types from being scaled, omit the corresponding entries from the 'base' and 'transform' vectors.

Value

object of class list with list elements containing a ggplot object, the gene features within the plot as a data frame, and mapping information of the gene features within the ggplot object.

Examples

# need transcript data for reference
library(TxDb.Hsapiens.UCSC.hg19.knownGene)
txdb <- TxDb.Hsapiens.UCSC.hg19.knownGene

# need a biostrings object for reference
library(BSgenome.Hsapiens.UCSC.hg19)
genome <- BSgenome.Hsapiens.UCSC.hg19

# need Granges object
gr <- GRanges(seqnames=c("chr10"),
ranges=IRanges(start=c(89622195), end=c(89729532)), strand=strand(c("+")))

# Plot the graphic
geneViz(txdb, gr, genome)

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(GenVisR)
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/GenVisR/geneViz.Rd_%03d_medium.png", width=480, height=480)
> ### Name: geneViz
> ### Title: Construct a gene-features plot
> ### Aliases: geneViz
> 
> ### ** Examples
> 
> # need transcript data for reference
> library(TxDb.Hsapiens.UCSC.hg19.knownGene)
Loading required package: GenomicFeatures
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: S4Vectors
Loading required package: stats4

Attaching package: 'S4Vectors'

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

    colMeans, colSums, expand.grid, rowMeans, rowSums

Loading required package: IRanges
Loading required package: GenomeInfoDb
Loading required package: GenomicRanges
Loading required package: AnnotationDbi
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")'.

> txdb <- TxDb.Hsapiens.UCSC.hg19.knownGene
> 
> # need a biostrings object for reference
> library(BSgenome.Hsapiens.UCSC.hg19)
Loading required package: BSgenome
Loading required package: Biostrings
Loading required package: XVector
Loading required package: rtracklayer
> genome <- BSgenome.Hsapiens.UCSC.hg19
> 
> # need Granges object
> gr <- GRanges(seqnames=c("chr10"),
+ ranges=IRanges(start=c(89622195), end=c(89729532)), strand=strand(c("+")))
> 
> # Plot the graphic
> geneViz(txdb, gr, genome)
Obtaining CDS Coordinates
'select()' returned 1:many mapping between keys and columns
Obtaining UTR Coordinates
'select()' returned 1:many mapping between keys and columns
Calculating transform
$plot

$features
             start       end        GC width Type Upper Lower Mid segStart
38563.1   13.39821  19.70199 0.4050633    79  CDS   1.0  -1.0 0.0  4.00000
38563.2   24.17146  30.58085 0.3411765    85  CDS   1.0  -1.0 0.0  4.00000
38563.3   35.07782  40.56967 0.2666667    45  CDS   1.0  -1.0 0.0  4.00000
38563.4   44.30909  49.76852 0.3863636    44  CDS   1.0  -1.0 0.0  4.00000
38563.5   53.05250  60.95336 0.4016736   239  CDS   1.0  -1.0 0.0  4.00000
38563.6   90.17269  97.32244 0.4014085   142  CDS   1.0  -1.0 0.0  4.00000
38563.7  101.07008 108.45379 0.4371257   167  CDS   1.0  -1.0 0.0  4.00000
38563.8  111.91227 119.72606 0.3377778   225  CDS   1.0  -1.0 0.0  4.00000
38563.9  123.34598 130.88514 0.3978495   186  CDS   1.0  -1.0 0.0  4.00000
38563.10   4.00000  13.39821 0.7160853  1032  UTR   0.5  -0.5 0.0  4.00000
38563.11 130.88514 142.02635 0.3345444  3303  UTR   0.5  -0.5 0.0  4.00000
38564.1    4.00000  19.70199 0.6939694  1111  UTR   2.7   1.7 2.2  4.00000
38564.2   24.17146  30.58085 0.3411765    85  UTR   2.7   1.7 2.2  4.00000
38564.3   44.30909  49.76852 0.3863636    44  UTR   2.7   1.7 2.2  4.00000
38564.4   53.05250  60.95336 0.4016736   239  UTR   2.7   1.7 2.2  4.00000
38564.5   64.92459  72.23748 0.4528302   159  UTR   2.7   1.7 2.2  4.00000
38564.6   90.17269  97.32244 0.4014085   142  UTR   2.7   1.7 2.2  4.00000
38564.7  101.07008 108.45379 0.4371257   167  UTR   2.7   1.7 2.2  4.00000
38564.8  111.91227 119.72606 0.3377778   225  UTR   2.7   1.7 2.2  4.00000
38564.9  123.34598 142.02635 0.3379192  3489  UTR   2.7   1.7 2.2  4.00000
38565     75.88073  86.67026 0.4011299  1770  UTR   4.9   3.9 4.4 75.88073
            segEnd     txname
38563.1  142.02635 uc001kfb.3
38563.2  142.02635 uc001kfb.3
38563.3  142.02635 uc001kfb.3
38563.4  142.02635 uc001kfb.3
38563.5  142.02635 uc001kfb.3
38563.6  142.02635 uc001kfb.3
38563.7  142.02635 uc001kfb.3
38563.8  142.02635 uc001kfb.3
38563.9  142.02635 uc001kfb.3
38563.10 142.02635 uc001kfb.3
38563.11 142.02635 uc001kfb.3
38564.1  142.02635 uc021pvw.1
38564.2  142.02635 uc021pvw.1
38564.3  142.02635 uc021pvw.1
38564.4  142.02635 uc021pvw.1
38564.5  142.02635 uc021pvw.1
38564.6  142.02635 uc021pvw.1
38564.7  142.02635 uc021pvw.1
38564.8  142.02635 uc021pvw.1
38564.9  142.02635 uc021pvw.1
38565     86.67026 uc001kfc.1

$master
              start      end     width   Type width.init trans_start trans_end
38563.1011 89622195 89623194  3.000000 Intron       1000     1.00000   4.00000
38563.10   89623195 89624226  9.398207    UTR       1111     4.00000  13.39821
38563.1    89624227 89624305  6.303781    CDS         79    13.39821  19.70199
38563.101  89624306 89653781  4.469469 Intron      29476    19.70199  24.17146
38563.2    89653782 89653866  6.409391    CDS         85    24.17146  30.58085
38564.2    89653867 89653866  0.000000    UTR         85    30.58085  30.58085
38563.102  89653867 89685269  4.496971 Intron      31403    30.58085  35.07782
38563.3    89685270 89685314  5.491853    CDS         45    35.07782  40.56967
38563.103  89685315 89690802  3.739414 Intron       5488    40.56967  44.30909
38563.4    89690803 89690846  5.459432    CDS         44    44.30909  49.76852
38564.3    89690847 89690846  0.000000    UTR         44    49.76852  49.76852
38563.104  89690847 89692769  3.283979 Intron       1923    49.76852  53.05250
38563.5    89692770 89693008  7.900867    CDS        239    53.05250  60.95336
38564.4    89693009 89693008  0.000000    UTR        239    60.95336  60.95336
38563.105  89693009 89702367  3.971229 Intron       9359    60.95336  64.92459
38564.5    89702368 89702526  7.312883    UTR        159    64.92459  72.23748
38563.106  89702527 89706924  3.643255 Intron       4398    72.23748  75.88073
38565      89706925 89708694 10.789534    UTR       1770    75.88073  86.67026
38563.107  89708695 89711874  3.502427 Intron       3180    86.67026  90.17269
38563.6    89711875 89712016  7.149747    CDS        142    90.17269  97.32244
38564.6    89712017 89712016  0.000000    UTR        142    97.32244  97.32244
38563.108  89712017 89717609  3.747645 Intron       5593    97.32244 101.07008
38563.7    89717610 89717776  7.383704    CDS        167   101.07008 108.45379
38564.7    89717777 89717776  0.000000    UTR        167   108.45379 108.45379
38563.109  89717777 89720650  3.458487 Intron       2874   108.45379 111.91227
38563.8    89720651 89720875  7.813781    CDS        225   111.91227 119.72606
38564.8    89720876 89720875  0.000000    UTR        225   119.72606 119.72606
38563.1010 89720876 89725043  3.619928 Intron       4168   119.72606 123.34598
38563.9    89725044 89725229  7.539159    CDS        186   123.34598 130.88514
38564.9    89725230 89728532 11.141209    UTR       3489   130.88514 142.02635
38563.1012 89728533 89729532  3.000000 Intron       1000   142.02635 145.02635
              c.ratio
38563.1011  41.359330
38563.10    14.667761
38563.1      1.554965
38563.101  818.290325
38563.2      1.645496
38564.2           Inf
38563.102  866.454563
38563.3      1.016690
38563.103  182.098050
38563.4      1.000000
38564.3           Inf
38563.104   72.656359
38563.5      3.753340
38564.4           Inf
38563.105  292.414713
38564.5      2.697760
38563.106  149.782261
38565       20.354730
38563.107  112.655595
38563.6      2.464293
38564.6           Inf
38563.108  185.174487
38563.7      2.806318
38564.7           Inf
38563.109  103.108721
38563.8      3.572860
38564.8           Inf
38563.1010 142.863921
38563.9      3.061151
38564.9     38.856475
38563.1012  41.359330

> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>