You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow custom color palettes for XString objects (#123)
Add functions update_DNA_palette(), update_RNA_palette(),
update_AA_palette(), and update_B_palette(), to let users
set their own color palettes for XString/XStringSet objects.
\itemAAString:AminoacidsarecoloredaccordingtoJalView's Zappo color scheme, representing physicochemical properties. X is colored light grey, other ambiguity codes are colored dark grey, and \code{"*-+."} are not colored.
35
+
\item BStrings are not colored.
36
+
}
37
+
38
+
Users can change the default color scheme of Biostrings with the \code{update_X_palette} family functions. Each function expects a \code{list} with named entries corresponding to the values to update. Each entry can specify \code{'fg'} and \code{'bg'} values, corresponding to the foreground and background colors (respectively). If \code{'fg'} is not specified, it defaults to \code{rgb(1,1,1)} (white). If \code{'bg'} is not specified, it defaults to transparent.
39
+
40
+
These functions will only update the values passed, leaving the rest of the colors as-is. For example, calling \code{update_AA_palette(list(A=list(fg="green")))} would update the coloring for \code{A} while leaving all other colors as the default schema.
41
+
42
+
To reset all colors to the default palette, call the function with no arguments (\code{NULL}).
43
+
44
+
To remove a coloring for a specific value, provide a named entry with value \code{NULL}. For example, \code{update_AA_palette(list(A=NULL))} will remove the coloring for \code{A}.
45
+
46
+
\code{update_DNA_palette} and \code{update_RNA_palette} are identical internally, so either function can be used to update colorings for \code{T,U}.
47
+
48
+
See the Examples section for more examples of custom colorings.
49
+
}
50
+
51
+
\value{
52
+
For \code{update_X_palette}, Invisibly returns the new color mapping, consisting of a named character vector. Calling \code{cat} on the return value will print out all letters with their respective coloring.
53
+
}
54
+
55
+
\author{Aidan Lakshman <AHL27@pitt.edu>}
56
+
57
+
\seealso{
58
+
\link{XString-class}
59
+
}
60
+
61
+
\examples{
62
+
## display default colors
63
+
DNAString(paste(DNA_ALPHABET, collapse=''))
64
+
RNAString(paste(RNA_ALPHABET, collapse=''))
65
+
AAString(paste(AA_ALPHABET, collapse=''))
66
+
BString(paste(LETTERS, collapse=''))
67
+
68
+
## create new palettes
69
+
DNA_palette <- list(
70
+
A=list(fg="blue",bg="black"),
71
+
T=list(fg="red",bg='black'),
72
+
G=list(fg='green',bg='black'),
73
+
C=list(fg='yellow',bg='black')
74
+
)
75
+
update_DNA_palette(DNA_palette)
76
+
DNAString(paste(DNA_ALPHABET, collapse=''))
77
+
78
+
## reset to default palette
79
+
update_DNA_palette()
80
+
DNAString(paste(DNA_ALPHABET, collapse=''))
81
+
82
+
## colors can also be specified with `rgb()`
83
+
AA_palette <- list(
84
+
A=list(fg="white", bg="purple"),
85
+
B=list(fg=rgb(1,1,1), bg='orange')
86
+
)
87
+
update_AA_palette(AA_palette)
88
+
AAString(paste(AA_ALPHABET, collapse=''))
89
+
90
+
## remove all coloring for QEG
91
+
update_AA_palette(list(Q=NULL, E=NULL, G=NULL))
92
+
AAString(paste(AA_ALPHABET, collapse=''))
93
+
94
+
## reset to default
95
+
update_AA_palette()
96
+
AAString(paste(AA_ALPHABET, collapse=''))
97
+
98
+
## We can also add colors to BStrings,
99
+
## which are normally not colored
100
+
101
+
## if 'fg' is not specified, defaults to rgb(1,1,1)
102
+
## if 'bg' is not specified, background is transparent
0 commit comments