Add links generated by get_links to a GC_chart object. Links are added
to the graph by their respective rowIDs.
Usage
GC_links(
GC_chart,
group = NULL,
data = NULL,
value1 = NULL,
value2 = NULL,
cluster = NULL,
curve = NULL,
measure = "identity",
show_links = TRUE,
label = TRUE,
label_position = "gene",
normal_color = NULL,
inverted_color = NULL,
low_color = NULL,
vmin = NULL,
vmax = NULL,
use_group_colors = FALSE,
color_bar = NULL,
colorBarOptions = list(),
linkWidth = NULL,
linkStyle = list(),
labelStyle = list(),
...
)Arguments
- GC_chart
Gene chart object.
- group
The name of the column in the data to create value pairs from.
- data
data.frame containing linking data.
- value1
Optional vector of group values to generate links for.
- value2
Optional vector of group values to generate links for.
- cluster
Numeric or character vector or NULL; specifies which clusters.
- curve
Logical; if
TRUE, links are curved, otherwise straight. Default is NULL: as set by the theme, otherwiseTRUE.- measure
Character; specifies which measure to use for link color intensity. Should be "identity", "similarity", or "none".
- show_links
Logical; if
TRUE, links are shown, otherwise hidden.- label
Logical; if
TRUE, shows measure labels on the links, otherwise hidden. When the genes also have labels fromGC_labels(), the measure is shown below the gene name in the same label (or after it, when the label is rotated to avoid overlap).- label_position
Where the measure labels go:
"gene"(default), with the label of the gene as described forlabel, or"link", in the middle of each link, white on dark links. A measure is only written where it fits within its link and clear of the others, so narrow links stay clean; zoomed in withGC_zoom(), links widen and more of them are written. With"link", links fromdatahave labels too.- normal_color
Color for the links in their normal state. Default is NULL: the color of the theme, otherwise "#969696".
- inverted_color
Color for inverted links. Default is NULL: the color of the theme, otherwise "#d62728".
- low_color
Color that links fade to at a low measure: links run from nearly this color (10% of the link color, at
vmin) tonormal_colororinverted_color(atvmax). Default is NULL: the color of the theme, otherwise white.- vmin, vmax
Numeric; the measures of the lightest and the full link color, also the ends of the color bar. Measures outside are drawn in the color of the nearest end. Default is NULL: as set by the theme, otherwise 0 and 100. Set
vminto the lowest measure to spread the colors over the data, e.g.vmin = floor(min(alignment$identity)).- use_group_colors
Logical; if
TRUE, color links by group.- color_bar
Logical; if
TRUE, the color bar is displayed. Default is NULL: as set by the theme, otherwiseTRUE.- colorBarOptions
List of options to customize the color bar appearance:
position, where the bar goes: a corner of the plot area,"bottomright"(default),"bottomleft","topright"or"topleft", or"legend"for an item of the legend (GC_legend()), lying down, in the font of the legend; without a legend it goes bottom right.legendSideputs it before the groups of the legend,"left"(default), or after them,"right".orientation,"vertical"(default) or"horizontal".labels, for a horizontal bar:"inline", one line with the title, the lowest measure, the bar and the highest, or"below", the title above the bar and ticks with their measures below it, as many as fit. Default is"inline"; in the legend it is always inline, as its rows are one line. The title of a horizontal bar is bold. With the labels below, the bar is about three lines tall, so in a corner it is more likely to cover genes. In the legend the bar is as tall as the legend markers, with a light grey outline when the theme leaves it without one.xandymove the bar in from its corner (default 0, and 24 pixels up from a bottom corner for a vertical bar);widthandheightset the size of the bar (default 10 by 60 pixels standing, 80 by 8 lying inline, 120 by 8 lying with the labels below);title = FALSEleaves out its title;labelOptions,titleOptionsandbarOptionsstyle the labels, the title and the bar. The bar is drawn over the plot area, so in a corner it can cover genes or links: move it withxandy, or put it in the legend.- linkWidth
Numeric; specifies the width of the links. A value of
1represents full width, and0represents no width.- linkStyle
A list of CSS styles to apply to the links.
- labelStyle
A list of CSS styles specifically for the labels.
- ...
Additional arguments passed to the links.
Examples
# Add links between all groups in each cluster
genes_data <- data.frame(
start = c(10, 90, 130, 170, 240, 250, 300, 340, 380, 420),
end = c(40, 120, 160, 200, 210, 270, 330, 370, 410, 450),
name = c('Gene 1', 'Gene 2', 'Gene 3', 'Gene 4', 'Gene 5',
'Gene 6', 'Gene 7', 'Gene 8', 'Gene 9', 'Gene 10'),
group = c('A', 'B', 'C', 'A', 'B', 'C', 'A', 'B', 'C', 'D'),
identity = c(NA, NA, NA, 50, 40, 100, 60, 65, 20, NA),
similarity = c(NA, NA, NA, 40, 30, 90, 50, 55, 10, NA),
cluster = c(1, 1, 1, 2, 2, 2, 3, 3, 3, 3)
)
GC_chart(genes_data,
cluster = "cluster",
height = "200px") %>%
GC_links(
group = "group",
value1 = "A",
value2 = "B",
measure = "identity",
label = FALSE) %>%
GC_labels(label = "group")
# Add links between group A of cluster 1 and A and B of cluster 2
GC_chart(genes_data,
cluster = "cluster",
height = "200px") %>%
GC_labels(label = "group") %>%
GC_links(group = "group",
value1 = c("A", "A"),
value2 = c("B", "A"),
label = FALSE,
cluster = c(1,2))
# A horizontal color bar in the legend
GC_chart(genes_data, cluster = "cluster", group = "group",
height = "220px") %>%
GC_links(group = "group", measure = "identity", label = FALSE,
colorBarOptions = list(position = "legend")) %>%
GC_legend(position = "top")
# Style links and color bar
GC_chart(genes_data,
cluster = "cluster",
height = "200px"
) %>%
GC_links(
group = "group",
data = NULL,
curve = TRUE,
measure = "identity",
show_links = TRUE,
label = TRUE,
normal_color = "#1f77b4",
inverted_color = "#d62728",
use_group_colors = FALSE,
color_bar = TRUE,
colorBarOptions = list(
x = 0,
y = 24,
width = 10,
height = 60,
labelOptions = list(
fontSize = 8,
xOffset = 2,
yOffset = 0
# Any other CSS style
),
titleOptions = list(
fontSize = 10,
xOffset = 2,
yOffset = 0
# Any other CSS style
),
barOptions = list(
stroke = "#000",
strokeWidth = 0.5,
opacity = 1
# Any other CSS style
)
),
linkWidth = 1,
linkStyle = list(
stroke = "black",
strokeWidth = 0.5,
fillOpacity = 0.4
# Any other CSS style
),
labelStyle = list(
fontSize = "8px"
# Any other CSS style
)
) %>%
GC_labels(label = "group", cluster = 1) %>%
GC_clusterLabel()
