# Utility Methods convertBamToRle( bam.file.name, chr, start, end, chr.name.mapping=function( name ){ name } ) generateBridgeData( xrange, bamFiles, colours=NULL, names=NULL ) ngsTraceScale( vector.of.xbams.and.ybams ) ngsTraceLabel( rle.data ) ngsTracePlotter( rle.data, start, end, ylim, trace.label.properties=list(), smoothing.function=function( rle, ... ) { IRanges::runmean( rle, k=1001, endrule='constant' ) }, trace.clip='inherit', trace.draw.scale=FALSE, trace.bor='transparent', trace.pad=c(0,0), ... )
# Plotting Methods ngsBridgePlot( xrange, data=list(), main=NULL, sub=NULL, highlights=NULL, trace.plotter=ngsTracePlotter, genome.layout.weight=4, trace.scale=ngsTraceScale, trace.draw.scale=NULL, trace.match.strand=TRUE, probe.plot=NULL, exon.depth.plot=genomicExonDepthPlot, .genes=NULL, .exons=NULL, ... )generalisedNameToNCBI ngsTracePlotter trace.scale function is passes a vector of the elements of xbams and ybams concatenated together. rle (the Rle data to be plotted), name (the name of the Trace) and col (the colour for the trace). ngs.trace.scale) grid.text call for plotting the label on the trace. To hide the label, this should be NA. 'inherit', 'on' or 'off'. See viewport. TRUE, x and y scales are drawn with main=TRUE (see grid.xaxis and grid.yaxis), if FALSE, then neither axis is drawn. You can control individual axis drawing by passing a vector such as trace.draw.scale='x' to just draw the x axis. You can also pass a list such as trace.draw.scale=list(x=TRUE,y=FALSE), and this will draw both the x and y axis, but pass main=TRUE to the grid.xaxis call, and main=FALSE to grid.yaxis trace.plotter and trace.scale functions where the plotting happens -- see details. ) genomicPlot. ngsTracePlotter) ngsTraceScale) OR a 2 element vector cntaining the min and max extent of the trace. TRUE, we will only draw the rle data from the strand defined in xrange. If false, we will draw all of the rle data. Can also be set to '+' or '-' to only draw the trace from the given strand (ignoring the strand of xrange). genomicProbePlot), NULL if not drawn. genomicExonDepthPlot), NULL if not drawn. convertBamToRle will take a BAM file name, and a region of interest and return a list() containing two elements, '+' and '-'. Each element will be an Rle object, one for each strand. The data parameter to ngsBridgePlot is a list of elements as defined in the rle.data parameter, one element per NGS trace, ie:
library(grid)
library(annmap)# Connect to datasource with annmapConnect()
# Ensure we have a clean plot grid.newpage()
bamFiles = c( 'data1.bam', 'data2.bam', 'data3.bam' ) colours = rainbow( 3, v=0.5, s=0.5 ) data = lapply( seq_along( bamFiles ), function( idx ) { list( rle=convertBamToRle( bamFiles[ idx ], 'I', 40000, 100000 ), col=colours[ idx ], name=paste( 'Trace', bamFiles[ idx ] ) ) } ) ngsBridgePlot( RangedData( space='I', ranges=IRanges( 40000, 100000 ) ), data=data, main='Example Plot' )
genomicProbePlot, genomicPlot, genomicExonDepthPlot