coloring | R Documentation |
XString objects support custom coloring for display. Users can also set custom color palettes for XString objects using the update_X_palette
functions.
update_DNA_palette(colors=NULL)
update_RNA_palette(colors=NULL)
update_AA_palette(colors=NULL)
update_B_palette(colors=NULL)
colors |
A named list of colors to update, with entries |
XString objects support the following default coloring for display.
DNAString: A, C, G, and T are colored red, green, blue, and orange (respectively), N is colored light grey, other ambiguity codes are colored dark grey, and "-+."
have no coloring.
RNAString: All bases are colored identically to DNAString. U is colored yellow.
AAString: Amino acids are colored according to JalView's Zappo color scheme, representing physicochemical properties. X is colored light grey, other ambiguity codes are colored dark grey, and "*-+."
are not colored.
BStrings are not colored.
Users can change the default color scheme of Biostrings with the update_X_palette
family functions. Each function expects a list
with named entries corresponding to the values to update. Each entry can specify 'fg'
and 'bg'
values, corresponding to the foreground and background colors (respectively). If 'fg'
is not specified, it defaults to rgb(1,1,1)
(white). If 'bg'
is not specified, it defaults to transparent.
These functions will only update the values passed, leaving the rest of the colors as-is. For example, calling update_AA_palette(list(A=list(fg="green")))
would update the coloring for A
while leaving all other colors as the default schema.
To reset all colors to the default palette, call the function with no arguments (NULL
).
To remove a coloring for a specific value, provide a named entry with value NULL
. For example, update_AA_palette(list(A=NULL))
will remove the coloring for A
.
update_DNA_palette
and update_RNA_palette
are identical internally, so either function can be used to update colorings for T,U
.
See the Examples section for more examples of custom colorings.
For update_X_palette
, Invisibly returns the new color mapping, consisting of a named character vector. Calling cat
on the return value will print out all letters with their respective coloring.
Aidan Lakshman <AHL27@pitt.edu>
XString-class
## display default colors
DNAString(paste(DNA_ALPHABET, collapse=''))
RNAString(paste(RNA_ALPHABET, collapse=''))
AAString(paste(AA_ALPHABET, collapse=''))
BString(paste(LETTERS, collapse=''))
## create new palettes
DNA_palette <- list(
A=list(fg="blue",bg="black"),
T=list(fg="red",bg='black'),
G=list(fg='green',bg='black'),
C=list(fg='yellow',bg='black')
)
update_DNA_palette(DNA_palette)
DNAString(paste(DNA_ALPHABET, collapse=''))
## reset to default palette
update_DNA_palette()
DNAString(paste(DNA_ALPHABET, collapse=''))
## colors can also be specified with `rgb()`
AA_palette <- list(
A=list(fg="white", bg="purple"),
B=list(fg=rgb(1,1,1), bg='orange')
)
update_AA_palette(AA_palette)
AAString(paste(AA_ALPHABET, collapse=''))
## remove all coloring for QEG
update_AA_palette(list(Q=NULL, E=NULL, G=NULL))
AAString(paste(AA_ALPHABET, collapse=''))
## reset to default
update_AA_palette()
AAString(paste(AA_ALPHABET, collapse=''))
## We can also add colors to BStrings,
## which are normally not colored
## if 'fg' is not specified, defaults to rgb(1,1,1)
## if 'bg' is not specified, background is transparent
B_palette <- list(
A=list(bg='green'),
B=list(bg="red"),
C=list(bg='blue'),
D=list(fg="orange"),
E=list(fg="yellow")
)
update_B_palette(B_palette)
BString(paste(LETTERS, collapse=''))
## can also directly view the changes with cat
cat(update_B_palette(B_palette), '\n')
## reset to default
update_B_palette()
BString(paste(LETTERS, collapse=''))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.