Last data update: 2014.03.03

R: Visualise reads aligned to genome intervals
plotAlignedR Documentation

Visualise reads aligned to genome intervals

Description

Visualise reads aligned to genome intervals

Usage

plotAligned(x, y, chr, start, end, plus.col = "#00441b",
   minus.col = "#283d78", gff, featureLegend = FALSE,
   gffChrColumn = "seq_name", gffTypeColumn="type",
   gffNameColumn="ID",
   featureExclude = c("chromosome", "nucleotide_match", "insertion"),
   showStrands="both", extraColors=NULL, ylim, highlight, main, ...)

Arguments

x

Object of class AlignedGenomeIntervals

y

This argument is only specified for compatibility with plot.default and not used in the function.

chr

string; on which chromosome is the region to plot

start

integer; start coordinate of the chromosome region to plot

end

integer; end coordinate of the chromosome region to plot

plus.col

which colour to use for the reads on the Plus strand

minus.col

which colour to use for the reads on the Plus strand

gff

Data frame containing annotation for genomic feature to be used to further annotate the plot. Note that it must include a column called “type” that indicates the type of each genomic feature (e.g. miRNA, gene etc.).

featureLegend

logical; should a legend that describes the colour code for the annotated genome features be appended at the bottom of the plot?

gffChrColumn

string; which column of the gff data.frame holds the chromosome identifier of each feature.

gffTypeColumn

string; which column of the gff data.frame holds the type/class identifier of each feature. Used for the colouring of features.

gffNameColumn

what is the column of the gff data.frame called that holds the identifier of the element that should be displayed in the plot; default: “name”

featureExclude

character; which kinds of annotated genome features specified in the gff are to be ignored for the plot

showStrands

string; which strands to show in the plot; defaults to “both”, but users can specify to show only the reads on “plus” or “minus” strand

extraColors

named character vector which allows the user to specify custom colours for feature types; colours must be specified in RGB format as hexadecimal strings starting with “#”, e.g. “#addfff” for light-blue

ylim

range of read numbers to plot (y-axis limits); if not specified they are computed from the data in the specified region

highlight

currently unused

main

string; main title to use for the plot

...

further arguments passed on to the more primitive plotting functions used

Details

This function implements the plot method for objects of class AlignedGenomeIntervals.

Value

Returns NULL; this function is called for the side-effect of creating the plot.

Note

This function was inspired by and borrows source code from the function plotAlongChrom in package tilingArray

Author(s)

Joern Toedling, Wolfgang Huber

See Also

AlignedGenomeIntervals-class

Examples

  A <- AlignedGenomeIntervals(
        start=c(1,8,10,20), end=c(5,15,16,25),
        chromosome=rep("chr1", each=4),
        strand=c("+","+","+","+"),
        sequence=c("ACATT","TATCGGAC","TCGGACT","GTAACG"),
        reads=c(5L, 2L, 4L, 7L) )
  M2 <- new("Genome_intervals_stranded",
            rbind(c(2,6), c(1,15), c(20,30)),
            closed = matrix(TRUE, ncol=2, nrow=3),
            annotation = data.frame(
              seq_name= factor(rep("chr1", 3)),
              inter_base= logical(3),
              strand=factor(rep("+", 3), levels=c("+","-")),
              alias=c("miRNA1","gene1","tRNA1"),
              type=c("miRNA","gene","tRNA")) )
  if (interactive())
    plot(A, M2, chr="chr1", start=0, end=35,
         nameColum="alias", showStrands="plus")

  if (interactive())
  ## use 'extraColors' to replace default colours (or to add new ones):
    plot(A, M2, chr="chr1", start=0, end=35, nameColum="alias",
         showStrands="plus", extraColors=c("tRNA"="#6666DD"))

  ## See also the examples in the vignette and on the manual page
  ##  of the class 'AlignedGenomeIntervals'

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(girafe)
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: Rsamtools
Loading required package: GenomeInfoDb
Loading required package: IRanges
Loading required package: GenomicRanges
Loading required package: Biostrings
Loading required package: XVector
Loading required package: intervals

Attaching package: 'intervals'

The following object is masked from 'package:Biostrings':

    type

The following object is masked from 'package:GenomicRanges':

    reduce

The following object is masked from 'package:IRanges':

    reduce

The following object is masked from 'package:S4Vectors':

    expand

Loading required package: ShortRead
Loading required package: BiocParallel
Loading required package: GenomicAlignments
Loading required package: SummarizedExperiment
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: genomeIntervals
Loading required package: grid
No methods found in "IRanges" for requests: sort
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/girafe/plotAligned.Rd_%03d_medium.png", width=480, height=480)
> ### Name: plotAligned
> ### Title: Visualise reads aligned to genome intervals
> ### Aliases: plotAligned
> ### Keywords: internal hplot
> 
> ### ** Examples
> 
>   A <- AlignedGenomeIntervals(
+         start=c(1,8,10,20), end=c(5,15,16,25),
+         chromosome=rep("chr1", each=4),
+         strand=c("+","+","+","+"),
+         sequence=c("ACATT","TATCGGAC","TCGGACT","GTAACG"),
+         reads=c(5L, 2L, 4L, 7L) )
>   M2 <- new("Genome_intervals_stranded",
+             rbind(c(2,6), c(1,15), c(20,30)),
+             closed = matrix(TRUE, ncol=2, nrow=3),
+             annotation = data.frame(
+               seq_name= factor(rep("chr1", 3)),
+               inter_base= logical(3),
+               strand=factor(rep("+", 3), levels=c("+","-")),
+               alias=c("miRNA1","gene1","tRNA1"),
+               type=c("miRNA","gene","tRNA")) )
> #  if (interactive())
>     plot(A, M2, chr="chr1", start=0, end=35,
+          nameColum="alias", showStrands="plus")
> 
> #  if (interactive())
>   ## use 'extraColors' to replace default colours (or to add new ones):
>     plot(A, M2, chr="chr1", start=0, end=35, nameColum="alias",
+          showStrands="plus", extraColors=c("tRNA"="#6666DD"))
> 
>   ## See also the examples in the vignette and on the manual page
>   ##  of the class 'AlignedGenomeIntervals'
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>