Learn R Programming

R4RNA (version 1.0.0)

Colour Helices: Assign colours to helices

Description

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 Biostrings XStringSet object or a named array of strings like ones obtained from converting XStringSet with as.character.

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.

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.

See Also

plotHelix

logseq

basepairFrequency

unknottedGroups

Examples

Run this code
    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")

Run the code above in your browser using DataLab