R: Plot nucleotide sequence coloured by covariance
Covariation Plots
R Documentation
Plot nucleotide sequence coloured by covariance
Description
Given a multiple sequence alignment and a corresponding secondary structure,
nucleotides in the sequence alignment will be coloured according to the
basepairing and conservation status, where green is the most commonly
observed valid basepair in the column, dark blue being valid covariation
(i.e. mutation into another valid basepair), cyan is one-sided mutation that
retains the basepair, and red is a mutation where the basepair has been
lost.
A multiple sequence alignment. Can be either a BiostringsXStringSet object or a named array of strings like ones obtained
from converting XStringSet with as.character.
top.msa and bot.msa are specific to top.helix and
bot.helix respectively, and may be set to NA to have no
multiple sequence alignment at all.
A helix data.frame with a structure corresponding to msa,
See plotDoubleHelix and plotOverlapHelix for
detailed explanations of top.helix, bot.helix,
predict.helix, and known.helix.
arcs
TRUE if the structure should be plotted as arcs. Arcs may be styled
with styling columns, see example and plotHelix for
details.
add
TRUE if graphical elements are to be added to an existing device, else
a new plotting device is created with blankPlot.
grid
TRUE if the multiple sequence alignment is to be drawn as a grid of
bases, else the multiple sequence alignment is drawn as equidistant
horizontal lines.
text
Only applicable when grid is TRUE. TRUE if the grid is to be filled
with nucleotide character.
legend
TRUE if legend are to be shown.
species
If a number greater than 0 is given, then species names for
the multiple sequence alignment will be printed along the left side.
This name is typically the entire header lines of FASTA entries. The
number specifies the start position relative to the left edge of the
multiple sequence alignment).
base.colour
TRUE if bases are to be coloured by nucleotide instead of basepair
conservation.
palette
A list of colour names to override the default colour palette. When
base.colour is TRUE, the first 6 colours will be used for colouring
bases A, U, G, C, - (gap), and ? (everything else), respectively. When
base.colour is FALSE, the first 7 colours will be used for colouring
conserved basepairs, covarying basepairs, one-sided conserved basepairs,
invalid basepairs, unpaired bases, gaps, and bases/pairs with ambiguous
bases, resepctively. If the palette is shorter than the expected
length, the palette will simply cycle. “NA” is a valid colour,
that will effectively plot nothing.
flip
If TRUE, the entire plot will be flipped upside down. Note that this
is not a perfect mirror image about the horizon.
grid.col, grid.lwd
The colour and line width of the borders displayed when grid is
TRUE.
text.cex, text.col, text.font, text.family
cex, col, family and font for the text displayed via the text
option. Use help("par") for more information the paramters.
cex, col, family and font for the species text displayed via the
species option. Use help("par") for more information the
paramters.
shape
One of "circle", "triangle", or "square", specifying the shape of
the arcs.
conflict.lty, conflict.col, conflict.cutoff
Determines the line type (style) and colour to be used for conflicting
basepairs. By default, conflicting helices are drawn as dotted lines
(lty = 2) and whatever colour was originally assigned to it
(col = NA). Conflicting helices may be coloured by setting
conflict.col to some R-compatible colour name. If both arguments
are set to NA, then no attempt to exclude conflicting helices
will be made when colouring covariance plot columns, which in most cases
will render the plot nonsensical. When the input has helices with
multiple basepairs, and only part of the helix is conflicting, the
conflict.cutoff determines above what percentage of basepairs
have to be conflicting before a helix is considered conflicting, with the
default set at 1
conflicting).
miss
The colour for unpredicted arcs in overlapping diagrams, see
plotOverlapHelix for more information.
overlap.cutoff
Decimal between 0 and 1 indicating the percentage of basepairs within a helix
that have to be overlapping for the entire helix to count as overlapping.
Default is 1, or 100
pad
A four integer array passed to blankPlot, specifies the
number of pixels to pad the bottom, left, top and right sides of the
figure with, repsectively.
x, y
Coordinates for the left bottom corner of the plot. Useful for manually
positioning and overlapping figure elements.
...
In plotCovariance, these are additional arguments passed to
blankPlot, useful arguments include ‘lwd’,
‘col’, ‘cex’ for line width, line colour, and text size,
respectively. help('par') for more.
For plotDoubleCovariance and plotOverlapCovariance, these
are additional arguments passed to plotCovariance (and thus
indirectly also to blankPlot).
Value
Not intended to return a value, will plot to GUI or file if specific.
Author(s)
Daniel Lai
See Also
plotHelix
plotDoubleHelix
plotOverlapHelix
colourByCovariation
colourByConservation
colourByCanonical
Examples
data(helix)
# Basic covariance plot
plotCovariance(fasta, known, cex = 0.8, lwd = 1.5)
# Grid mode
plotCovariance(fasta, known, grid = TRUE, text = FALSE, cex = 0.8)
# Global style and nucleotide colouring
plotCovariance(fasta, known, grid = TRUE, text = FALSE, base.colour = TRUE)
# Styling indivual helices with styling columns
known$col <- c("red", "blue")
plotCovariance(fasta, known, lwd = 2, cex = 0.8)
# Use in combination with colourBy functions
cov <- colourByCovariation(known, fasta, get = TRUE)
plotCovariance(fasta, cov)
legend("topleft", legend = attr(cov, "legend"),
fill = attr(cov, "fill"), title = "Covariation")
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(R4RNA)
Loading required package: Biostrings
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: XVector
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/R4RNA/plotCovariance.Rd_%03d_medium.png", width=480, height=480)
> ### Name: Covariation Plots
> ### Title: Plot nucleotide sequence coloured by covariance
> ### Aliases: plotCovariance plotDoubleCovariance plotOverlapCovariance
> ### Keywords: aplot
>
> ### ** Examples
>
> data(helix)
>
> # Basic covariance plot
> plotCovariance(fasta, known, cex = 0.8, lwd = 1.5)
>
> # Grid mode
> plotCovariance(fasta, known, grid = TRUE, text = FALSE, cex = 0.8)
>
> # Global style and nucleotide colouring
> plotCovariance(fasta, known, grid = TRUE, text = FALSE, base.colour = TRUE)
>
> # Styling indivual helices with styling columns
> known$col <- c("red", "blue")
> plotCovariance(fasta, known, lwd = 2, cex = 0.8)
>
> # Use in combination with colourBy functions
> cov <- colourByCovariation(known, fasta, get = TRUE)
> plotCovariance(fasta, cov)
> legend("topleft", legend = attr(cov, "legend"),
+ fill = attr(cov, "fill"), title = "Covariation")
>
>
>
>
>
>
> dev.off()
null device
1
>