plot.ngs: Plotting BAM file data alongside the features of a chromosome

Description Usage Arguments Details Author(s) See Also

Description

These functions aid plotting a-la xmapbridge but in a format that is more publication friendly

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
  # 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, ... )

Arguments

bam.file.name

The name of the BAM file to read in

chr

The chromosome of interest.

start

The start of the region of interest

end

The end of the region of interest

chr.name.mapping

The function to convert between the Annmap chr name to the chr name in the BAM file. By default, this just uses chr supplied as the parameter, however it can be set to any function you like. One example of this is generalisedNameToNCBI

xrange

The genomic range for the x-axis. Should be a GRanges object.

bamFiles

A vector containing the filenames of your BAM files.

colours

A vector of colours for each file (sensible defaults will be chosen if NULL).

names

A vector of names to show on the traces drawn by ngsTracePlotter

vector.of.xbams.and.ybams

The trace.scale function is passes a vector of the elements of xbams and ybams concatenated together.

rle.data

A list containing fields rle (the Rle data to be plotted), name (the name of the Trace) and col (the colour for the trace).

ylim

A vector of min and max values for this plot (usually retrieved from ngs.trace.scale)

trace.label.properties

Properties to be sent to the grid.text call for plotting the label on the trace. To hide the label, this should be NA.

smoothing.function

A function that generates a smoothed RLE object.

trace.clip

Is the trace clipped to it's bounding box? One of 'inherit', 'on' or 'off'. See viewport.

trace.draw.scale

If 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.bor

The colour for a box that is drawn round this trace.plot.

trace.pad

A 2 element vector consisting of the number of 'lines' of padding to allow at the top and bottom of the plot respecively

data

A list containing an element per trace. Each element of this list is, in turn, passed to the trace.plotter and trace.scale functions where the plotting happens – see details. )

main

The main title for the plot.

sub

A sub-title for the plot.

highlights

Highlight regions for the plot. See genomicPlot.

trace.plotter

The function to call to draw the traces (see ngsTracePlotter)

genome.layout.weight

The weight for the genomic plot in the layout of this grid

trace.scale

Either a function to calculate the global max for the NGS traces (see ngsTraceScale) OR a 2 element vector cntaining the min and max extent of the trace.

trace.match.strand

If 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).

probe.plot

The function to plot the probes (see genomicProbePlot), NULL if not drawn.

exon.depth.plot

The function to draw the exon depth (see genomicExonDepthPlot), NULL if not drawn.

.genes

Optionally pass a list of genes to limit the plot to.

.exons

An optional list of exons to limit the plot to.

...

Parameters passed on to functions called by this function

Details

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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
    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' )
  

Author(s)

Tim Yates

See Also

genomicProbePlot, genomicPlot, genomicExonDepthPlot


annmap documentation built on Nov. 8, 2020, 7:43 p.m.