Skip to content

Fill Genes with Patterns ​

Fills the genes, exons and legend markers with a pattern per group, for example for black and white figures. Patterns can also be drawn on top of the gene colours to show each group with both a colour and a pattern.

Usage ​

r
GC_pattern(
  GC_chart,
  patterns = NULL,
  color = "black",
  background = "white",
  size = 6,
  strokeWidth = 1
)

Arguments ​

ArgumentDescription
GC_chartThe gene chart object to be modified.
patternsNULL, a vector of pattern names or a named list of pattern names by group. NULL gives each group a pattern in a fixed order. A vector is recycled over the groups. Groups left out of a named list get no pattern ("none"). Available patterns: "none", "solid", "horizontal", "vertical", "diagonal", "antidiagonal", "grid", "crosshatch", "dots", "zigzag", "checkerboard", "rings", "bricks", "plus", "wideStripes" and "inverseDots" (background-coloured dots on a solid tile).
colorThe colour of the pattern lines and dots: a single colour, a vector of colours recycled over the groups, or a named list of colours by group. For example, color = "white" with background = "black" gives white patterns on black.
backgroundThe colour behind the pattern: a single colour, a vector of colours recycled over the groups, or a named list of colours by group. NULL keeps the gene colours set by GC_color(). When background is not NULL, intron lines and UTR outlines take color.
sizeNumeric, the width and height of one pattern tile in pixels.
strokeWidthNumeric, the width of the pattern lines in pixels.

Value ​

Returns the gene chart object with updated pattern settings.

Examples ​

r
genes_data <- data.frame(
  start = c(10, 50, 90, 130, 170, 210),
  end = c(40, 80, 120, 160, 200, 240),
  name = c('Gene 1', 'Gene 2', 'Gene 3', 'Gene 4', 'Gene 5', 'Gene 6'),
  group = c('A', 'A', 'B', 'B', 'A', 'C'),
  cluster = c(1, 1, 1, 2, 2, 2)
)

# Black and white
GC_chart(genes_data, cluster = "cluster", group = "group", height = "150px") %>%
  GC_pattern()

# Chosen patterns on grey backgrounds
GC_chart(genes_data, cluster = "cluster", group = "group", height = "150px") %>%
  GC_pattern(
    patterns = list(A = "dots", B = "crosshatch", C = "none"),
    background = c("white", "grey80")
  )

# Patterns on top of the gene colours
GC_chart(genes_data, cluster = "cluster", group = "group", height = "150px") %>%
  GC_pattern(background = NULL)

# White patterns on black for group C
GC_chart(genes_data, cluster = "cluster", group = "group", height = "150px") %>%
  GC_pattern(
    patterns = list(A = "checkerboard", B = "rings", C = "bricks"),
    color = list(A = "black", B = "black", C = "white"),
    background = list(A = "white", B = "white", C = "black")
  )