View source: R/visualise_many_sequences.R
| visualise_many_sequences | R Documentation |
This function takes a vector of DNA/RNA sequences (each sequence can be
any length and they can be different lengths), and plots each sequence
as base-coloured squares along a single line. Setting filename allows direct
export of a png image with the correct dimensions to make every base a perfect
square. Empty strings ("") within the vector can be utilised as blank spacing
lines. Colours and pixels per square when exported are configurable.
visualise_many_sequences(
sequences_vector,
sequence_colours = sequence_colour_palettes$ggplot_style,
background_colour = "white",
margin = 0.5,
sequence_text_colour = "black",
sequence_text_size = 16,
outline_colour = "black",
outline_linewidth = 3,
outline_join = "mitre",
return = TRUE,
filename = NA,
render_device = ragg::agg_png,
pixels_per_base = 100
)
sequences_vector |
|
sequence_colours |
|
background_colour |
|
margin |
|
sequence_text_colour |
|
sequence_text_size |
|
outline_colour |
|
outline_linewidth |
|
outline_join |
|
return |
|
filename |
|
render_device |
|
pixels_per_base |
|
A ggplot object containing the full visualisation, or invisible(NULL) if return = FALSE. It is often more useful to use filename = "myfilename.png", because then the visualisation is exported at the correct aspect ratio.
## Create sequences vector
sequences <- extract_and_sort_sequences(example_many_sequences)
## Visualise example_many_sequences with all defaults
## This looks ugly because it isn't at the right scale/aspect ratio
visualise_many_sequences(sequences)
## Export with all defaults rather than returning
visualise_many_sequences(
sequences,
filename = "example_vms_01.png",
return = FALSE
)
## View exported image
image <- png::readPNG("example_vms_01.png")
unlink("example_vms_01.png")
grid::grid.newpage()
grid::grid.raster(image)
## Export while customising appearance
visualise_many_sequences(
sequences,
filename = "example_vms_02.png",
return = FALSE,
sequence_colours = sequence_colour_palettes$bright_pale,
sequence_text_colour = "white",
background_colour = "lightgrey",
outline_linewidth = 0,
margin = 0
)
## View exported image
image <- png::readPNG("example_vms_02.png")
unlink("example_vms_02.png")
grid::grid.newpage()
grid::grid.raster(image)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.