Package 'ggtangle'

Title: 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.
Authors: Guangchuang Yu [aut, cre]
Maintainer: Guangchuang Yu <[email protected]>
License: Artistic-2.0
Version: 0.0.6
Built: 2024-12-18 23:37:27 UTC
Source: CRAN

Help Index


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 color = "category", then edges will be colored based on the category information.

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 geom_text_repel

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()