plot_network | R Documentation |
Plot an undirected PPI network using ggraph
plot_network(
network,
fill_column,
fill_type,
cat_fill_colours = "Set1",
layout = "kk",
legend = FALSE,
fontfamily = "Helvetica",
edge_colour_ = "grey40",
edge_alpha_ = 0.5,
edge_width_ = 0.5,
node_size = c(3, 9),
node_colour = "grey30",
int_colour = "grey70",
fc_up_col = "firebrick3",
fc_down_col = "#188119",
label = FALSE,
label_column,
label_filter = 0,
label_size = 5,
label_colour = "black",
hub_colour = "blue2",
label_face = "bold",
label_padding = 0.25,
min_seg_length = 0.25,
force_atlas_params = NULL,
subnet = TRUE,
seed = 1,
...
)
network |
|
fill_column |
Tidy-select column for mapping node colour. Designed to
handle continuous numeric mappings (either positive/negative only, or
both), and categorical mappings, plus a special case for displaying fold
changes from, for example, RNA-Seq data. See |
fill_type |
String denoting type of fill mapping to perform for nodes. Options are: "fold_change", "two_sided", "one_sided", or "categorical". |
cat_fill_colours |
Colour palette to be used when |
layout |
Layout of nodes in the network. Supports all layouts from
|
legend |
Should a legend be included? Defaults to FALSE. |
fontfamily |
Font to use for labels and legend (if present). Defaults to "Helvetica". |
edge_colour_ |
Edge colour, defaults to "grey40" |
edge_alpha_ |
Transparency of edges, defaults to 0.5 |
edge_width_ |
Thickness of edges connecting nodes. Defaults to 0.5 |
node_size |
Numeric vector of length two, specifying size range of node
sizes (maps to node degree). Default is |
node_colour |
Colour (stroke or outline) of all nodes in the network. Defaults to "grey30". |
int_colour |
Fill colour for non-seed nodes, i.e. interactors. Defaults to "grey70". |
fc_up_col |
Colour to use for up regulated nodes when |
fc_down_col |
Colour to use for down regulated nodes when |
label |
Boolean, whether labels should be added to nodes. Defaults to FALSE. |
label_column |
Tidy-select column of the network/data to be used in
labeling nodes. Recommend setting to |
label_filter |
Degree filter used to determine which nodes should be labeled. Defaults to 0. This value can be increased to reduce the number of node labels, to prevent the network from being too crowded. |
label_size |
Size of node labels, defaults to 5. |
label_colour |
Colour of node labels, defaults to "black" |
hub_colour |
Colour of node labels for hubs. The top 2% of nodes (based
on calculated hub score) are highlighted with this colour, if |
label_face |
Font face for node labels, defaults to "bold" |
label_padding |
Padding around the label, defaults to 0.25 lines. |
min_seg_length |
Minimum length of lines to be drawn from labels to points. The default specified here is 0.25, half of the normal default value. |
force_atlas_params |
List of parameters to tweak node positions when
using the Force Atlas layout. The following arguments must be supplied: k,
gravity, ks, ksmax, and delta. See |
subnet |
Logical determining if networks produced by
|
seed |
Number used in call to |
... |
Further parameters can be passed on to |
Any layout supported by ggraph can be specified here - see
?layout_tbl_graph_igraph
for a list of options. Additionally, there is
support for the "force_atlas" method, implemented via the ForceAtlas2
package. Finally, you can also supply a data frame containing coordinates
for each node. The first and second columns will be used for x and y,
respectively. Note that having columns named "x" and "y" in the input
network will generate a warning message when supplying custom coordinates.
Since this function returns a standard ggplot object, you can tweak the
final appearance using the normal array of ggplot2 function, e.g. labs()
and theme()
to further customize the final appearance.
The fill_type
argument will determine how the node colour is mapped to
the desired column. "fold_change" represents a special case, where the fill
column is numeric and whose values should be mapped to up (> 0) or down (<
0). "two_sided" and "one_sided" are designed for numeric data that contains
either positive and negative values, or only positive/negative values,
respectively. "categorical" handles any other non-numeric colour mapping,
and uses "Set1" from RColorBrewer.
Node statistics (degree, betweenness, and hub score) are calculated using
the respective functions from the tidygraph
package.
If plotting a network created from the extract_subnetwork
function, the
genes belonging to the extracted pathway (i.e. the contents of the
"gene_id" column in the enrichment results) will be highlighted, instead of
hub nodes. The colour used here can be controlled via the hub_colour
argument, and this behaviour can be turned off altogether by setting the
subnet
argument to FALSE to return an "standard" network. Additionally,
one can set the "starters" attribute of the network being plotted to a
custom character vector of Ensembl gene IDs, to allow highlighting a custom
selection of nodes.
An object of class "gg"
See https://github.com/analyxcompany/ForceAtlas2 for details on this method.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.