Last data update: 2014.03.03

R: Plot segmentation result using Gviz
biomvRGvizR Documentation

Plot segmentation result using Gviz

Description

This function could be called to plot segmentation output, together with the input signal and optional annotation. By default resulting image will be printed to file. The plot method for class biomvRCNS-class also calls this method. See the vignette for a more complete example.

Usage

biomvRGviz(exprgr, gmgr = NULL, prange = NULL, regionID = NULL, seggr = NULL, plotstrand = "+", eps = TRUE, tofile = TRUE, ...)

Arguments

exprgr

a GRanges object with one numeric column for the segmentation input signal in its meta DataFrame

gmgr

an optional GRanges object for the annotation, which must have one column named 'TYPE' in its meta DataFrame

prange

an optional vector defining the scope of the plot, the first 3 elements must be formatted as c('seqname', 'start_position', 'end_position')

regionID

a character for the name of the plotted region or gene name or other identifier, will be used in the title of the plot and the output file name

seggr

a GRanges object for the segmentation output, which must have one column named 'STATE' in its meta DataFrame

plotstrand

select which strand to plot, possible values are '+', '-', '*'

eps

whether to output EPS file using postscript, if FALSE then PDF files for each sequence will be generated to the current working folder.

tofile

whether to output graphics file, if FALSE then will plot on the active device and have the trackList returned.

...

other arguments for plot, like main, ylab, cex, or height and width for graphic device.

Details

See the vignette for more details and examples.

Value

Plot graph on the active device or output to EPS/PDF file.

Author(s)

Yang Du

Examples

	data(coriell)
	x<-coriell[coriell[,2]==1,]
	xgr<-GRanges(seqnames=paste('chr', x[,2], sep=''), IRanges(start=x[,3], width=1, names=x[,1]))
	values(xgr)<-DataFrame(x[,4:5], row.names=NULL)
	xgr<-xgr[order(xgr)]

	J<-2; maxk<-50
	# a uniform inital sojourn, not utilizing positional information
	soj<-list(J=J, maxk=maxk, type='gamma', d=cbind(dunif(1:maxk, 1, maxk), dunif(1:maxk, 1, maxk)))
	soj$D <- sapply(1:J, function(j) rev(cumsum(rev(soj$d[1:maxk,j]))))
	sample<-colnames(coriell)[5]
	runout<-hsmmRun(matrix(values(xgr)[,sample]), sample, xgr, soj, emis=list(type='norm', mu=quantile(unlist(x[,sample]), c(0.25, 0.75)), var=rep(var(unlist(x[,sample])), J)))
	biomvRGviz(exprgr=xgr, seggr=runout$res, tofile=FALSE) 
	

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(biomvRCNS)
Loading required package: IRanges
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: GenomicRanges
Loading required package: GenomeInfoDb
Loading required package: Gviz
Loading required package: grid
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/biomvRCNS/biomvRGviz.Rd_%03d_medium.png", width=480, height=480)
> ### Name: biomvRGviz
> ### Title: Plot segmentation result using Gviz
> ### Aliases: biomvRGviz
> 
> ### ** Examples
> 
> 	data(coriell)
> 	x<-coriell[coriell[,2]==1,]
> 	xgr<-GRanges(seqnames=paste('chr', x[,2], sep=''), IRanges(start=x[,3], width=1, names=x[,1]))
> 	values(xgr)<-DataFrame(x[,4:5], row.names=NULL)
> 	xgr<-xgr[order(xgr)]
> 
> 	J<-2; maxk<-50
> 	# a uniform inital sojourn, not utilizing positional information
> 	soj<-list(J=J, maxk=maxk, type='gamma', d=cbind(dunif(1:maxk, 1, maxk), dunif(1:maxk, 1, maxk)))
> 	soj$D <- sapply(1:J, function(j) rev(cumsum(rev(soj$d[1:maxk,j]))))
> 	sample<-colnames(coriell)[5]
> 	runout<-hsmmRun(matrix(values(xgr)[,sample]), sample, xgr, soj, emis=list(type='norm', mu=quantile(unlist(x[,sample]), c(0.25, 0.75)), var=rep(var(unlist(x[,sample])), J)))
[ hsmmRun ] seq 'chr1' column 'Coriell.13330' iteration: 1
> 	biomvRGviz(exprgr=xgr, seggr=runout$res, tofile=FALSE) 
[[1]]
[[1]][[1]]
DataTrack '   '
| genome: NA
| active chromosome: chr1
| positions: 142
| samples:2
| strand: * 

[[1]][[2]]
AnnotationTrack 'Coriell.13330'
| genome: NA
| active chromosome: chr1
| annotation features: 3

[[1]][[3]]
Genome axis 'Axis'
5->3 label is set
3->5 label is set
littleTicks label is set


$`1`
[1] "#FF0000FF"

$`2`
[1] "#00FFFFFF"

$main
[1] "chr1:0-241000@Coriell.05296&Coriell.13330"

$min.distance
[1] 0

$min.width
[1] 0

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