Package 'MetaNet'

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.1
Built: 2024-09-15 03:01:50 UTC
Source: https://github.com/asa12138/metanet

Help Index


Use dataframe to annotate edges of an igraph

Description

Use dataframe to annotate edges of an igraph

Usage

anno_edge(go, anno_tab, verbose = TRUE)

Arguments

go

metanet an igraph object

anno_tab

a dataframe using to annotate (with rowname or a name column)

verbose

logical

Value

a annotated igraph object

See Also

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

Examples

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

Description

Use data.frame to annotate vertexes of metanet

Usage

anno_vertex(go, anno_tab, verbose = TRUE)

Arguments

go

metanet object

anno_tab

a dataframe using to annotate (with rowname or a "name" column)

verbose

logical

Value

a annotated metanet object

See Also

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

Examples

data("c_net")
data("otutab", package = "pcutils")
anno_vertex(co_net, taxonomy)

Edgelist

Description

Edgelist for c_net_from_edgelist()


Edgelist

Description

Edgelist for c_net_from_edgelist()


Layout as a arc

Description

Layout as a arc

Usage

as_arc(angle = 0, arc = pi)

Arguments

angle

anticlockwise rotation angle

arc

the radian of arc

Value

A two-column matrix, each row giving the coordinates of a vertex, according to the ids of the vertex ids.

See Also

Other layout: as_circle_tree(), as_line(), as_polyarc(), as_polycircle(), as_polygon(), c_net_layout()

Examples

as_arc()(co_net)
c_net_plot(co_net, coors = as_arc(pi / 2), rescale = FALSE)

Layout as a circle_tree

Description

Layout as a circle_tree

Usage

as_circle_tree()

Value

A two-column matrix, each row giving the coordinates of a vertex, according to the ids of the vertex ids.

See Also

Other layout: as_arc(), as_line(), as_polyarc(), as_polycircle(), as_polygon(), c_net_layout()


Layout as a line

Description

Layout as a line

Usage

as_line(angle = 0)

Arguments

angle

anticlockwise rotation angle

Value

A two-column matrix, each row giving the coordinates of a vertex, according to the ids of the vertex ids.

See Also

Other layout: as_arc(), as_circle_tree(), as_polyarc(), as_polycircle(), as_polygon(), c_net_layout()

Examples

as_line()(co_net)
c_net_plot(co_net, coors = as_line(pi / 2))

Layout as a polyarc

Description

Layout as a polyarc

Usage

as_polyarc(n = 3, space = pi/3)

Arguments

n

how many arcs of this poly_arc

space

the space between each arc, default: pi/3

Value

A two-column matrix, each row giving the coordinates of a vertex, according to the ids of the vertex ids.

See Also

Other layout: as_arc(), as_circle_tree(), as_line(), as_polycircle(), as_polygon(), c_net_layout()

Examples

as_polyarc()(co_net)

Layout as a polycircle

Description

Layout as a polycircle

Usage

as_polycircle(n = 2)

Arguments

n

how many circles of this polycircle

Value

A two-column matrix, each row giving the coordinates of a vertex, according to the ids of the vertex ids.

See Also

Other layout: as_arc(), as_circle_tree(), as_line(), as_polyarc(), as_polygon(), c_net_layout()

Examples

as_polycircle()(co_net)

Layout as a polygon

Description

Layout as a polygon

Usage

as_polygon(n = 3, line_curved = 0.5)

Arguments

n

how many edges of this polygon

line_curved

line_curved 0~0.5

Value

A two-column matrix, each row giving the coordinates of a vertex, according to the ids of the vertex ids.

See Also

Other layout: as_arc(), as_circle_tree(), as_line(), as_polyarc(), as_polycircle(), c_net_layout()

Examples

as_polygon()(co_net)

Transfer an igraph object to a ggig

Description

Transfer an igraph object to a ggig

Usage

as.ggig(go, coors = NULL)

Arguments

go

igraph or meatnet

coors

coordinates for nodes,columns: name, X, Y

Value

ggig object

See Also

Other plot: c_net_plot(), input_gephi(), netD3plot(), olympic_rings_net(), plot.ggig(), twocol_edgelist(), venn_net()

Examples

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

Description

Annotate a metanet

Usage

c_net_annotate(go, anno_tab, mode = "v", verbose = TRUE)

Arguments

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

Value

a annotated metanet object

See Also

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

Examples

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

Description

Construct a metanet from a corr object

Usage

c_net_build(
  corr,
  r_threshold = 0.6,
  p_threshold = 0.05,
  use_p_adj = TRUE,
  delete_single = TRUE
)

Arguments

corr

corr object from c_net_calculate() or read_corr().

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?

Value

an metanet object

See Also

Other build: c_net_from_edgelist(), c_net_set(), c_net_update(), multi_net_build()

Examples

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

Description

Calculate correlation for one or two t(otutab), or distance for one t(otutab).

Usage

c_net_calculate(
  totu,
  totu2 = NULL,
  method = "spearman",
  filename = FALSE,
  p.adjust.method = NULL,
  p.adjust.mode = "all",
  threads = 1,
  verbose = TRUE
)

Arguments

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 vegdist.

filename

the prefix of saved .corr file or FALSE.

p.adjust.method

see p.adjust

p.adjust.mode

see p.adjust.table

threads

threads, default: 1.

verbose

verbose, default: TRUE.

Value

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

See Also

Other calculate: cal_sim(), fast_cor(), p.adjust.table(), read_corr()

Examples

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

Description

Filter a network according to some attributes

Usage

c_net_filter(go, ..., mode = "v")

Arguments

go

metanet object

...

some attributes of vertex and edge

mode

"v" or "e"

Value

metanet

See Also

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

Examples

data("multi_net")
c_net_filter(multi1, v_group %in% c("omic1", "omic2"))

Construct a network from edge_list dataframe

Description

Construct a network from edge_list dataframe

Usage

c_net_from_edgelist(
  edgelist,
  vertex_df = NULL,
  direct = FALSE,
  e_type = NULL,
  e_class = NULL
)

Arguments

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

Value

metanet

See Also

Other build: c_net_build(), c_net_set(), c_net_update(), multi_net_build()

Examples

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

Description

Layout coordinates

Usage

c_net_layout(
  go,
  method = igraph::nicely(),
  order_by = NULL,
  order_ls = NULL,
  seed = 1234,
  line_curved = 0.5,
  ...
)

Arguments

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 layout_; (3) a character, "auto","backbone","centrality","circlepack","dendrogram", "eigen","focus","hive","igraph","linear","manual","matrix", "partition","pmds","stress","treemap","unrooted". see create_layout

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

Value

coors object: coordinates for nodes, columns: name, X, Y; curved for edges, columns: from, to, curved;

See Also

Other layout: as_arc(), as_circle_tree(), as_line(), as_polyarc(), as_polycircle(), as_polygon()

Examples

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

Description

Load network file

Usage

c_net_load(filename, format = "data.frame")

Arguments

filename

filename

format

"data.frame","graphml"

Value

metanet

See Also

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

Description

Plot a metanet

Usage

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
)

Arguments

go

an igraph or metanet object

coors

the coordinates you saved

...

additional parameters for igraph.plotting

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.

Value

a network plot

See Also

Other plot: as.ggig(), input_gephi(), netD3plot(), olympic_rings_net(), plot.ggig(), twocol_edgelist(), venn_net()

Examples

data("c_net")
c_net_plot(co_net)
c_net_plot(co_net2)
c_net_plot(multi1)

Save network file

Description

Save network file

Usage

c_net_save(go, filename = "net", format = "data.frame")

Arguments

go

metanet network

filename

filename

format

"data.frame","graphml"

Value

No value

See Also

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

Description

Set basic attributes from totu table

Usage

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
)

Arguments

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

Value

a metanet object

See Also

Other build: c_net_build(), c_net_from_edgelist(), c_net_update(), multi_net_build()

Examples

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

Evaluate the stability of a network

Description

Vi=E−EiEVi=\frac{E-Ei}{E}

E is the global efficiency and Ei is the global efficiency after the removal of the node i and its entire links.

Usage

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)

Arguments

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)

Value

a data.frame

data.frame (robustness class)

a vector

Examples

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

Description

Union two networks

Usage

c_net_union(go1, go2)

Arguments

go1

metanet object

go2

metanet object

Value

metanet

See Also

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

Examples

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

Description

Update a metanet object or transform igraph object to metanet object

Usage

c_net_update(
  go,
  node_break = 5,
  edge_break = 5,
  initialize = FALSE,
  verbose = TRUE,
  uniq_v_class = FALSE
)

Arguments

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.

Value

metanet

See Also

Other build: c_net_build(), c_net_from_edgelist(), c_net_set(), multi_net_build()


Calculate similarity for one t(otutab)

Description

Calculate similarity for one t(otutab)

Usage

cal_sim(totu, totu2 = NULL, method = "bray")

Arguments

totu

t(otutab), row are samples, column are features.

totu2

t(otutab) or NULL, row are samples, column are features.

method

Dissimilarity index, see vegdist.

Value

similarity = 1-distance

See Also

vegdist

Other calculate: c_net_calculate(), fast_cor(), p.adjust.table(), read_corr()

Examples

if (requireNamespace("vegan")) {
  data("otutab", package = "pcutils")
  t(otutab) -> totu
  cal_sim(totu) -> sim_corr
}

Check tables and extract common samples

Description

Check tables and extract common samples

Usage

check_tabs(...)

Arguments

...

tables

Value

formatted tables

Examples

data("otutab", package = "pcutils")
check_tabs(otutab)

Clean a igraph object

Description

Clean a igraph object

Usage

clean_igraph(go, direct = TRUE)

Arguments

go

igraph, metanet objects

direct

direct?

Value

a igraph object


Clean multi edge metanet to plot

Description

Clean multi edge metanet to plot

Usage

clean_multi_edge_metanet(go)

Arguments

go

metanet object

Value

metanet object

Examples

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

MetaNet networks

Description

MetaNet co_nets


MetaNet networks

Description

MetaNet co_nets


MetaNet networks

Description

MetaNet co_nets


Cohesion calculation

Description

Cohesion calculation

Plot cohesion

Usage

Cohesion(otutab, reps = 200, threads = 1, mycor = NULL, verbose = TRUE)

## S3 method for class 'cohesion'
plot(x, group, metadata, mode = 1, ...)

Arguments

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

Cohesion() result (cohesion object)

group

group name in colnames(metadata)

metadata

metadata

mode

plot mode, 1~2

...

additional arguments for group_box (mode=1) or group_box (mode=2)

Value

Cohesion object: a list with two dataframe

a ggplot

References

Herren, C. M. & McMahon, K. (2017) Cohesion: a method for quantifying the connectivity of microbial communities. doi:10.1038/ismej.2017.91.

Examples

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.

Description

Transform a dataframe to a network edgelist.

Usage

df2net_tree(test, fun = sum)

Arguments

test

df

fun

default: sum

Value

metanet

Examples

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

Description

Extract each sample network from the whole network

Usage

extract_sample_net(
  whole_net,
  otutab,
  threads = 1,
  save_net = FALSE,
  fast = TRUE,
  remove_negative = FALSE,
  verbose = TRUE
)

Arguments

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

Value

a dataframe contains all sub_net parameters

See Also

Other topological: fit_power(), get_group_skeleton(), links_stat(), nc(), net_par(), rand_net_par(), rand_net(), smallworldness()

Examples

data(otutab, package = "pcutils")
extract_sample_net(co_net, otutab) -> sub_net_pars

Fast correlation calculation

Description

Fast correlation calculation

Usage

fast_cor(totu, totu2 = NULL, method = c("pearson", "spearman"))

Arguments

totu

t(otutab), row are samples, column are features.

totu2

t(otutab) or NULL, row are samples, column are features.

method

"spearman" or "pearson"

Value

a list with 2 elements:

r

default: spearman correlation

p.value

default: p-value of spearman correlation

See Also

Other calculate: c_net_calculate(), cal_sim(), p.adjust.table(), read_corr()

Examples

data("otutab", package = "pcutils")
t(otutab[1:100, ]) -> totu
fast_cor(totu, method = "spearman") -> corr

Filter some modules as others

Description

Filter some modules as others

Combine or cut modules to module_number

Plot module tree

Usage

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)

Arguments

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

Value

metanet with modules

ggplot

See Also

Other module: get_community(), get_module_eigen(), get_module(), module_detect(), module_eigen(), module_net(), summary_module(), to_module_net(), zp_analyse()

Examples

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

Description

Fit power-law distribution for an igraph

Usage

fit_power(go, p.value = FALSE)

Arguments

go

igraph

p.value

calculate p.value

Value

ggplot

See Also

Other topological: extract_sample_net(), get_group_skeleton(), links_stat(), nc(), net_par(), rand_net_par(), rand_net(), smallworldness()

Examples

fit_power(co_net)

Layout with group

Description

Layout with group

Usage

g_layout(
  go,
  group = "module",
  group_order = NULL,
  layout1 = in_circle(),
  zoom1 = 20,
  layout2 = in_circle(),
  zoom2 = 3,
  show_big_layout = FALSE,
  ...
)

Arguments

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 c_net_layout default: in_circle()

zoom1

big network layout size

layout2

one of functions: layout method for c_net_layout, or a list of functions.

zoom2

average sub_network layout size, or numeric vector, or "auto"

show_big_layout

show the big layout to help you adjust.

...

add

Value

coors

See Also

Other g_layout: g_layout_nice(), g_layout_polygon()

Examples

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

Description

Layout with group nicely

Usage

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", ...)

Arguments

go

igraph or metanet

group

group name (default: module)

mode

circlepack, treemap, backbone, stress

...

add

Value

coors

See Also

Other g_layout: g_layout_polygon(), g_layout()

Examples

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

Description

Layout with group as a polygon

Layout with group as a polyarc

Layout with group as a polyarc

Usage

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
)

Arguments

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

Value

coors

See Also

Other g_layout: g_layout_nice(), g_layout()

Examples

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

Description

Get community

Usage

get_community(go_m)

Arguments

go_m

module metanet

Value

community

See Also

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

Description

Get edge information

Usage

get_e(go, index = NULL)

Arguments

go

metanet object

index

attribute name, default: NULL

Value

data.frame

See Also

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

Description

Get skeleton network according to a group

Skeleton plot

Usage

get_group_skeleton(go, Group = "v_class", count = NULL, top_N = 8)

skeleton_plot(ske_net, split_e_type = TRUE, ...)

Arguments

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 igraph.plotting

Value

skeleton network

See Also

Other topological: extract_sample_net(), fit_power(), links_stat(), nc(), net_par(), rand_net_par(), rand_net(), smallworldness()

Examples

get_group_skeleton(co_net) -> ske_net
skeleton_plot(ske_net)

Get module

Description

Get module

Usage

get_module(go_m)

Arguments

go_m

module metanet

Value

module

See Also

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

Description

Get module_eigen

Usage

get_module_eigen(go_m)

Arguments

go_m

module metanet

Value

module_eigen

See Also

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

Description

Get network information

Usage

get_n(go, index = NULL, simple = FALSE)

Arguments

go

metanet object

index

attribute name, default: NULL

simple

logical, get simple index

Value

data.frame

See Also

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

Description

Get vertex information

Usage

get_v(go, index = NULL)

Arguments

go

metanet object

index

attribute name, default: NULL

Value

data.frame

See Also

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

Description

Input a graphml file exported by Gephi

Usage

input_gephi(file)

Arguments

file

graphml file exported by Gephi

Value

list contains the igraph object and coordinates

See Also

Other plot: as.ggig(), c_net_plot(), netD3plot(), olympic_rings_net(), plot.ggig(), twocol_edgelist(), venn_net()


Is this object a metanet object?

Description

Is this object a metanet object?

Usage

is_metanet(go)

Arguments

go

a test object

Value

logical

See Also

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

Examples

data(c_net)
is_metanet(co_net)

MetaNet networks abundance

Description

MetaNet co_nets


MetaNet networks metadata

Description

MetaNet co_nets


MetaNet networks abundance

Description

MetaNet co_nets


MetaNet networks metadata

Description

MetaNet co_nets


Detect the modules

Description

Detect the modules

Usage

module_detect(
  go,
  method = "cluster_fast_greedy",
  n_node_in_module = 0,
  delete = FALSE
)

Arguments

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".

Value

an igraph object

See Also

Other module: filter_n_module(), get_community(), get_module_eigen(), get_module(), module_eigen(), module_net(), summary_module(), to_module_net(), zp_analyse()

Examples

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

Description

Calculate the eigenvalue of each module and correlation of nodes and eigenvalue (node_eigen_cor).

Plot the expression of each modules

Usage

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
)

Arguments

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 facet_wrap, e.g. nrow=2.

plot_eigen

plot the eigen value line.

Value

module metanet with module_eigen

See Also

Other module: filter_n_module(), get_community(), get_module_eigen(), get_module(), module_detect(), module_net(), summary_module(), to_module_net(), zp_analyse()

Examples

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)

Generate a n-modules network

Description

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.

Usage

module_net(
  module_number = 3,
  n_node_in_module = 30,
  intra_module_density = 0.3,
  inter_module_density = 0.01
)

Arguments

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

Value

n-modules metanet

See Also

Other module: filter_n_module(), get_community(), get_module_eigen(), get_module(), module_detect(), module_eigen(), summary_module(), to_module_net(), zp_analyse()

Examples

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

Description

Multi-omics network build

Usage

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
)

Arguments

...

some omics abundance tables

mode

"full"

method

"spearman" or "pearson"

filename

the prefix of saved .corr file or FALSE

p.adjust.method

see p.adjust

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?

Value

metanet

See Also

Other build: c_net_build(), c_net_from_edgelist(), c_net_set(), c_net_update()

Examples

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)

MetaNet networks

Description

MetaNet co_nets


Calculate natural_connectivity

Description

Calculate natural_connectivity

Usage

nc(p)

Arguments

p

an igraph or metanet object

Value

natural_connectivity (numeric)

References

`nc` in `ggClusterNet`

See Also

Other topological: extract_sample_net(), fit_power(), get_group_skeleton(), links_stat(), net_par(), rand_net_par(), rand_net(), smallworldness()

Examples

igraph::make_ring(10) %>% nc()

Calculate all topological indexes of a network

Description

Calculate all topological indexes of a network

Add topological indexes for a network

Usage

net_par(
  go,
  mode = c("v", "e", "n", "all"),
  fast = TRUE,
  remove_negative = FALSE
)

c_net_index(go, force = FALSE)

Arguments

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

Value

a 3-elements list

n_index

indexs of the whole network

v_index

indexs of each vertex

e_index

indexs of each edge

See Also

Other topological: extract_sample_net(), fit_power(), get_group_skeleton(), links_stat(), nc(), rand_net_par(), rand_net(), smallworldness()

Examples

igraph::make_graph("Walther") %>% net_par()
c_net_index(co_net) -> co_net_with_par

plot use networkD3

Description

plot use networkD3

Usage

netD3plot(go, v_class = "v_class", ...)

Arguments

go

metanet

v_class

which attributes use to be v_class

...

see forceNetwork

Value

D3 plot

See Also

Other plot: as.ggig(), c_net_plot(), input_gephi(), olympic_rings_net(), plot.ggig(), twocol_edgelist(), venn_net()

Examples

data("c_net")
plot(co_net2)
if (requireNamespace("networkD3")) {
  netD3plot(co_net2)
}

Plot olympic rings using network

Description

Plot olympic rings using network

Usage

olympic_rings_net()

Value

network plot

See Also

Other plot: as.ggig(), c_net_plot(), input_gephi(), netD3plot(), plot.ggig(), twocol_edgelist(), venn_net()

Examples

olympic_rings_net()

p.adjust apply on a correlation table (matrix or data.frame)

Description

p.adjust apply on a correlation table (matrix or data.frame)

Usage

p.adjust.table(pp, method = "BH", mode = "all")

Arguments

pp

table of p-values

method

see p.adjust, default: "BH".

mode

"all" for all values; "rows" adjust each row one by one; "columns" adjust each column one by one. Default: "all".

Value

a table of adjusted p-values

See Also

Other calculate: c_net_calculate(), cal_sim(), fast_cor(), read_corr()

Examples

matrix(abs(rnorm(100, 0.01, 0.1)), 10, 10) -> pp
p.adjust.table(pp, method = "BH", mode = "all") -> pp_adj

Plot a ggig

Description

Plot a ggig

Usage

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

Arguments

x

ggig object

coors

the coordinates you saved

...

additional parameters for igraph.plotting

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.

Value

ggplot

See Also

Other plot: as.ggig(), c_net_plot(), input_gephi(), netD3plot(), olympic_rings_net(), twocol_edgelist(), venn_net()


Plot a metanet

Description

Plot a metanet

Usage

## S3 method for class 'metanet'
plot(x, ...)

Arguments

x

metanet object

...

add

Value

plot


Plot a rmt_res

Description

Plot a rmt_res

Usage

## S3 method for class 'rmt_res'
plot(x, ...)

Arguments

x

rmt_res

...

Additional arguments

Value

ggplot


Plot robust

Description

Plot robust

Usage

## S3 method for class 'robust'
plot(
  x,
  indexes = c("Natural_connectivity", "Average_degree"),
  use_ratio = FALSE,
  mode = 1,
  ...
)

Arguments

x

robust_test() result (robust object)

indexes

indexes selected to show

use_ratio

use the delete nodes ratio rather than nodes number

mode

plot mode, 1~3

...

additional arguments for group_box

Value

a ggplot


Plot robustness

Description

Plot robustness

Usage

## S3 method for class 'robustness'
plot(x, indexes = "Node_number", ...)

Arguments

x

robustness() result (robustness object)

indexes

indexes selected to show

...

additional arguments for group_box

Value

a ggplot


Plot vulnerability

Description

Plot vulnerability

Usage

## S3 method for class 'vulnerability'
plot(x, ...)

Arguments

x

vulnerability() result (vulnerability object)

...

add

Value

a ggplot


Print method for 'cohesion' objects

Description

Print method for 'cohesion' objects

Usage

## S3 method for class 'cohesion'
print(x, ...)

Arguments

x

'cohesion' object

...

Additional arguments

Value

No value


Print method for 'coors' objects

Description

Print method for 'coors' objects

Usage

## S3 method for class 'coors'
print(x, ...)

Arguments

x

'coors' object

...

additional arguments

Value

No value


Print method for 'corr' objects

Description

Print method for 'corr' objects

Usage

## S3 method for class 'corr'
print(x, ...)

Arguments

x

'corr' object

...

additional arguments

Value

No value


Print method for 'ggig' objects

Description

Print method for 'ggig' objects

Usage

## S3 method for class 'ggig'
print(x, ...)

Arguments

x

'ggig' object

...

Additional arguments

Value

No value


Print method for 'metanet' objects

Description

Print method for 'metanet' objects

Usage

## S3 method for class 'metanet'
print(x, ...)

Arguments

x

'metanet' object

...

Additional arguments

Value

No value


Print method for 'robust' objects

Description

Print method for 'robust' objects

Usage

## S3 method for class 'robust'
print(x, ...)

Arguments

x

'robust' object

...

Additional arguments

Value

No value


Print method for 'robustness' objects

Description

Print method for 'robustness' objects

Usage

## S3 method for class 'robustness'
print(x, ...)

Arguments

x

'robustness' object

...

Additional arguments

Value

No value


Print method for 'vulnerability' objects

Description

Print method for 'vulnerability' objects

Usage

## S3 method for class 'vulnerability'
print(x, ...)

Arguments

x

'vulnerability' object

...

Additional arguments

Value

No value


Degree distribution comparison with random network

Description

Degree distribution comparison with random network

Usage

rand_net(go = go, plot = TRUE)

Arguments

go

igraph object

plot

plot or not

Value

ggplot

See Also

Other topological: extract_sample_net(), fit_power(), get_group_skeleton(), links_stat(), nc(), net_par(), rand_net_par(), smallworldness()

Examples

rand_net(co_net)

Net_pars of many random network

Description

Net_pars of many random network

Compare some indexes between your net with random networks

Usage

rand_net_par(go, reps = 99, threads = 1, verbose = TRUE)

compare_rand(
  pars,
  randp,
  index = c("Average_path_length", "Clustering_coefficient")
)

Arguments

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

Value

ggplot

See Also

Other topological: extract_sample_net(), fit_power(), get_group_skeleton(), links_stat(), nc(), net_par(), rand_net(), smallworldness()

Examples

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

Description

Read a corr object

Usage

read_corr(filename)

Arguments

filename

filename of .corr

Value

a corr object

See Also

Other calculate: c_net_calculate(), cal_sim(), fast_cor(), p.adjust.table()


Get RMT threshold for a correlation matrix

Description

Get RMT threshold for a correlation matrix

Get RMT threshold for a correlation matrix roughly

Usage

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)

Arguments

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

Value

a r-threshold

recommend threshold

References

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

Examples

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

Description

Save a corr object

Usage

save_corr(corr, filename = "corr")

Arguments

corr

a corr object

filename

filename without extension, default: "corr"

Value

a .corr file


Calculate small-world coefficient

Description

Calculate small-world coefficient

Usage

smallworldness(go, reps = 99, threads = 1, verbose = TRUE)

Arguments

go

igraph or metanet

reps

simulation time

threads

threads

verbose

verbose

Value

number

See Also

Other topological: extract_sample_net(), fit_power(), get_group_skeleton(), links_stat(), nc(), net_par(), rand_net_par(), rand_net()

Examples

# set reps at least 99 when you run.
smallworldness(co_net, reps = 9)

Summaries two columns information

Description

Summaries two columns information

Usage

summ_2col(df, from = 1, to = 2, count = 3, direct = FALSE)

Arguments

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

Value

data.frame

Examples

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

Description

Summary module index

Usage

summary_module(go_m, var = "v_class", module = "module", ...)

Arguments

go_m

module metanet

var

variable name

module

which column name is module. default: "module"

...

add

Value

ggplot

See Also

Other module: filter_n_module(), get_community(), get_module_eigen(), get_module(), module_detect(), module_eigen(), module_net(), to_module_net(), zp_analyse()

Examples

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

Description

Summary method for 'corr' objects

Usage

## S3 method for class 'corr'
summary(object, ...)

Arguments

object

'corr' object

...

Additional arguments

Value

No value


Transformation a network to a module network

Description

Transformation a network to a module network

Usage

to_module_net(go, edge_type = c("module", "module_from", "module_to")[1])

Arguments

go

metanet

edge_type

"module", "module_from", "module_to"

Value

metanet with modules

See Also

Other module: filter_n_module(), get_community(), get_module_eigen(), get_module(), module_detect(), module_eigen(), module_net(), summary_module(), zp_analyse()


MetaNet networks abundance

Description

MetaNet co_nets


MetaNet networks metadata

Description

MetaNet co_nets


Quick build a metanet from two columns table

Description

Quick build a metanet from two columns table

Usage

twocol_edgelist(edgelist)

Arguments

edgelist

two columns table (no elements exist in two columns at same time)

Value

metanet

See Also

Other plot: as.ggig(), c_net_plot(), input_gephi(), netD3plot(), olympic_rings_net(), plot.ggig(), venn_net()

Examples

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

Description

Venn network

Usage

venn_net(tab)

Arguments

tab

data.frame (row is elements, column is group), or a list (names is group, value is elements)

Value

plot

See Also

Other plot: as.ggig(), c_net_plot(), input_gephi(), netD3plot(), olympic_rings_net(), plot.ggig(), twocol_edgelist()

Examples

data(otutab, package = "pcutils")
tab <- otutab[400:485, 1:3]
venn_net(tab) -> v_net
plot(v_net)

Zi-Pi calculate

Description

Zi-Pi calculate

Zi-Pi plot of vertexes

Usage

zp_analyse(go_m, mode = 2, use_origin = TRUE)

zp_plot(go, label = TRUE, mode = 1)

Arguments

go_m

igraph object after module_detect()

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

Value

igraph

a ggplot object

References

  1. GuimerĂ , R. & Amaral, L. Functional cartography of complex metabolic networks. (2005) doi:10.1038/nature03288.

See Also

Other module: filter_n_module(), get_community(), get_module_eigen(), get_module(), module_detect(), module_eigen(), module_net(), summary_module(), to_module_net()

Examples

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)