R: Convert helix structures to and from other formats
Convert Helix Formats
R Documentation
Convert helix structures to and from other formats
Description
Converts dot bracket vienna format to and from helix format. It should be
noted that the allows structures of vienna is a subset of those allowed
in the helix format. Thus, conversion from vienna to helix will yield the
identical structure, while conversion from helix to vienna may result in the
loss of certain basepairs (mainly those that are conflicting). Pseudoknots
are supported in both directions of conversion with limitations.
Usage
viennaToHelix(vienna, value = NA, palette = NA)
helixToVienna(helix)
helixToConnect(helix)
helixToBpseq(helix)
Arguments
vienna
A string containing only a vienna dot bracket structure, with
balanced brackets. Allowable brackets are (, <, [, {, A, B, C, and D
(where upper-case alphabets are paired with lower-case alphabets).
value
A numerical value to assign to all helices.
palette
A list of colour names for up to 8 colours that will be used to colour
brackets of type (, <, [, {, A, B, C, and D, respectively.
helix
A helix data.frame.
Details
viennaToHelix will ignore any non dot-bracket characters prior
to parsing, so the resultant length will be shorter than expected if invalid
characters are included.
If the colour palette is less than the number of supported brackets, it
will simply cycle through the list. To explicitly prevent the colouring/
display of specific bracket type, colour it “NA”.
For helixToVienna, pseudoknotted basepairs will be assigned
different bracket types. As there are only 8 supported bracket types,
any basepair pseudonotted deeper than 8 levels will be excluded from the
output. Additionally, vienna format is unable to respresent conflicting
basepairs, so conflicting basepairs will also be excluded. For both types
of exclusion, those at the bottom of the helix data.frame will always be
excluded in favour of keeping helices higher on the data.frame table.
helixToConnect and helixToBpseq will convert a
non-conflicting helix data.frame into connect or bpseq format
repsectively, provided the helix structure has a “sequence” attribute
containing a single nucleotide sequence of the structure.
Value
viennaToHelix returns a helix data.frame. helixToVienna
returns a character string of basepairs in the Vienna helix format.
helixToConnect and HelixTpBpseq return data.frames in the
connect and bpseq formats, respectively.
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/viennaToHelix.Rd_%03d_medium.png", width=480, height=480)
> ### Name: Convert Helix Formats
> ### Title: Convert helix structures to and from other formats
> ### Aliases: viennaToHelix helixToVienna helixToConnect helixToBpseq
> ### Keywords: manip
>
> ### ** Examples
>
> # viennaToHelix demonstrating ALL valid bracket symbols
> dot_bracket <- ".....(<[{.....ABCD.....}]>).....dcba....."
> parsed <- viennaToHelix(dot_bracket, -31.5)
> print(parsed)
i j length value
1 6 27 1 -31.5
2 7 26 1 -31.5
3 8 25 1 -31.5
4 9 24 1 -31.5
5 15 36 1 -31.5
6 16 35 1 -31.5
7 17 34 1 -31.5
8 18 33 1 -31.5
>
> vienna <- helixToVienna(parsed)
Warning message:
In any(conflict) : coercing argument of type 'double' to logical
> print(vienna)
[1] ".....((((.....<<<<.....)))).....>>>>....."
>
> # Colouring the brackets by bracket type
> colour <- c("red", "orange", "yellow", "green", "lightblue", "blue", "purple", "black")
> double.rainbow <- viennaToHelix(dot_bracket, 0, colour)
> plotHelix(double.rainbow)
>
>
>
>
>
> dev.off()
null device
1
>