This function updates a gene chart with specific characteristics for genes based on the given parameters. It can show/hide genes, apply a color scheme, assign custom colors, filter by cluster, and accept additional options.
Usage
GC_genes(
GC_chart,
group = NULL,
marker = NULL,
marker_size = NULL,
show = TRUE,
colorScheme = NULL,
customColors = NULL,
cluster = NULL,
itemStyle = list(),
groupStyle = NULL,
style_by = NULL,
corner_radius = NULL,
...
)Arguments
- GC_chart
The gene chart object to be modified.
- group
Column name used for gene grouping to influence color aesthetics.
- marker
Character or NULL, type of marker to represent genes on the chart. Allowed values are 'arrow', 'boxarrow', 'box', 'cbox', and 'rbox'.
- marker_size
Character or NULL, size category of the marker ('small', 'medium', 'large').
- show
Logical, whether to show the genes or not.
- colorScheme
Character or NULL, the name of the color scheme to use: a d3 scheme (e.g. "schemeSet2") or a geneviewer palette (e.g. "okabeIto", see
geneviewer_palette()). When noclusteris selected, the legend uses the same colours. NULL keeps the colours set byGC_color().- customColors
List or NULL, custom colors to apply to the genes: a vector of colours, recycled over the groups, or a named list of colours by group. Groups left out of a named list keep the colours of the colour scheme. When no
clusteris selected, the legend uses the same colours.- cluster
Numeric or character, the specific cluster to filter genes by.
- itemStyle
List, a list of styles to apply to individual items in the chart.
- groupStyle
Named list of styles by group, applied to every gene of that group (of
group, or of the column given instyle_by), e.g.list(promoter = list(marker = "box", fill = "grey")). Takes the same options asitemStyle; theitemStyleof a gene takes precedence over the style of its group.- style_by
Column name or NULL; the column whose values
groupStyleis matched against, to style genes by another column than the one that sets their colours, or"geneTrack"for the track of a gene withGC_cluster()(prevent_gene_overlap = ), e.g.groupStyle = list("2" = list(markerHeight = 8))to draw the genes of the second track smaller. Default is NULL:group.- corner_radius
Numeric or NULL, radius in pixels of the rounded corners of 'arrow', 'boxarrow', 'box' and 'rbox' markers, e.g.
3for soft corners. The inner corners of arrows stay sharp. Default is NULL: sharp corners, and 5 for 'rbox'.- ...
Additional arguments to be passed to the gene options.
Examples
genes_data <- data.frame(
start = c(10, 90, 130, 170, 210),
end = c(40, 120, 160, 200, 240),
name = c('Gene 1', 'Gene 3', 'Gene 4', 'Gene 5', 'Gene 6'),
group = c('A', 'B', 'B', 'A', 'C'),
cluster = c(1, 1, 2, 2, 2)
)
# Change the appearance of a specific gene cluster
GC_chart(genes_data, cluster = "cluster", group = "group", height = "200px") %>%
GC_genes(
group = "group",
show = TRUE,
marker = "arrow",
marker_size = "medium",
colorScheme = NULL, # One of D3.js build in colorSchemes
# (eg. "schemeCategory10",
# "schemeAccent", "schemeTableau10")
customColors = NULL, # A vector of color names
prevent_overlap = FALSE,
gene_overlap_spacing = 40,
cluster = 1, # Specify a specific cluster
x = 1,
y = 50,
stroke = "black",
strokeWidth = 1,
arrowheadWidth = NULL,
arrowheadHeight = NULL,
arrowHeight = NULL,
markerHeight = NULL # overwrites marker_size
)
# Change the appearance of a specific gene
GC_chart(genes_data, cluster = "cluster", group = "group", height = "200px") %>%
GC_genes(
cluster = 2,
itemStyle = list(list(index = 2, fill = "red", stroke = "blue")
)
)
# Change the appearance of all genes of a group
GC_chart(genes_data, cluster = "cluster", group = "group", height = "200px") %>%
GC_genes(groupStyle = list(C = list(marker = "box", stroke = "red")))
