Functions to generate colours for helices by various rules, including
integer counts, value ranges, percent identity covariation, conservation,
percentage canonical basepair, basepair frequency, and non-pseudoknotted
groups.
Usage
colourByCount(helix, cols, counts, get = FALSE)
colourByValue(helix, cols, breaks, get = FALSE,
log = FALSE, include.lowest = TRUE, ...)
colourByBasepairFrequency(helix, cols, get = TRUE)
colourByUnknottedGroups(helix, cols, get = TRUE)
colourByCovariation(helix, msa, cols, get = FALSE)
colourByConservation(helix, msa, cols, get = FALSE)
colourByCanonical(helix, msa, cols, get = FALSE)
defaultPalette()
Arguments
helix
A helix data frame to be coloured.
cols
An array of characters (or numbers) representing a set of colours to
colour helix with. When missing, a default set of colours from
defaultPalette() will be used. Valid input include hex codes, colour
names from the colours function, and integer numbers. The
colours will be interpreted as being from best to worst.
counts
An array of integers the same length as cols, dictating the
number of times each corresponding colour should be used. When missing,
the function will divide the number of helices evenly over each of the
colours available.
breaks
An integer number of intervals to break the ‘value’ column of
helix into, or a list of numbers defining the interval breaks.
If missing, the range of ‘helix$value’ will automatically be
split evenly into intervals for each colour available.
get
If TRUE, returns the input helix with a col column, else
simply returns an array of colours the same length as the number of row
in helix. The exceptions are colourByBasepairFrequency
and colourByUnknottedGroups which will return a different helix
if TRUE, and a list of colours that will not match the input helix if
FALSE.
log
If TRUE, will breaks values into even log10 space intervals, useful
when values are p-values.
include.lowest
Whether the lowest interval should include the lowest value, passed to
cut
...
Additional arguments passed to cut, potentially useful
ones include right (whether intervals should be inclusive on the
right or left) and dig.lab (number of digits in interval labels).
msa
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.
Details
colourByCount assigns colours indepenent of the helix input's value
column, and instead operates over the number of helices (i.e. rows).
colourByValue uses cut to assign each of the helices
to an interval based on its value.
colourByCovariation, colourByConservation , and
colourByCanonical, colour helices according to compensatory mutations
(or covariation), percentage identity conservation, and percentage canonical
basepair repsectively, relative to the multiple sequence alignment provided.
colourByBasepairFrequency colours each basepair according to the
number of times it appear in the input, regardless of its value.
colourByUnknottedGroups greedily partitions the basepairs into non-
pseudoknotted groups, and assigns a colour to each.
Value
All “colourBy” functions return a list of colours when get =
FALSE, and a helix with a col column if get = TRUE. In both
bases, the returned object has attributes “legend” and “fill”,
showing the mapping between interval (in legend) and colour (in fill),
which can as eponymous arguments legend.
defaultPalette returns the default list of colours.
Author(s)
Daniel Lai
See Also
plotHelix
logseq
basepairFrequency
unknottedGroups
Examples
data(helix)
known$col <- colourByCount(known)
plotHelix(known)
plotHelix(colourByValue(helix, log = TRUE, get = TRUE))
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/colourHelices.Rd_%03d_medium.png", width=480, height=480)
> ### Name: Colour Helices
> ### Title: Assign colours to helices
> ### Aliases: colourByCount colourByValue colourByConservation
> ### colourByCovariation colourByCanonical colourByBasepairFrequency
> ### colourByUnknottedGroups defaultPalette
> ### Keywords: color
>
> ### ** Examples
>
> data(helix)
>
> known$col <- colourByCount(known)
> plotHelix(known)
>
> plotHelix(colourByValue(helix, log = TRUE, get = TRUE))
>
> 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
>