Title: | Network Analysis for Omics Data |
---|---|
Description: | Comprehensive network analysis package. Calculate correlation network fastly, accelerate lots of analysis by parallel computing. Support for multi-omics data, search sub-nets fluently. Handle bigger data, more than 10,000 nodes in each omics. Offer various layout method for multi-omics network and some interfaces to other software ('Gephi', 'Cytoscape', 'ggplot2'), easy to visualize. Provide comprehensive topology indexes calculation, including ecological network stability. |
Authors: | Chen Peng [aut, cre] |
Maintainer: | Chen Peng <[email protected]> |
License: | GPL-3 |
Version: | 0.2.2 |
Built: | 2025-02-03 06:27:22 UTC |
Source: | https://github.com/asa12138/metanet |
Use dataframe to annotate edges of an igraph
anno_edge(go, anno_tab, verbose = TRUE)
anno_edge(go, anno_tab, verbose = TRUE)
go |
metanet an igraph object |
anno_tab |
a dataframe using to annotate (with rowname or a name column) |
verbose |
logical |
a annotated igraph object
Other manipulate:
anno_vertex()
,
c_net_annotate()
,
c_net_filter()
,
c_net_load()
,
c_net_save()
,
c_net_union()
,
get_e()
,
get_n()
,
get_v()
,
is_metanet()
data("c_net") anno <- data.frame("from" = "s__Pelomonas_puraquae", "to" = "s__un_g__Rhizobium", new_atr = "new") anno_edge(co_net, anno) -> anno_net
data("c_net") anno <- data.frame("from" = "s__Pelomonas_puraquae", "to" = "s__un_g__Rhizobium", new_atr = "new") anno_edge(co_net, anno) -> anno_net
Use data.frame to annotate vertexes of metanet
anno_vertex(go, anno_tab, verbose = TRUE)
anno_vertex(go, anno_tab, verbose = TRUE)
go |
metanet object |
anno_tab |
a dataframe using to annotate (with rowname or a "name" column) |
verbose |
logical |
a annotated metanet object
Other manipulate:
anno_edge()
,
c_net_annotate()
,
c_net_filter()
,
c_net_load()
,
c_net_save()
,
c_net_union()
,
get_e()
,
get_n()
,
get_v()
,
is_metanet()
data("c_net") data("otutab", package = "pcutils") anno_vertex(co_net, taxonomy)
data("c_net") data("otutab", package = "pcutils") anno_vertex(co_net, taxonomy)
Layout as a arc
as_arc(angle = 0, arc = pi)
as_arc(angle = 0, arc = pi)
angle |
anticlockwise rotation angle |
arc |
the radian of arc |
A two-column matrix, each row giving the coordinates of a vertex, according to the ids of the vertex ids.
Other layout:
as_circle_tree()
,
as_line()
,
as_polyarc()
,
as_polycircle()
,
as_polygon()
,
c_net_layout()
as_arc()(co_net) c_net_plot(co_net, coors = as_arc(pi / 2), rescale = FALSE)
as_arc()(co_net) c_net_plot(co_net, coors = as_arc(pi / 2), rescale = FALSE)
Layout as a circle_tree
as_circle_tree()
as_circle_tree()
A two-column matrix, each row giving the coordinates of a vertex, according to the ids of the vertex ids.
Other layout:
as_arc()
,
as_line()
,
as_polyarc()
,
as_polycircle()
,
as_polygon()
,
c_net_layout()
Layout as a line
as_line(angle = 0)
as_line(angle = 0)
angle |
anticlockwise rotation angle |
A two-column matrix, each row giving the coordinates of a vertex, according to the ids of the vertex ids.
Other layout:
as_arc()
,
as_circle_tree()
,
as_polyarc()
,
as_polycircle()
,
as_polygon()
,
c_net_layout()
as_line()(co_net) c_net_plot(co_net, coors = as_line(pi / 2))
as_line()(co_net) c_net_plot(co_net, coors = as_line(pi / 2))
Layout as a polyarc
as_polyarc(n = 3, space = pi/3)
as_polyarc(n = 3, space = pi/3)
n |
how many arcs of this poly_arc |
space |
the space between each arc, default: pi/3 |
A two-column matrix, each row giving the coordinates of a vertex, according to the ids of the vertex ids.
Other layout:
as_arc()
,
as_circle_tree()
,
as_line()
,
as_polycircle()
,
as_polygon()
,
c_net_layout()
as_polyarc()(co_net)
as_polyarc()(co_net)
Layout as a polycircle
as_polycircle(n = 2)
as_polycircle(n = 2)
n |
how many circles of this polycircle |
A two-column matrix, each row giving the coordinates of a vertex, according to the ids of the vertex ids.
Other layout:
as_arc()
,
as_circle_tree()
,
as_line()
,
as_polyarc()
,
as_polygon()
,
c_net_layout()
as_polycircle()(co_net)
as_polycircle()(co_net)
Layout as a polygon
as_polygon(n = 3, line_curved = 0.5)
as_polygon(n = 3, line_curved = 0.5)
n |
how many edges of this polygon |
line_curved |
line_curved 0~0.5 |
A two-column matrix, each row giving the coordinates of a vertex, according to the ids of the vertex ids.
Other layout:
as_arc()
,
as_circle_tree()
,
as_line()
,
as_polyarc()
,
as_polycircle()
,
c_net_layout()
as_polygon()(co_net)
as_polygon()(co_net)
Transfer an igraph object to a ggig
as.ggig(go, coors = NULL)
as.ggig(go, coors = NULL)
go |
igraph or meatnet |
coors |
coordinates for nodes,columns: name, X, Y |
ggig object
Other plot:
c_net_plot()
,
input_gephi()
,
netD3plot()
,
olympic_rings_net()
,
plot.ggig()
,
twocol_edgelist()
,
venn_net()
as.ggig(co_net, coors = c_net_layout(co_net)) -> ggig plot(ggig) as.ggig(multi1, coors = c_net_layout(multi1)) -> ggig plot(ggig, labels_num = 0.3)
as.ggig(co_net, coors = c_net_layout(co_net)) -> ggig plot(ggig) as.ggig(multi1, coors = c_net_layout(multi1)) -> ggig plot(ggig, labels_num = 0.3)
Annotate a metanet
c_net_annotate(go, anno_tab, mode = "v", verbose = TRUE)
c_net_annotate(go, anno_tab, mode = "v", verbose = TRUE)
go |
metanet object |
anno_tab |
a dataframe using to annotate (mode v, e), or a list (mode n) |
mode |
"v" for vertex, "e" for edge, "n" for network |
verbose |
logical |
a annotated metanet object
Other manipulate:
anno_edge()
,
anno_vertex()
,
c_net_filter()
,
c_net_load()
,
c_net_save()
,
c_net_union()
,
get_e()
,
get_n()
,
get_v()
,
is_metanet()
data("c_net") anno <- data.frame("name" = "s__Pelomonas_puraquae", new_atr = "new") co_net_new <- c_net_annotate(co_net, anno, mode = "v") get_v(co_net_new, c("name", "new_atr")) anno <- data.frame("from" = "s__Pelomonas_puraquae", "to" = "s__un_g__Rhizobium", new_atr = "new") co_net_new <- c_net_annotate(co_net, anno, mode = "e") get_e(co_net_new, c("from", "to", "new_atr")) co_net_new <- c_net_annotate(co_net, list(new_atr = "new"), mode = "n") get_n(co_net_new)
data("c_net") anno <- data.frame("name" = "s__Pelomonas_puraquae", new_atr = "new") co_net_new <- c_net_annotate(co_net, anno, mode = "v") get_v(co_net_new, c("name", "new_atr")) anno <- data.frame("from" = "s__Pelomonas_puraquae", "to" = "s__un_g__Rhizobium", new_atr = "new") co_net_new <- c_net_annotate(co_net, anno, mode = "e") get_e(co_net_new, c("from", "to", "new_atr")) co_net_new <- c_net_annotate(co_net, list(new_atr = "new"), mode = "n") get_n(co_net_new)
Construct a metanet from a corr object
c_net_build( corr, r_threshold = 0.6, p_threshold = 0.05, use_p_adj = TRUE, delete_single = TRUE )
c_net_build( corr, r_threshold = 0.6, p_threshold = 0.05, use_p_adj = TRUE, delete_single = TRUE )
corr |
corr object from |
r_threshold |
r_threshold (default: >0.6). |
p_threshold |
p_threshold (default: <0.05). |
use_p_adj |
use the p.adjust instead of p.value (default: TRUE), if p.adjust not in the corr object, use p.value. |
delete_single |
should delete single vertexes? |
an metanet object
Other build:
c_net_from_edgelist()
,
c_net_set()
,
c_net_update()
,
multi_net_build()
data("otutab", package = "pcutils") t(otutab) -> totu metadata[, 3:10] -> env c_net_calculate(totu) -> corr c_net_build(corr, r_threshold = 0.65) -> co_net c_net_calculate(totu, env) -> corr2 c_net_build(corr2) -> co_net2
data("otutab", package = "pcutils") t(otutab) -> totu metadata[, 3:10] -> env c_net_calculate(totu) -> corr c_net_build(corr, r_threshold = 0.65) -> co_net c_net_calculate(totu, env) -> corr2 c_net_build(corr2) -> co_net2
Calculate correlation for one or two t(otutab), or distance for one t(otutab).
c_net_calculate( totu, totu2 = NULL, method = "spearman", filename = FALSE, p.adjust.method = NULL, p.adjust.mode = "all", threads = 1, verbose = TRUE )
c_net_calculate( totu, totu2 = NULL, method = "spearman", filename = FALSE, p.adjust.method = NULL, p.adjust.mode = "all", threads = 1, verbose = TRUE )
totu |
t(otutab), row are samples, column are features. |
totu2 |
t(otutab2) or NULL, row are samples, column are features. |
method |
"spearman" (default), "pearson", "sparcc", or distance index from |
filename |
the prefix of saved .corr file or FALSE. |
p.adjust.method |
see |
p.adjust.mode |
see |
threads |
threads, default: 1. |
verbose |
verbose, default: TRUE. |
a corr object with 3 elements:
r |
default: spearman correlation |
p.value |
default: p-value of spearman correlation |
p.adjust |
default p.adjust.method = NULL |
Other calculate:
cal_sim()
,
fast_cor()
,
p.adjust.table()
,
read_corr()
data("otutab", package = "pcutils") t(otutab) -> totu c_net_calculate(totu) -> corr metadata[, 3:10] -> env c_net_calculate(totu, env) -> corr2
data("otutab", package = "pcutils") t(otutab) -> totu c_net_calculate(totu) -> corr metadata[, 3:10] -> env c_net_calculate(totu, env) -> corr2
Filter a network according to some attributes
c_net_filter(go, ..., mode = "v")
c_net_filter(go, ..., mode = "v")
go |
metanet object |
... |
some attributes of vertex and edge |
mode |
"v" or "e" |
metanet
Other manipulate:
anno_edge()
,
anno_vertex()
,
c_net_annotate()
,
c_net_load()
,
c_net_save()
,
c_net_union()
,
get_e()
,
get_n()
,
get_v()
,
is_metanet()
data("multi_net") c_net_filter(multi1, v_group %in% c("omic1", "omic2"))
data("multi_net") c_net_filter(multi1, v_group %in% c("omic1", "omic2"))
Construct a network from edge_list dataframe
c_net_from_edgelist( edgelist, vertex_df = NULL, direct = FALSE, e_type = NULL, e_class = NULL )
c_net_from_edgelist( edgelist, vertex_df = NULL, direct = FALSE, e_type = NULL, e_class = NULL )
edgelist |
first is source, second is target, others are annotation |
vertex_df |
vertex metadata data.frame |
direct |
logical |
e_type |
set e_type |
e_class |
set e_class |
metanet
Other build:
c_net_build()
,
c_net_set()
,
c_net_update()
,
multi_net_build()
data(edgelist) edge_net <- c_net_from_edgelist(arc_count, vertex_df = arc_taxonomy) edge_net <- c_net_set(edge_net, vertex_class = "Phylum", edge_width = "n") c_net_plot(edge_net)
data(edgelist) edge_net <- c_net_from_edgelist(arc_count, vertex_df = arc_taxonomy) edge_net <- c_net_set(edge_net, vertex_class = "Phylum", edge_width = "n") c_net_plot(edge_net)
Layout coordinates
c_net_layout( go, method = igraph::nicely(), order_by = NULL, order_ls = NULL, seed = 1234, line_curved = 0.5, ... )
c_net_layout( go, method = igraph::nicely(), order_by = NULL, order_ls = NULL, seed = 1234, line_curved = 0.5, ... )
go |
igraph or metanet |
method |
(1) as_line(), as_arc(), as_polygon(), as_polyarc(), as_polycircle(), as_circle_tree();
(2) as_star(), as_tree(), in_circle(), nicely(), on_grid(), on_sphere(),randomly(), with_dh(), with_fr(), with_gem(), with_graphopt(), with_kk(),with_lgl(), with_mds(),. see |
order_by |
order nodes according to a node attribute |
order_ls |
manual the discrete variable with a vector, or continuous variable with "desc" to decreasing |
seed |
random seed |
line_curved |
consider line curved, only for some layout methods like as_line(), as_polygon().default:0 |
... |
add |
coors object: coordinates for nodes, columns: name, X, Y; curved for edges, columns: from, to, curved;
Other layout:
as_arc()
,
as_circle_tree()
,
as_line()
,
as_polyarc()
,
as_polycircle()
,
as_polygon()
library(igraph) c_net_layout(co_net) -> coors c_net_plot(co_net, coors) c_net_plot(co_net, c_net_layout(co_net, in_circle()), vertex.size = 2) c_net_plot(co_net, c_net_layout(co_net, in_circle(), order_by = "v_class"), vertex.size = 2) c_net_plot(co_net, c_net_layout(co_net, in_circle(), order_by = "size", order_ls = "desc")) c_net_plot(co_net, c_net_layout(co_net, as_polygon(3)))
library(igraph) c_net_layout(co_net) -> coors c_net_plot(co_net, coors) c_net_plot(co_net, c_net_layout(co_net, in_circle()), vertex.size = 2) c_net_plot(co_net, c_net_layout(co_net, in_circle(), order_by = "v_class"), vertex.size = 2) c_net_plot(co_net, c_net_layout(co_net, in_circle(), order_by = "size", order_ls = "desc")) c_net_plot(co_net, c_net_layout(co_net, as_polygon(3)))
Load network file
c_net_load(filename, format = "data.frame")
c_net_load(filename, format = "data.frame")
filename |
filename |
format |
"data.frame","graphml" |
metanet
Other manipulate:
anno_edge()
,
anno_vertex()
,
c_net_annotate()
,
c_net_filter()
,
c_net_save()
,
c_net_union()
,
get_e()
,
get_n()
,
get_v()
,
is_metanet()
Plot a metanet
c_net_plot( go, coors = NULL, ..., labels_num = NULL, vertex_size_range = NULL, edge_width_range = NULL, plot_module = FALSE, mark_module = FALSE, mark_color = NULL, mark_alpha = 0.3, module_label = FALSE, module_label_cex = 2, module_label_color = "black", module_label_just = c(0.5, 0.5), pie_value = NULL, pie_color = NULL, legend = TRUE, legend_number = FALSE, legend_cex = 1, legend_position = c(left_leg_x = -2, left_leg_y = 1, right_leg_x = 1.2, right_leg_y = 1), group_legend_title = NULL, group_legend_order = NULL, color_legend = TRUE, color_legend_order = NULL, size_legend = FALSE, size_legend_title = "Node Size", edge_legend = TRUE, edge_legend_title = "Edge type", edge_legend_order = NULL, width_legend = FALSE, width_legend_title = "Edge width", lty_legend = FALSE, lty_legend_title = "Edge class", lty_legend_order = NULL, module_legend = FALSE, module_legend_title = "Module", module_legend_order = NULL, pie_legend = FALSE, pie_legend_title = "Pie part", pie_legend_order = NULL, params_list = NULL, seed = 1234 )
c_net_plot( go, coors = NULL, ..., labels_num = NULL, vertex_size_range = NULL, edge_width_range = NULL, plot_module = FALSE, mark_module = FALSE, mark_color = NULL, mark_alpha = 0.3, module_label = FALSE, module_label_cex = 2, module_label_color = "black", module_label_just = c(0.5, 0.5), pie_value = NULL, pie_color = NULL, legend = TRUE, legend_number = FALSE, legend_cex = 1, legend_position = c(left_leg_x = -2, left_leg_y = 1, right_leg_x = 1.2, right_leg_y = 1), group_legend_title = NULL, group_legend_order = NULL, color_legend = TRUE, color_legend_order = NULL, size_legend = FALSE, size_legend_title = "Node Size", edge_legend = TRUE, edge_legend_title = "Edge type", edge_legend_order = NULL, width_legend = FALSE, width_legend_title = "Edge width", lty_legend = FALSE, lty_legend_title = "Edge class", lty_legend_order = NULL, module_legend = FALSE, module_legend_title = "Module", module_legend_order = NULL, pie_legend = FALSE, pie_legend_title = "Pie part", pie_legend_order = NULL, params_list = NULL, seed = 1234 )
go |
an igraph or metanet object |
coors |
the coordinates you saved |
... |
additional parameters for |
labels_num |
show how many labels, >1 indicates number, <1 indicates fraction, "all" indicates all. |
vertex_size_range |
the vertex size range, e.g. c(1,10) |
edge_width_range |
the edge width range, e.g. c(1,10) |
plot_module |
logical, plot module? |
mark_module |
logical, mark the modules? |
mark_color |
mark color |
mark_alpha |
mark fill alpha, default 0.3 |
module_label |
show module label? |
module_label_cex |
module label cex |
module_label_color |
module label color |
module_label_just |
module label just, default c(0.5,0.5) |
pie_value |
a dataframe using to plot pie (with rowname or a "name" column) |
pie_color |
color vector |
legend |
all legends |
legend_number |
legend with numbers |
legend_cex |
character expansion factor relative to current par("cex"), default: 1 |
legend_position |
legend_position, default: c(left_leg_x=-1.9,left_leg_y=1,right_leg_x=1.2,right_leg_y=1) |
group_legend_title |
group_legend_title, length must same to the numbers of v_group |
group_legend_order |
group_legend_order vector |
color_legend |
logical |
color_legend_order |
color_legend_order vector |
size_legend |
logical |
size_legend_title |
size_legend_title |
edge_legend |
logical |
edge_legend_title |
edge_legend_title |
edge_legend_order |
edge_legend_order vector, e.g. c("positive","negative") |
width_legend |
logical |
width_legend_title |
width_legend_title |
lty_legend |
logical |
lty_legend_title |
lty_legend_title |
lty_legend_order |
lty_legend_order |
module_legend |
logical |
module_legend_title |
module_legend_title |
module_legend_order |
module_legend_order |
pie_legend |
logical |
pie_legend_title |
pie_legend_title |
pie_legend_order |
pie_legend_order |
params_list |
a list of parameters, e.g. list(edge_legend = TRUE, lty_legend = FALSE), when the parameter is duplicated, the format argument will be used rather than the argument in params_list. |
seed |
random seed, default:1234, make sure each plot is the same. |
a network plot
Other plot:
as.ggig()
,
input_gephi()
,
netD3plot()
,
olympic_rings_net()
,
plot.ggig()
,
twocol_edgelist()
,
venn_net()
data("c_net") c_net_plot(co_net) c_net_plot(co_net2) c_net_plot(multi1)
data("c_net") c_net_plot(co_net) c_net_plot(co_net2) c_net_plot(multi1)
Save network file
c_net_save(go, filename = "net", format = "data.frame")
c_net_save(go, filename = "net", format = "data.frame")
go |
metanet network |
filename |
filename |
format |
"data.frame","graphml" |
No value
Other manipulate:
anno_edge()
,
anno_vertex()
,
c_net_annotate()
,
c_net_filter()
,
c_net_load()
,
c_net_union()
,
get_e()
,
get_n()
,
get_v()
,
is_metanet()
Set basic attributes from totu table
c_net_set( go, ..., vertex_group = "v_group", vertex_class = "v_class", vertex_size = "size", edge_type = "e_type", edge_class = "e_class", edge_width = "width", node_break = 5, edge_break = 5, initialize = TRUE )
c_net_set( go, ..., vertex_group = "v_group", vertex_class = "v_class", vertex_size = "size", edge_type = "e_type", edge_class = "e_class", edge_width = "width", node_break = 5, edge_break = 5, initialize = TRUE )
go |
metanet an igraph object |
... |
some data.frames to annotate go |
vertex_group |
choose which column to be vertex_group (map to vertex_shape) |
vertex_class |
choose which column to be vertex_class (map to vertex_color) |
vertex_size |
choose which column to be vertex_size (map to vertex_size) |
edge_type |
choose which column to be edge_type (map to edge_color) |
edge_class |
choose which column to be edge_class (map to edge_linetype) |
edge_width |
choose which column to be edge_width (map to edge_width) |
node_break |
node_break if v_class is numeric, default: 5 |
edge_break |
edge_break if e_type is numeric, default: 5 |
initialize |
initialize, default: TRUE |
a metanet object
Other build:
c_net_build()
,
c_net_from_edgelist()
,
c_net_update()
,
multi_net_build()
data("otutab", package = "pcutils") t(otutab) -> totu metadata[, 3:10] -> env data("c_net") co_net <- c_net_set(co_net, taxonomy, data.frame("Abundance" = colSums(totu)), vertex_class = "Phylum", vertex_size = "Abundance" ) co_net2 <- c_net_set(co_net2, taxonomy, data.frame(name = colnames(env), env = colnames(env)), vertex_class = c("Phylum", "env") ) co_net2 <- c_net_set(co_net2, data.frame("Abundance" = colSums(totu)), vertex_size = "Abundance")
data("otutab", package = "pcutils") t(otutab) -> totu metadata[, 3:10] -> env data("c_net") co_net <- c_net_set(co_net, taxonomy, data.frame("Abundance" = colSums(totu)), vertex_class = "Phylum", vertex_size = "Abundance" ) co_net2 <- c_net_set(co_net2, taxonomy, data.frame(name = colnames(env), env = colnames(env)), vertex_class = c("Phylum", "env") ) co_net2 <- c_net_set(co_net2, data.frame("Abundance" = colSums(totu)), vertex_size = "Abundance")
E is the global efficiency and Ei is the global efficiency after the removal of the node i and its entire links.
c_net_stability( go_ls, mode = "robust_test", partial = 0.5, step = 10, reps = 9, threads = 1, verbose = TRUE, keystone = FALSE ) robust_test( go_ls, partial = 0.5, step = 10, reps = 9, threads = 1, verbose = TRUE ) vulnerability(go_ls, threads = 1, verbose = TRUE) robustness(go_ls, keystone = FALSE, reps = 9, threads = 1, verbose = TRUE)
c_net_stability( go_ls, mode = "robust_test", partial = 0.5, step = 10, reps = 9, threads = 1, verbose = TRUE, keystone = FALSE ) robust_test( go_ls, partial = 0.5, step = 10, reps = 9, threads = 1, verbose = TRUE ) vulnerability(go_ls, threads = 1, verbose = TRUE) robustness(go_ls, keystone = FALSE, reps = 9, threads = 1, verbose = TRUE)
go_ls |
an igraph object or igraph list. |
mode |
"robust_test", "vulnerability", "robustness" |
partial |
how much percent vertexes be removed in total (default: 0.5, only for robust_test) |
step |
how many nodes be removed each time? (default: 10, only for robust_test) |
reps |
simulation number (default: 9) |
threads |
threads |
verbose |
verbose |
keystone |
remove 70%% keystones instead of remove 50%% nodes (default: False, only for robustness) |
a data.frame
data.frame (robustness class)
a vector
data("c_net") if (requireNamespace("ggpmisc")) { c_net_stability(co_net, mode = "robust_test", step = 20, reps = 9) -> robust_res plot(robust_res, index = "Average_degree", mode = 2) } c_net_stability(co_net, mode = "vulnerability") -> vulnerability_res plot(vulnerability_res) robustness(co_net) -> robustness_res plot(robustness_res) module_detect(co_net) -> co_net_modu zp_analyse(co_net_modu, mode = 2) -> co_net_modu c_net_stability(co_net_modu, mode = "robustness", keystone = TRUE) -> robustness_res plot(robustness_res)
data("c_net") if (requireNamespace("ggpmisc")) { c_net_stability(co_net, mode = "robust_test", step = 20, reps = 9) -> robust_res plot(robust_res, index = "Average_degree", mode = 2) } c_net_stability(co_net, mode = "vulnerability") -> vulnerability_res plot(vulnerability_res) robustness(co_net) -> robustness_res plot(robustness_res) module_detect(co_net) -> co_net_modu zp_analyse(co_net_modu, mode = 2) -> co_net_modu c_net_stability(co_net_modu, mode = "robustness", keystone = TRUE) -> robustness_res plot(robustness_res)
Union two networks
c_net_union(go1, go2)
c_net_union(go1, go2)
go1 |
metanet object |
go2 |
metanet object |
metanet
Other manipulate:
anno_edge()
,
anno_vertex()
,
c_net_annotate()
,
c_net_filter()
,
c_net_load()
,
c_net_save()
,
get_e()
,
get_n()
,
get_v()
,
is_metanet()
data("c_net") co_net_union <- c_net_union(co_net, co_net2) c_net_plot(co_net_union)
data("c_net") co_net_union <- c_net_union(co_net, co_net2) c_net_plot(co_net_union)
Update a metanet object or transform igraph object to metanet object
c_net_update( go, node_break = 5, edge_break = 5, initialize = FALSE, verbose = TRUE, uniq_v_class = FALSE )
c_net_update( go, node_break = 5, edge_break = 5, initialize = FALSE, verbose = TRUE, uniq_v_class = FALSE )
go |
a metanet object or igraph object |
node_break |
node_break if v_class is numeric, default: 5 |
edge_break |
edge_break if e_type is numeric, default: 5 |
initialize |
initialize? |
verbose |
verbose? |
uniq_v_class |
if TRUE, add prefix to v_class if multiple v_class belong to same v_group. |
metanet
Other build:
c_net_build()
,
c_net_from_edgelist()
,
c_net_set()
,
multi_net_build()
Calculate similarity for one t(otutab)
cal_sim(totu, totu2 = NULL, method = "bray")
cal_sim(totu, totu2 = NULL, method = "bray")
totu |
t(otutab), row are samples, column are features. |
totu2 |
t(otutab) or NULL, row are samples, column are features. |
method |
Dissimilarity index, see |
similarity = 1-distance
Other calculate:
c_net_calculate()
,
fast_cor()
,
p.adjust.table()
,
read_corr()
if (requireNamespace("vegan")) { data("otutab", package = "pcutils") t(otutab) -> totu cal_sim(totu) -> sim_corr }
if (requireNamespace("vegan")) { data("otutab", package = "pcutils") t(otutab) -> totu cal_sim(totu) -> sim_corr }
Check tables and extract common samples
check_tabs(...)
check_tabs(...)
... |
tables |
formatted tables
data("otutab", package = "pcutils") check_tabs(otutab)
data("otutab", package = "pcutils") check_tabs(otutab)
Clean a igraph object
clean_igraph(go, direct = TRUE)
clean_igraph(go, direct = TRUE)
go |
igraph, metanet objects |
direct |
direct? |
a igraph object
Clean multi edge metanet to plot
clean_multi_edge_metanet(go)
clean_multi_edge_metanet(go)
go |
metanet object |
metanet object
g <- igraph::make_ring(2) g <- igraph::add.edges(g, c(1, 1, 1, 1, 2, 1)) plot(g) plot(clean_multi_edge_metanet(g))
g <- igraph::make_ring(2) g <- igraph::add.edges(g, c(1, 1, 1, 1, 2, 1)) plot(g) plot(clean_multi_edge_metanet(g))
Cohesion calculation
Plot cohesion
Cohesion(otutab, reps = 200, threads = 1, mycor = NULL, verbose = TRUE) ## S3 method for class 'cohesion' plot(x, group, metadata, mode = 1, ...)
Cohesion(otutab, reps = 200, threads = 1, mycor = NULL, verbose = TRUE) ## S3 method for class 'cohesion' plot(x, group, metadata, mode = 1, ...)
otutab |
otutab |
reps |
iteration time |
threads |
threads |
mycor |
a correlation matrix you want to use, skip the null model build when mycor is not NULL, default: NULL |
verbose |
verbose |
x |
|
group |
group name in colnames(metadata) |
metadata |
metadata |
mode |
plot mode, 1~2 |
... |
additional arguments for |
Cohesion object: a list with two dataframe
a ggplot
Herren, C. M. & McMahon, K. (2017) Cohesion: a method for quantifying the connectivity of microbial communities. doi:10.1038/ismej.2017.91.
data("otutab", package = "pcutils") # set reps at least 99 when you run. Cohesion(otutab[1:50, ], reps = 19) -> cohesion_res if (requireNamespace("ggpubr")) { plot(cohesion_res, group = "Group", metadata = metadata, mode = 1) plot(cohesion_res, group = "Group", metadata = metadata, mode = 2) }
data("otutab", package = "pcutils") # set reps at least 99 when you run. Cohesion(otutab[1:50, ], reps = 19) -> cohesion_res if (requireNamespace("ggpubr")) { plot(cohesion_res, group = "Group", metadata = metadata, mode = 1) plot(cohesion_res, group = "Group", metadata = metadata, mode = 2) }
Transform a dataframe to a network edgelist.
df2net_tree(test, fun = sum)
df2net_tree(test, fun = sum)
test |
df |
fun |
default: sum |
metanet
data("otutab", package = "pcutils") cbind(taxonomy, num = rowSums(otutab))[1:20, ] -> test df2net_tree(test) -> ttt plot(ttt) if (requireNamespace("ggraph")) plot(ttt, coors = as_circle_tree())
data("otutab", package = "pcutils") cbind(taxonomy, num = rowSums(otutab))[1:20, ] -> test df2net_tree(test) -> ttt plot(ttt) if (requireNamespace("ggraph")) plot(ttt, coors = as_circle_tree())
Extract each sample network from the whole network
extract_sample_net( whole_net, otutab, threads = 1, save_net = FALSE, fast = TRUE, remove_negative = FALSE, verbose = TRUE )
extract_sample_net( whole_net, otutab, threads = 1, save_net = FALSE, fast = TRUE, remove_negative = FALSE, verbose = TRUE )
whole_net |
the whole network |
otutab |
otutab, columns are samples, these columns will be extract |
threads |
threads, default: 1 |
save_net |
should save these sub_nets? FALSE or a filename |
fast |
less indexes for faster calculate ? |
remove_negative |
remove negative edge or not? default: FALSE |
verbose |
verbose |
a dataframe contains all sub_net parameters
Other topological:
fit_power()
,
get_group_skeleton()
,
links_stat()
,
nc()
,
net_par()
,
rand_net_par()
,
rand_net()
,
smallworldness()
data(otutab, package = "pcutils") extract_sample_net(co_net, otutab) -> sub_net_pars
data(otutab, package = "pcutils") extract_sample_net(co_net, otutab) -> sub_net_pars
Fast correlation calculation
fast_cor(totu, totu2 = NULL, method = c("pearson", "spearman"))
fast_cor(totu, totu2 = NULL, method = c("pearson", "spearman"))
totu |
t(otutab), row are samples, column are features. |
totu2 |
t(otutab) or NULL, row are samples, column are features. |
method |
"spearman" or "pearson" |
a list with 2 elements:
r |
default: spearman correlation |
p.value |
default: p-value of spearman correlation |
Other calculate:
c_net_calculate()
,
cal_sim()
,
p.adjust.table()
,
read_corr()
data("otutab", package = "pcutils") t(otutab[1:100, ]) -> totu fast_cor(totu, method = "spearman") -> corr
data("otutab", package = "pcutils") t(otutab[1:100, ]) -> totu fast_cor(totu, method = "spearman") -> corr
Filter some modules as others
Combine or cut modules to module_number
Plot module tree
filter_n_module(go_m, n_node_in_module = 0, keep_id = NULL, delete = FALSE) combine_n_module(go_m, module_number = 5) plot_module_tree(go_m, module = "module", community = NULL, label.size = 2)
filter_n_module(go_m, n_node_in_module = 0, keep_id = NULL, delete = FALSE) combine_n_module(go_m, module_number = 5) plot_module_tree(go_m, module = "module", community = NULL, label.size = 2)
go_m |
module metanet |
n_node_in_module |
transfer the modules less than n_node_in_module to "others" |
keep_id |
keep modules ids, will not be "others" |
delete |
logical, delete others modules? default:FALSE, the others module will be "others". |
module_number |
number of modules |
module |
which column name is module. default: "module" |
community |
community object, default: NULL, use the community of go_m |
label.size |
label.size |
metanet with modules
ggplot
Other module:
get_community()
,
get_module_eigen()
,
get_module()
,
module_detect()
,
module_eigen()
,
module_net()
,
summary_module()
,
to_module_net()
,
zp_analyse()
data("c_net") module_detect(co_net) -> co_net_modu filter_n_module(co_net_modu, n_node_in_module = 30) -> co_net_modu if (requireNamespace("ggtree") && requireNamespace("treeio")) plot_module_tree(co_net_modu) combine_n_module(co_net_modu, 20) -> co_net_modu1 if (requireNamespace("ggtree") && requireNamespace("treeio")) plot_module_tree(co_net_modu1)
data("c_net") module_detect(co_net) -> co_net_modu filter_n_module(co_net_modu, n_node_in_module = 30) -> co_net_modu if (requireNamespace("ggtree") && requireNamespace("treeio")) plot_module_tree(co_net_modu) combine_n_module(co_net_modu, 20) -> co_net_modu1 if (requireNamespace("ggtree") && requireNamespace("treeio")) plot_module_tree(co_net_modu1)
Fit power-law distribution for an igraph
fit_power(go, p.value = FALSE)
fit_power(go, p.value = FALSE)
go |
igraph |
p.value |
calculate p.value |
ggplot
Other topological:
extract_sample_net()
,
get_group_skeleton()
,
links_stat()
,
nc()
,
net_par()
,
rand_net_par()
,
rand_net()
,
smallworldness()
fit_power(co_net)
fit_power(co_net)
Layout with group
g_layout( go, group = "module", group_order = NULL, layout1 = in_circle(), zoom1 = 20, layout2 = in_circle(), zoom2 = 3, show_big_layout = FALSE, ... )
g_layout( go, group = "module", group_order = NULL, layout1 = in_circle(), zoom1 = 20, layout2 = in_circle(), zoom2 = 3, show_big_layout = FALSE, ... )
go |
igraph or metanet object |
group |
group name (default: module) |
group_order |
group_order |
layout1 |
layout1 method, one of
(1) a dataframe or matrix: rowname is group, two columns are X and Y
(2) function: layout method for |
zoom1 |
big network layout size |
layout2 |
one of functions: layout method for |
zoom2 |
average sub_network layout size, or numeric vector, or "auto" |
show_big_layout |
show the big layout to help you adjust. |
... |
add |
coors
Other g_layout:
g_layout_nice()
,
g_layout_polygon()
data("c_net") module_detect(co_net, method = "cluster_fast_greedy") -> co_net_modu g_layout(co_net_modu, group = "module", zoom1 = 30, zoom2 = "auto", layout2 = as_line()) -> oridata plot(co_net_modu, coors = oridata)
data("c_net") module_detect(co_net, method = "cluster_fast_greedy") -> co_net_modu g_layout(co_net_modu, group = "module", zoom1 = 30, zoom2 = "auto", layout2 = as_line()) -> oridata plot(co_net_modu, coors = oridata)
Layout with group nicely
g_layout_nice(go, group = "module", mode = "circlepack", ...) g_layout_circlepack(go, group = "module", ...) g_layout_treemap(go, group = "module", ...) g_layout_backbone(go, group = "module", ...) g_layout_stress(go, group = "module", ...)
g_layout_nice(go, group = "module", mode = "circlepack", ...) g_layout_circlepack(go, group = "module", ...) g_layout_treemap(go, group = "module", ...) g_layout_backbone(go, group = "module", ...) g_layout_stress(go, group = "module", ...)
go |
igraph or metanet |
group |
group name (default: module) |
mode |
circlepack, treemap, backbone, stress |
... |
add |
coors
Other g_layout:
g_layout_polygon()
,
g_layout()
data("c_net") module_detect(co_net, method = "cluster_fast_greedy") -> co_net_modu if (requireNamespace("ggraph")) { plot(co_net_modu, coors = g_layout_nice(co_net_modu, group = "module")) plot(co_net_modu, coors = g_layout_nice(co_net_modu, group = "module", mode = "treemap")) }
data("c_net") module_detect(co_net, method = "cluster_fast_greedy") -> co_net_modu if (requireNamespace("ggraph")) { plot(co_net_modu, coors = g_layout_nice(co_net_modu, group = "module")) plot(co_net_modu, coors = g_layout_nice(co_net_modu, group = "module", mode = "treemap")) }
Layout with group as a polygon
Layout with group as a polyarc
Layout with group as a polyarc
g_layout_polygon( go, group = "v_group", group_order = NULL, group2 = NULL, group2_order = NULL, line_curved = 0.5 ) g_layout_polyarc( go, group = "v_group", group_order = NULL, group2 = NULL, group2_order = NULL, space = pi/4, scale_node_num = TRUE ) g_layout_polycircle( go, group = "v_group", group_order = NULL, group2 = NULL, group2_order = NULL )
g_layout_polygon( go, group = "v_group", group_order = NULL, group2 = NULL, group2_order = NULL, line_curved = 0.5 ) g_layout_polyarc( go, group = "v_group", group_order = NULL, group2 = NULL, group2_order = NULL, space = pi/4, scale_node_num = TRUE ) g_layout_polycircle( go, group = "v_group", group_order = NULL, group2 = NULL, group2_order = NULL )
go |
igraph |
group |
group name (default:v_group) |
group_order |
group_order |
group2 |
group2 name, will order nodes in each group according to group2_order |
group2_order |
group2_order |
line_curved |
line_curved 0~1 |
space |
the space between each arc, default: pi/4 |
scale_node_num |
scale with the node number in each group |
coors
Other g_layout:
g_layout_nice()
,
g_layout()
g_layout_polygon(multi1) -> oridata c_net_plot(multi1, oridata) g_layout_polyarc(multi1, group2 = "v_class", group2_order = c(LETTERS[4:1])) -> oridata c_net_plot(multi1, oridata) g_layout_polycircle(co_net2, group2 = "v_class") -> oridata c_net_plot(co_net2, oridata)
g_layout_polygon(multi1) -> oridata c_net_plot(multi1, oridata) g_layout_polyarc(multi1, group2 = "v_class", group2_order = c(LETTERS[4:1])) -> oridata c_net_plot(multi1, oridata) g_layout_polycircle(co_net2, group2 = "v_class") -> oridata c_net_plot(co_net2, oridata)
Get community
get_community(go_m)
get_community(go_m)
go_m |
module metanet |
community
Other module:
filter_n_module()
,
get_module_eigen()
,
get_module()
,
module_detect()
,
module_eigen()
,
module_net()
,
summary_module()
,
to_module_net()
,
zp_analyse()
Get edge information
get_e(go, index = NULL)
get_e(go, index = NULL)
go |
metanet object |
index |
attribute name, default: NULL |
data.frame
Other manipulate:
anno_edge()
,
anno_vertex()
,
c_net_annotate()
,
c_net_filter()
,
c_net_load()
,
c_net_save()
,
c_net_union()
,
get_n()
,
get_v()
,
is_metanet()
Get skeleton network according to a group
Skeleton plot
get_group_skeleton(go, Group = "v_class", count = NULL, top_N = 8) skeleton_plot(ske_net, split_e_type = TRUE, ...)
get_group_skeleton(go, Group = "v_class", count = NULL, top_N = 8) skeleton_plot(ske_net, split_e_type = TRUE, ...)
go |
network |
Group |
vertex column name |
count |
take which column count, default: NULL |
top_N |
top_N |
ske_net |
skeleton |
split_e_type |
split by e_type? default: TRUE |
... |
additional parameters for |
skeleton network
Other topological:
extract_sample_net()
,
fit_power()
,
links_stat()
,
nc()
,
net_par()
,
rand_net_par()
,
rand_net()
,
smallworldness()
get_group_skeleton(co_net) -> ske_net skeleton_plot(ske_net)
get_group_skeleton(co_net) -> ske_net skeleton_plot(ske_net)
Get module
get_module(go_m)
get_module(go_m)
go_m |
module metanet |
module
Other module:
filter_n_module()
,
get_community()
,
get_module_eigen()
,
module_detect()
,
module_eigen()
,
module_net()
,
summary_module()
,
to_module_net()
,
zp_analyse()
Get module_eigen
get_module_eigen(go_m)
get_module_eigen(go_m)
go_m |
module metanet |
module_eigen
Other module:
filter_n_module()
,
get_community()
,
get_module()
,
module_detect()
,
module_eigen()
,
module_net()
,
summary_module()
,
to_module_net()
,
zp_analyse()
Get network information
get_n(go, index = NULL, simple = FALSE)
get_n(go, index = NULL, simple = FALSE)
go |
metanet object |
index |
attribute name, default: NULL |
simple |
logical, get simple index |
data.frame
Other manipulate:
anno_edge()
,
anno_vertex()
,
c_net_annotate()
,
c_net_filter()
,
c_net_load()
,
c_net_save()
,
c_net_union()
,
get_e()
,
get_v()
,
is_metanet()
Get vertex information
get_v(go, index = NULL)
get_v(go, index = NULL)
go |
metanet object |
index |
attribute name, default: NULL |
data.frame
Other manipulate:
anno_edge()
,
anno_vertex()
,
c_net_annotate()
,
c_net_filter()
,
c_net_load()
,
c_net_save()
,
c_net_union()
,
get_e()
,
get_n()
,
is_metanet()
Input a graphml file exported by Gephi
input_gephi(file)
input_gephi(file)
file |
graphml file exported by Gephi |
list contains the igraph object and coordinates
Other plot:
as.ggig()
,
c_net_plot()
,
netD3plot()
,
olympic_rings_net()
,
plot.ggig()
,
twocol_edgelist()
,
venn_net()
Is this object a metanet object?
is_metanet(go)
is_metanet(go)
go |
a test object |
logical
Other manipulate:
anno_edge()
,
anno_vertex()
,
c_net_annotate()
,
c_net_filter()
,
c_net_load()
,
c_net_save()
,
c_net_union()
,
get_e()
,
get_n()
,
get_v()
data(c_net) is_metanet(co_net)
data(c_net) is_metanet(co_net)
Link summary of the network
links_stat( go, group = "v_class", e_type = "all", topN = 10, colors = NULL, mode = 1, plot_param = list() )
links_stat( go, group = "v_class", e_type = "all", topN = 10, colors = NULL, mode = 1, plot_param = list() )
go |
igraph or metanet |
group |
summary which group of vertex attribution in names(vertex_attr(go)) |
e_type |
"positive", "negative", "all" |
topN |
topN of group, default: 10 |
colors |
colors |
mode |
1~2 |
plot_param |
plot parameters |
plot
Other topological:
extract_sample_net()
,
fit_power()
,
get_group_skeleton()
,
nc()
,
net_par()
,
rand_net_par()
,
rand_net()
,
smallworldness()
if (requireNamespace("circlize")) { links_stat(co_net, topN = 10) module_detect(co_net) -> co_net_modu links_stat(co_net_modu, group = "module") } if (requireNamespace("corrplot")) { links_stat(co_net, topN = 10, mode = 2) }
if (requireNamespace("circlize")) { links_stat(co_net, topN = 10) module_detect(co_net) -> co_net_modu links_stat(co_net_modu, group = "module") } if (requireNamespace("corrplot")) { links_stat(co_net, topN = 10, mode = 2) }
Detect the modules
module_detect( go, method = "cluster_fast_greedy", n_node_in_module = 0, delete = FALSE )
module_detect( go, method = "cluster_fast_greedy", n_node_in_module = 0, delete = FALSE )
go |
an igraph object |
method |
cluster_method: "cluster_walktrap", "cluster_edge_betweenness", "cluster_fast_greedy", "cluster_spinglass" |
n_node_in_module |
transfer the modules less than n_node_in_module to "others" |
delete |
logical, delete others modules? default:FALSE, the others module will be "others". |
an igraph object
Other module:
filter_n_module()
,
get_community()
,
get_module_eigen()
,
get_module()
,
module_eigen()
,
module_net()
,
summary_module()
,
to_module_net()
,
zp_analyse()
data("c_net") module_detect(co_net) -> co_net_modu
data("c_net") module_detect(co_net) -> co_net_modu
Calculate the eigenvalue of each module and correlation of nodes and eigenvalue (node_eigen_cor).
Plot the expression of each modules
module_eigen(go_m, totu, cor_method = "spearman") module_expression( go_m, totu, group = NULL, r_threshold = 0.6, x_order = NULL, facet_param = NULL, plot_eigen = FALSE )
module_eigen(go_m, totu, cor_method = "spearman") module_expression( go_m, totu, group = NULL, r_threshold = 0.6, x_order = NULL, facet_param = NULL, plot_eigen = FALSE )
go_m |
module metanet |
totu |
original abundance table used for module_eigen(). |
cor_method |
"pearson", "kendall", "spearman" |
group |
group variable for totu |
r_threshold |
the threshold for node_eigen_cor, default: 0.6. |
x_order |
order the x axis. |
facet_param |
parameters parse to |
plot_eigen |
plot the eigen value line. |
module metanet with module_eigen
Other module:
filter_n_module()
,
get_community()
,
get_module_eigen()
,
get_module()
,
module_detect()
,
module_net()
,
summary_module()
,
to_module_net()
,
zp_analyse()
data("otutab", package = "pcutils") t(otutab) -> totu data("c_net") module_detect(co_net, n_node_in_module = 30) -> co_net_modu module_eigen(co_net_modu, totu) -> co_net_modu module_expression(co_net_modu, totu)
data("otutab", package = "pcutils") t(otutab) -> totu data("c_net") module_detect(co_net, n_node_in_module = 30) -> co_net_modu module_eigen(co_net_modu, totu) -> co_net_modu module_expression(co_net_modu, totu)
this is just a random generation method, the module number of result is not exactly the module_number, you can change the inter_module_density and intra_module_density to get the proper result.
module_net( module_number = 3, n_node_in_module = 30, intra_module_density = 0.3, inter_module_density = 0.01 )
module_net( module_number = 3, n_node_in_module = 30, intra_module_density = 0.3, inter_module_density = 0.01 )
module_number |
number of modules |
n_node_in_module |
number of nodes in each modules |
intra_module_density |
intra_module_density, recommend bigger than 20*inter_module_density, default:0.3 |
inter_module_density |
inter_module_density, default:0.01 |
n-modules metanet
Other module:
filter_n_module()
,
get_community()
,
get_module_eigen()
,
get_module()
,
module_detect()
,
module_eigen()
,
summary_module()
,
to_module_net()
,
zp_analyse()
g1 <- module_net() get_n(g1) plot(g1, mark_module = TRUE) plot(g1, coors = g_layout(g1, zoom2 = 20)) plot(g1, coors = g_layout_polyarc(g1, group = "module")) plot(g1, coors = g_layout_polygon(g1, group = "module"))
g1 <- module_net() get_n(g1) plot(g1, mark_module = TRUE) plot(g1, coors = g_layout(g1, zoom2 = 20)) plot(g1, coors = g_layout_polyarc(g1, group = "module")) plot(g1, coors = g_layout_polygon(g1, group = "module"))
Multi-omics network build
multi_net_build( ..., mode = "full", method = "spearman", filename = FALSE, p.adjust.method = NULL, r_threshold = 0.6, p_threshold = 0.05, use_p_adj = TRUE, delete_single = TRUE )
multi_net_build( ..., mode = "full", method = "spearman", filename = FALSE, p.adjust.method = NULL, r_threshold = 0.6, p_threshold = 0.05, use_p_adj = TRUE, delete_single = TRUE )
... |
some omics abundance tables |
mode |
"full" |
method |
"spearman" or "pearson" |
filename |
the prefix of saved .corr file or FALSE |
p.adjust.method |
see |
r_threshold |
r_threshold (default: >0.6) |
p_threshold |
p_threshold (default: <0.05) |
use_p_adj |
use the p.adjust instead of p-value (default: TRUE) |
delete_single |
should delete single vertexes? |
metanet
Other build:
c_net_build()
,
c_net_from_edgelist()
,
c_net_set()
,
c_net_update()
data("multi_test") multi1 <- multi_net_build(list(Microbiome = micro, Metabolome = metab, Transcriptome = transc)) multi1 <- c_net_set(multi1, micro_g, metab_g, transc_g, vertex_class = c("Phylum", "kingdom", "type") ) multi1 <- c_net_set(multi1, data.frame("Abundance1" = colSums(micro)), data.frame("Abundance2" = colSums(metab)), data.frame("Abundance3" = colSums(transc)), vertex_size = paste0("Abundance", 1:3) ) c_net_plot(multi1)
data("multi_test") multi1 <- multi_net_build(list(Microbiome = micro, Metabolome = metab, Transcriptome = transc)) multi1 <- c_net_set(multi1, micro_g, metab_g, transc_g, vertex_class = c("Phylum", "kingdom", "type") ) multi1 <- c_net_set(multi1, data.frame("Abundance1" = colSums(micro)), data.frame("Abundance2" = colSums(metab)), data.frame("Abundance3" = colSums(transc)), vertex_size = paste0("Abundance", 1:3) ) c_net_plot(multi1)
Calculate natural_connectivity
nc(p)
nc(p)
p |
an igraph or metanet object |
natural_connectivity (numeric)
`nc` in `ggClusterNet`
Other topological:
extract_sample_net()
,
fit_power()
,
get_group_skeleton()
,
links_stat()
,
net_par()
,
rand_net_par()
,
rand_net()
,
smallworldness()
igraph::make_ring(10) %>% nc()
igraph::make_ring(10) %>% nc()
Calculate all topological indexes of a network
Add topological indexes for a network
net_par( go, mode = c("v", "e", "n", "all"), fast = TRUE, remove_negative = FALSE ) c_net_index(go, force = FALSE)
net_par( go, mode = c("v", "e", "n", "all"), fast = TRUE, remove_negative = FALSE ) c_net_index(go, force = FALSE)
go |
igraph or metanet |
mode |
calculate what? c("v", "e", "n", "all") |
fast |
less indexes for faster calculate ? |
remove_negative |
remove negative edge or not? default: FALSE |
force |
replace existed net_par |
a 3-elements list
n_index |
indexs of the whole network |
v_index |
indexs of each vertex |
e_index |
indexs of each edge |
Other topological:
extract_sample_net()
,
fit_power()
,
get_group_skeleton()
,
links_stat()
,
nc()
,
rand_net_par()
,
rand_net()
,
smallworldness()
igraph::make_graph("Walther") %>% net_par() c_net_index(co_net) -> co_net_with_par
igraph::make_graph("Walther") %>% net_par() c_net_index(co_net) -> co_net_with_par
plot use networkD3
netD3plot(go, v_class = "v_class", ...)
netD3plot(go, v_class = "v_class", ...)
go |
metanet |
v_class |
which attributes use to be v_class |
... |
see |
D3 plot
Other plot:
as.ggig()
,
c_net_plot()
,
input_gephi()
,
olympic_rings_net()
,
plot.ggig()
,
twocol_edgelist()
,
venn_net()
data("c_net") plot(co_net2) if (requireNamespace("networkD3")) { netD3plot(co_net2) }
data("c_net") plot(co_net2) if (requireNamespace("networkD3")) { netD3plot(co_net2) }
Plot olympic rings using network
olympic_rings_net()
olympic_rings_net()
network plot
Other plot:
as.ggig()
,
c_net_plot()
,
input_gephi()
,
netD3plot()
,
plot.ggig()
,
twocol_edgelist()
,
venn_net()
olympic_rings_net()
olympic_rings_net()
p.adjust apply on a correlation table (matrix or data.frame)
p.adjust.table(pp, method = "BH", mode = "all")
p.adjust.table(pp, method = "BH", mode = "all")
pp |
table of p-values |
method |
see |
mode |
"all" for all values; "rows" adjust each row one by one; "columns" adjust each column one by one. Default: "all". |
a table of adjusted p-values
Other calculate:
c_net_calculate()
,
cal_sim()
,
fast_cor()
,
read_corr()
matrix(abs(rnorm(100, 0.01, 0.1)), 10, 10) -> pp p.adjust.table(pp, method = "BH", mode = "all") -> pp_adj
matrix(abs(rnorm(100, 0.01, 0.1)), 10, 10) -> pp p.adjust.table(pp, method = "BH", mode = "all") -> pp_adj
Plot a ggig
## S3 method for class 'ggig' plot( x, coors = NULL, ..., labels_num = NULL, vertex_size_range = NULL, edge_width_range = NULL, plot_module = FALSE, mark_module = FALSE, mark_color = NULL, mark_alpha = 0.3, module_label = FALSE, module_label_cex = 2, module_label_color = "black", module_label_just = c(0.5, 0.5), legend_number = FALSE, legend = TRUE, legend_cex = 1, legend_position = c(left_leg_x = -2, left_leg_y = 1, right_leg_x = 1.2, right_leg_y = 1), group_legend_title = NULL, group_legend_order = NULL, color_legend = TRUE, color_legend_order = NULL, size_legend = FALSE, size_legend_title = "Node Size", edge_legend = TRUE, edge_legend_title = "Edge type", edge_legend_order = NULL, width_legend = FALSE, width_legend_title = "Edge width", lty_legend = FALSE, lty_legend_title = "Edge class", lty_legend_order = NULL, params_list = NULL, seed = 1234 )
## S3 method for class 'ggig' plot( x, coors = NULL, ..., labels_num = NULL, vertex_size_range = NULL, edge_width_range = NULL, plot_module = FALSE, mark_module = FALSE, mark_color = NULL, mark_alpha = 0.3, module_label = FALSE, module_label_cex = 2, module_label_color = "black", module_label_just = c(0.5, 0.5), legend_number = FALSE, legend = TRUE, legend_cex = 1, legend_position = c(left_leg_x = -2, left_leg_y = 1, right_leg_x = 1.2, right_leg_y = 1), group_legend_title = NULL, group_legend_order = NULL, color_legend = TRUE, color_legend_order = NULL, size_legend = FALSE, size_legend_title = "Node Size", edge_legend = TRUE, edge_legend_title = "Edge type", edge_legend_order = NULL, width_legend = FALSE, width_legend_title = "Edge width", lty_legend = FALSE, lty_legend_title = "Edge class", lty_legend_order = NULL, params_list = NULL, seed = 1234 )
x |
ggig object |
coors |
the coordinates you saved |
... |
additional parameters for |
labels_num |
show how many labels, >1 indicates number, <1 indicates fraction, "all" indicates all. |
vertex_size_range |
the vertex size range, e.g. c(1,10) |
edge_width_range |
the edge width range, e.g. c(1,10) |
plot_module |
logical, plot module? |
mark_module |
logical, mark the modules? |
mark_color |
mark color |
mark_alpha |
mark fill alpha, default 0.3 |
module_label |
show module label? |
module_label_cex |
module label cex |
module_label_color |
module label color |
module_label_just |
module label just, default c(0.5,0.5) |
legend_number |
legend with numbers |
legend |
all legends |
legend_cex |
character expansion factor relative to current par("cex"), default: 1 |
legend_position |
legend_position, default: c(left_leg_x=-1.9,left_leg_y=1,right_leg_x=1.2,right_leg_y=1) |
group_legend_title |
group_legend_title, length must same to the numbers of v_group |
group_legend_order |
group_legend_order vector |
color_legend |
logical |
color_legend_order |
color_legend_order vector |
size_legend |
logical |
size_legend_title |
size_legend_title |
edge_legend |
logical |
edge_legend_title |
edge_legend_title |
edge_legend_order |
edge_legend_order vector, e.g. c("positive","negative") |
width_legend |
logical |
width_legend_title |
width_legend_title |
lty_legend |
logical |
lty_legend_title |
lty_legend_title |
lty_legend_order |
lty_legend_order |
params_list |
a list of parameters, e.g. list(edge_legend = TRUE, lty_legend = FALSE), when the parameter is duplicated, the format argument will be used rather than the argument in params_list. |
seed |
random seed, default:1234, make sure each plot is the same. |
ggplot
Other plot:
as.ggig()
,
c_net_plot()
,
input_gephi()
,
netD3plot()
,
olympic_rings_net()
,
twocol_edgelist()
,
venn_net()
Plot a metanet
## S3 method for class 'metanet' plot(x, ...)
## S3 method for class 'metanet' plot(x, ...)
x |
metanet object |
... |
add |
plot
Plot a rmt_res
## S3 method for class 'rmt_res' plot(x, ...)
## S3 method for class 'rmt_res' plot(x, ...)
x |
rmt_res |
... |
Additional arguments |
ggplot
Plot robust
## S3 method for class 'robust' plot( x, indexes = c("Natural_connectivity", "Average_degree"), use_ratio = FALSE, mode = 1, ... )
## S3 method for class 'robust' plot( x, indexes = c("Natural_connectivity", "Average_degree"), use_ratio = FALSE, mode = 1, ... )
x |
|
indexes |
indexes selected to show |
use_ratio |
use the delete nodes ratio rather than nodes number |
mode |
plot mode, 1~3 |
... |
additional arguments for |
a ggplot
Plot robustness
## S3 method for class 'robustness' plot(x, indexes = "Node_number", ...)
## S3 method for class 'robustness' plot(x, indexes = "Node_number", ...)
x |
|
indexes |
indexes selected to show |
... |
additional arguments for |
a ggplot
Plot vulnerability
## S3 method for class 'vulnerability' plot(x, ...)
## S3 method for class 'vulnerability' plot(x, ...)
x |
|
... |
add |
a ggplot
Print method for 'cohesion' objects
## S3 method for class 'cohesion' print(x, ...)
## S3 method for class 'cohesion' print(x, ...)
x |
'cohesion' object |
... |
Additional arguments |
No value
Print method for 'coors' objects
## S3 method for class 'coors' print(x, ...)
## S3 method for class 'coors' print(x, ...)
x |
'coors' object |
... |
additional arguments |
No value
Print method for 'corr' objects
## S3 method for class 'corr' print(x, ...)
## S3 method for class 'corr' print(x, ...)
x |
'corr' object |
... |
additional arguments |
No value
Print method for 'ggig' objects
## S3 method for class 'ggig' print(x, ...)
## S3 method for class 'ggig' print(x, ...)
x |
'ggig' object |
... |
Additional arguments |
No value
Print method for 'metanet' objects
## S3 method for class 'metanet' print(x, ...)
## S3 method for class 'metanet' print(x, ...)
x |
'metanet' object |
... |
Additional arguments |
No value
Print method for 'robust' objects
## S3 method for class 'robust' print(x, ...)
## S3 method for class 'robust' print(x, ...)
x |
'robust' object |
... |
Additional arguments |
No value
Print method for 'robustness' objects
## S3 method for class 'robustness' print(x, ...)
## S3 method for class 'robustness' print(x, ...)
x |
'robustness' object |
... |
Additional arguments |
No value
Print method for 'vulnerability' objects
## S3 method for class 'vulnerability' print(x, ...)
## S3 method for class 'vulnerability' print(x, ...)
x |
'vulnerability' object |
... |
Additional arguments |
No value
Degree distribution comparison with random network
rand_net(go = go, plot = TRUE)
rand_net(go = go, plot = TRUE)
go |
igraph object |
plot |
plot or not |
ggplot
Other topological:
extract_sample_net()
,
fit_power()
,
get_group_skeleton()
,
links_stat()
,
nc()
,
net_par()
,
rand_net_par()
,
smallworldness()
rand_net(co_net)
rand_net(co_net)
Net_pars of many random network
Compare some indexes between your net with random networks
rand_net_par(go, reps = 99, threads = 1, verbose = TRUE) compare_rand( pars, randp, index = c("Average_path_length", "Clustering_coefficient") )
rand_net_par(go, reps = 99, threads = 1, verbose = TRUE) compare_rand( pars, randp, index = c("Average_path_length", "Clustering_coefficient") )
go |
igraph |
reps |
simulation time |
threads |
threads |
verbose |
verbose |
pars |
your net pars resulted by net_pars() |
randp |
random networks pars resulted by rand_net_par() |
index |
compared indexes: "Average_path_length","Clustering_coefficient" or else |
ggplot
Other topological:
extract_sample_net()
,
fit_power()
,
get_group_skeleton()
,
links_stat()
,
nc()
,
net_par()
,
rand_net()
,
smallworldness()
data("c_net") rand_net_par(co_net_rmt, reps = 30) -> randp net_par(co_net_rmt, fast = FALSE) -> pars compare_rand(pars, randp)
data("c_net") rand_net_par(co_net_rmt, reps = 30) -> randp net_par(co_net_rmt, fast = FALSE) -> pars compare_rand(pars, randp)
Read a corr object
read_corr(filename)
read_corr(filename)
filename |
filename of .corr |
a corr object
Other calculate:
c_net_calculate()
,
cal_sim()
,
fast_cor()
,
p.adjust.table()
Get RMT threshold for a correlation matrix
Get RMT threshold for a correlation matrix roughly
RMT_threshold( occor.r, out_dir, min_threshold = 0.5, max_threshold = 0.8, step = 0.02, gif = FALSE, verbose = FALSE ) rmt(occor.r, min_threshold = 0.5, max_threshold = 0.85, step = 0.01)
RMT_threshold( occor.r, out_dir, min_threshold = 0.5, max_threshold = 0.8, step = 0.02, gif = FALSE, verbose = FALSE ) rmt(occor.r, min_threshold = 0.5, max_threshold = 0.85, step = 0.01)
occor.r |
a corr object or a correlation matrix |
out_dir |
output dir |
min_threshold |
min_threshold |
max_threshold |
max_threshold |
step |
step |
gif |
render a .gif file? |
verbose |
verbose |
a r-threshold
recommend threshold
J. Zhou, Y. Deng, FALSE. Luo, Z. He, Q. Tu, X. Zhi, (2010) Functional Molecular Ecological Networks, doi:10.1128/mBio.00169-10. https://matstat.org/content_en/RMT/RMThreshold_Intro.pdf
data(otutab, package = "pcutils") t(otutab) -> totu c_net_calculate(totu) -> corr rmt(corr) # recommend: 0.69 c_net_build(corr, r_threshold = 0.69) -> co_net_rmt
data(otutab, package = "pcutils") t(otutab) -> totu c_net_calculate(totu) -> corr rmt(corr) # recommend: 0.69 c_net_build(corr, r_threshold = 0.69) -> co_net_rmt
Save a corr object
save_corr(corr, filename = "corr")
save_corr(corr, filename = "corr")
corr |
a corr object |
filename |
filename without extension, default: "corr" |
a .corr file
Show MetaNet logo
show_MetaNet_logo()
show_MetaNet_logo()
picture
Calculate small-world coefficient
smallworldness(go, reps = 99, threads = 1, verbose = TRUE)
smallworldness(go, reps = 99, threads = 1, verbose = TRUE)
go |
igraph or metanet |
reps |
simulation time |
threads |
threads |
verbose |
verbose |
number
Other topological:
extract_sample_net()
,
fit_power()
,
get_group_skeleton()
,
links_stat()
,
nc()
,
net_par()
,
rand_net_par()
,
rand_net()
# set reps at least 99 when you run. smallworldness(co_net, reps = 9)
# set reps at least 99 when you run. smallworldness(co_net, reps = 9)
Summaries two columns information
summ_2col(df, from = 1, to = 2, count = 3, direct = FALSE)
summ_2col(df, from = 1, to = 2, count = 3, direct = FALSE)
df |
data.frame |
from |
first column name or index |
to |
second column name or index |
count |
(optional) weight column, if no, each equal to 1 |
direct |
consider direct? default: FALSE |
data.frame
test <- data.frame( a = sample(letters[1:4], 10, replace = TRUE), b = sample(letters[1:4], 10, replace = TRUE) ) summ_2col(test, direct = TRUE) summ_2col(test, direct = FALSE) if (requireNamespace("circlize")) { summ_2col(test, direct = TRUE) %>% pcutils::my_circo() }
test <- data.frame( a = sample(letters[1:4], 10, replace = TRUE), b = sample(letters[1:4], 10, replace = TRUE) ) summ_2col(test, direct = TRUE) summ_2col(test, direct = FALSE) if (requireNamespace("circlize")) { summ_2col(test, direct = TRUE) %>% pcutils::my_circo() }
Summary module index
summary_module(go_m, var = "v_class", module = "module", ...)
summary_module(go_m, var = "v_class", module = "module", ...)
go_m |
module metanet |
var |
variable name |
module |
which column name is module. default: "module" |
... |
add |
ggplot
Other module:
filter_n_module()
,
get_community()
,
get_module_eigen()
,
get_module()
,
module_detect()
,
module_eigen()
,
module_net()
,
to_module_net()
,
zp_analyse()
data("c_net") module_detect(co_net, n_node_in_module = 30) -> co_net_modu summary_module(co_net_modu, var = "v_class", module = "module") summary_module(co_net_modu, var = "Abundance", module = "module")
data("c_net") module_detect(co_net, n_node_in_module = 30) -> co_net_modu summary_module(co_net_modu, var = "v_class", module = "module") summary_module(co_net_modu, var = "Abundance", module = "module")
Summary method for 'corr' objects
## S3 method for class 'corr' summary(object, ...)
## S3 method for class 'corr' summary(object, ...)
object |
'corr' object |
... |
Additional arguments |
No value
Transformation a network to a module network
to_module_net(go, edge_type = c("module", "module_from", "module_to")[1])
to_module_net(go, edge_type = c("module", "module_from", "module_to")[1])
go |
metanet |
edge_type |
"module", "module_from", "module_to" |
metanet with modules
Other module:
filter_n_module()
,
get_community()
,
get_module_eigen()
,
get_module()
,
module_detect()
,
module_eigen()
,
module_net()
,
summary_module()
,
zp_analyse()
Quick build a metanet from two columns table
twocol_edgelist(edgelist)
twocol_edgelist(edgelist)
edgelist |
two columns table (no elements exist in two columns at same time) |
metanet
Other plot:
as.ggig()
,
c_net_plot()
,
input_gephi()
,
netD3plot()
,
olympic_rings_net()
,
plot.ggig()
,
venn_net()
twocol <- data.frame( "col1" = sample(letters, 30, replace = TRUE), "col2" = sample(c("A", "B"), 30, replace = TRUE) ) twocol_net <- twocol_edgelist(twocol) plot(twocol_net) c_net_plot(twocol_net, g_layout_polygon(twocol_net))
twocol <- data.frame( "col1" = sample(letters, 30, replace = TRUE), "col2" = sample(c("A", "B"), 30, replace = TRUE) ) twocol_net <- twocol_edgelist(twocol) plot(twocol_net) c_net_plot(twocol_net, g_layout_polygon(twocol_net))
Venn network
venn_net(tab)
venn_net(tab)
tab |
data.frame (row is elements, column is group), or a list (names is group, value is elements) |
plot
Other plot:
as.ggig()
,
c_net_plot()
,
input_gephi()
,
netD3plot()
,
olympic_rings_net()
,
plot.ggig()
,
twocol_edgelist()
data(otutab, package = "pcutils") tab <- otutab[400:485, 1:3] venn_net(tab) -> v_net plot(v_net)
data(otutab, package = "pcutils") tab <- otutab[400:485, 1:3] venn_net(tab) -> v_net plot(v_net)
Zi-Pi calculate
Zi-Pi plot of vertexes
zp_analyse(go_m, mode = 2, use_origin = TRUE) zp_plot(go, label = TRUE, mode = 1)
zp_analyse(go_m, mode = 2, use_origin = TRUE) zp_plot(go, label = TRUE, mode = 1)
go_m |
igraph object after |
mode |
plot style, 1~3 |
use_origin |
use original_module, default:TRUE, if FALSE, use module |
go |
igraph object after zp_analyse() |
label |
show label or not |
igraph
a ggplot object
GuimerĂ , R. & Amaral, L. Functional cartography of complex metabolic networks. (2005) doi:10.1038/nature03288.
Other module:
filter_n_module()
,
get_community()
,
get_module_eigen()
,
get_module()
,
module_detect()
,
module_eigen()
,
module_net()
,
summary_module()
,
to_module_net()
data("c_net") module_detect(co_net) -> co_net_modu zp_analyse(co_net_modu) -> co_net_modu zp_plot(co_net_modu) zp_plot(co_net_modu, mode = 3)
data("c_net") module_detect(co_net) -> co_net_modu zp_analyse(co_net_modu) -> co_net_modu zp_plot(co_net_modu) zp_plot(co_net_modu, mode = 3)