Title: | Draw Network with Data |
Version: | 0.0.7 |
Description: | Extends the 'ggplot2' plotting system to support network visualization. Inspired by the 'Method 1' in 'ggtree' (G Yu (2018) <doi:10.1093/molbev/msy194>), 'ggtangle' is designed to work with network associated data. |
Depends: | R (≥ 4.1.0) |
Imports: | ggfun (≥ 0.1.7), ggplot2, ggrepel, igraph, rlang, yulab.utils (≥ 0.1.7) |
Suggests: | aplot, cli, ggnewscale, ggtree, knitr, prettydoc, rmarkdown, scatterpie (≥ 0.2.4) |
VignetteBuilder: | knitr |
License: | Artistic-2.0 |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.2 |
NeedsCompilation: | no |
Packaged: | 2025-06-30 09:31:46 UTC; HUAWEI |
Author: | Guangchuang Yu |
Maintainer: | Guangchuang Yu <guangchuangyu@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2025-06-30 16:10:02 UTC |
ggtangle: Draw Network with Data
Description
Extends the 'ggplot2' plotting system to support network visualization. Inspired by the 'Method 1' in 'ggtree' (G Yu (2018) doi:10.1093/molbev/msy194), 'ggtangle' is designed to work with network associated data.
Author(s)
Maintainer: Guangchuang Yu guangchuangyu@gmail.com (ORCID)
category-item network plot
Description
category-item network plot
Usage
cnetplot(
x,
layout = igraph::layout_nicely,
showCategory = 5,
color_category = "#E5C494",
size_category = 1,
color_item = "#B3B3B3",
size_item = 1,
color_edge = "grey",
size_edge = 0.5,
node_label = "all",
foldChange = NULL,
hilight = "none",
hilight_alpha = 0.3,
...
)
## S3 method for class 'list'
cnetplot(
x,
layout = igraph::layout_nicely,
showCategory = 5,
color_category = "#E5C494",
size_category = 1,
color_item = "#B3B3B3",
size_item = 1,
color_edge = "grey",
size_edge = 0.5,
node_label = "all",
foldChange = NULL,
hilight = "none",
hilight_alpha = 0.3,
...
)
Arguments
x |
input object |
layout |
network layout |
showCategory |
selected category to be displayed |
color_category |
color of category node |
size_category |
relative size of the category |
color_item |
color of item node |
size_item |
relative size of the item (e.g., genes) |
color_edge |
color of edge, e.g., "black". If |
size_edge |
relative size of edge |
node_label |
one of 'all', 'none', 'category', 'item', 'exclusive' or 'share' |
foldChange |
numeric values to color the item (e.g, foldChange of gene expression values) |
hilight |
selected category to be highlighted |
hilight_alpha |
transparent value for not selected to be highlight |
... |
additional parameters |
Drag the nodes of a network to update the layout of the network
Description
Drag the nodes of a network to update the layout of the network
Usage
drag_network(p, g = NULL)
Arguments
p |
the network diagram as a ggplot/gg/ggraph object. |
g |
an corresponding igraph object. Default is to extract from the 'ggraph' attribute. |
Value
an updated ggplot/gg/ggraph object
Examples
## Not run:
library(igraph)
library(ggraph)
flow_info <- data.frame(from = c(1,2,3,3,4,5,6),
to = c(5,5,5,6,7,6,7))
g = graph_from_data_frame(flow_info)
p <- ggraph(g, layout='nicely') + geom_node_point() + geom_edge_link()
pp <- drag_network(p)
## End(Not run)
geom_cnet_label
Description
add labels of cnetplot
Usage
geom_cnet_label(mapping = NULL, data = NULL, node_label = "all", ...)
Arguments
mapping |
aes mapping, default is NULL |
data |
plot data, default is NULL |
node_label |
which type of node label to be displayed, see also cnetplot |
... |
parameters that passed to |
Author(s)
Guangchuang Yu
layer to draw edges of a network
Description
layer to draw edges of a network
Usage
geom_edge(mapping = NULL, data = NULL, geom = geom_segment, ...)
Arguments
mapping |
aesthetic mapping, default is NULL |
data |
data to plot, default is NULL |
geom |
geometric layer to draw lines |
... |
additional parameter passed to 'geom' |
Value
line segments layer
Examples
flow_info <- data.frame(from = LETTERS[c(1,2,3,3,4,5,6)],
to = LETTERS[c(5,5,5,6,7,6,7)])
dd <- data.frame(
label = LETTERS[1:7],
v1 = abs(rnorm(7)),
v2 = abs(rnorm(7)),
v3 = abs(rnorm(7))
)
g = igraph::graph_from_data_frame(flow_info)
p <- ggplot(g) + geom_edge()
library(ggplot2)
library(scatterpie)
p %<+% dd +
geom_scatterpie(cols = c("v1", "v2", "v3")) +
geom_text(aes(label=label), nudge_y = .2) +
coord_fixed()
Objects exported from other packages
Description
These objects are imported from other packages. Follow the links below to see their documentation.
- ggfun
- ggplot2
aes
,geom_label
,geom_point
,geom_segment
,geom_text
,ggplot
,ggsave
- grid