Get or set the color palette of a sequence object

Share:

Description

This function gets or sets the color palette of a sequence object, that is, the list of colors used to represent the states.

Usage

1
2
cpal(seqdata)
cpal(seqdata) <- value

Arguments

seqdata

a state sequence object as defined by the seqdef function.

value

a vector containing the colors, of length equal to the number of states in the alphabet. The colors can be passed as character strings representing color names such as returned by the colors function, as hexadecimal values or as RGB vectors using the rgb function. Each color is attributed to the corresponding state in the alphabet, the order being the one returned by the alphabet.

Details

In the plot functions provided for visualizing sequence objects, a different color is associated to each state of the alphabet. The color palette is defined when creating the sequence object, either automatically using the brewer.pal function of the RColorBrewer package or by specifying a user defined color vector. The cpal function can be used to get or set the color palette of a previously defined sequence object.

Value

For 'cpal(seqdata)' a vector containing the colors.

For 'cpal(seqdata) <-' the updated sequence object.

Author(s)

Alexis Gabadinho

See Also

seqdef

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Creating a sequence object with the columns 13 to 24
## in the 'actcal' example data set
## The color palette is automatically set
data(actcal)
actcal.seq <- seqdef(actcal,13:24)

## Retrieving the color palette
cpal(actcal.seq)
seqiplot(actcal.seq)

## Setting a user defined color palette
cpal(actcal.seq) <- c("blue","red", "green", "yellow")
seqiplot(actcal.seq)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.