View source: R/visualise_single_sequence.R
| visualise_single_sequence | R Documentation |
This function takes a DNA/RNA sequence and returns a ggplot visualising it, with the option to directly export a png image with appropriate dimensions. Colours, line wrapping, index annotation interval, and pixels per square when exported are configurable.
visualise_single_sequence(
sequence,
sequence_colours = sequence_colour_palettes$ggplot_style,
background_colour = "white",
line_wrapping = 75,
spacing = 1,
margin = 0.5,
sequence_text_colour = "black",
sequence_text_size = 16,
index_annotation_colour = "darkred",
index_annotation_size = 12.5,
index_annotation_interval = 15,
index_annotations_above = TRUE,
index_annotation_vertical_position = 1/3,
outline_colour = "black",
outline_linewidth = 3,
outline_join = "mitre",
return = TRUE,
filename = NA,
render_device = ragg::agg_png,
pixels_per_base = 100
)
sequence |
|
sequence_colours |
|
background_colour |
|
line_wrapping |
|
spacing |
|
margin |
|
sequence_text_colour |
|
sequence_text_size |
|
index_annotation_colour |
|
index_annotation_size |
|
index_annotation_interval |
|
index_annotations_above |
|
index_annotation_vertical_position |
|
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 sequence to visualise
sequence <- paste(c(rep("GGC", 72), rep("GGAGGAGGCGGC", 15)), collapse = "")
## Visualise with all defaults
## This looks ugly because it isn't at the right scale/aspect ratio
visualise_single_sequence(sequence)
## Export with all defaults rather than returning
visualise_single_sequence(
sequence,
filename = "example_vss_01.png",
return = FALSE
)
## View exported image
image <- png::readPNG("example_vss_01.png")
unlink("example_vss_01.png")
grid::grid.newpage()
grid::grid.raster(image)
## Export while customising appearance
visualise_single_sequence(
sequence,
filename = "example_vss_02.png",
return = FALSE,
sequence_colours = sequence_colour_palettes$bright_pale,
sequence_text_colour = "white",
background_colour = "lightgrey",
line_wrapping = 60,
spacing = 2,
outline_linewidth = 0,
index_annotations_above = FALSE,
margin = 0
)
## View exported image
image <- png::readPNG("example_vss_02.png")
unlink("example_vss_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.