| trans_network | R Documentation |
trans_network object for network analysis.This class is a wrapper for a series of network analysis methods, including the network construction, topological attributes analysis, eigengene analysis, network subsetting, node and edge properties, network visualization and other operations.
new()Create the trans_network object, store the important intermediate data
and calculate correlations if cor_method parameter is not NULL.
trans_network$new(
dataset = NULL,
cor_method = NULL,
use_WGCNA_pearson_spearman = FALSE,
use_NetCoMi_pearson_spearman = FALSE,
use_sparcc_method = c("NetCoMi", "SpiecEasi")[1],
taxa_level = "OTU",
filter_thres = 0,
nThreads = 1,
SparCC_simu_num = 100,
env_cols = NULL,
add_data = NULL,
...
)datasetdefault NULL; the object of microtable class. Default NULL means customized analysis.
cor_methoddefault NULL; NULL or one of "bray", "pearson", "spearman", "sparcc", "bicor", "cclasso" and "ccrepe";
All the methods refered to NetCoMi package are performed based on netConstruct function of NetCoMi package and require
NetCoMi to be installed from Github (https://github.com/stefpeschel/NetCoMi);
For the algorithm details, please see Peschel et al. 2020 Brief. Bioinform <doi: 10.1093/bib/bbaa290>;
NULL denotes non-correlation network, i.e. do not use correlation-based network. If so, the return res_cor_p list will be NULL.
1-B, where B is Bray-Curtis dissimilarity; based on vegan::vegdist function
Pearson correlation; If use_WGCNA_pearson_spearman and use_NetCoMi_pearson_spearman are both FALSE,
use the function cor.test in R; use_WGCNA_pearson_spearman = TRUE invoke corAndPvalue function of WGCNA package;
use_NetCoMi_pearson_spearman = TRUE invoke netConstruct function of NetCoMi package
Spearman correlation; other details are same with the 'pearson' option
SparCC algorithm (Friedman & Alm, PLoS Comp Biol, 2012, <doi:10.1371/journal.pcbi.1002687>);
use NetCoMi package when use_sparcc_method = "NetCoMi"; use SpiecEasi package when use_sparcc_method = "SpiecEasi"
and require SpiecEasi to be installed from Github
(https://github.com/zdk123/SpiecEasi)
Calculate biweight midcorrelation efficiently for matrices based on WGCNA::bicor function;
This option can invoke netConstruct function of NetCoMi package;
Make sure WGCNA and NetCoMi packages are both installed
Correlation inference of Composition data through Lasso method based on netConstruct function of NetCoMi package;
for details, see NetCoMi::cclasso function
Calculates compositionality-corrected p-values and q-values for compositional data
using an arbitrary distance metric based on NetCoMi::netConstruct function; also see NetCoMi::ccrepe function
use_WGCNA_pearson_spearmandefault FALSE; whether use WGCNA package to calculate correlation when cor_method = "pearson" or "spearman".
use_NetCoMi_pearson_spearmandefault FALSE; whether use NetCoMi package to calculate correlation when cor_method = "pearson" or "spearman".
The important difference between NetCoMi and others is the features of zero handling and data normalization; See <doi: 10.1093/bib/bbaa290>.
use_sparcc_methoddefault c("NetCoMi", "SpiecEasi")[1];
use NetCoMi package or SpiecEasi package to perform SparCC when cor_method = "sparcc".
taxa_leveldefault "OTU"; taxonomic rank; 'OTU' denotes using feature abundance table;
other available options should be one of the colnames of tax_table of input dataset.
filter_thresdefault 0; the relative abundance threshold.
nThreadsdefault 1; the CPU thread number; available when use_WGCNA_pearson_spearman = TRUE or use_sparcc_method = "SpiecEasi".
SparCC_simu_numdefault 100; SparCC simulation number for bootstrap when use_sparcc_method = "SpiecEasi".
env_colsdefault NULL; numeric or character vector to select the column names of environmental data in dataset$sample_table;
the environmental data can be used in the correlation network (as the nodes) or FlashWeave network.
add_datadefault NULL; provide environmental variable table additionally instead of env_cols parameter; rownames must be sample names.
...parameters pass to NetCoMi::netConstruct for other operations, such as zero handling and/or data normalization
when cor_method and other parameters refer to NetCoMi package.
res_cor_p list with the correlation (association) matrix and p value matrix. Note that when cor_method and other parameters
refer to NetCoMi package, the p value table are all zero as the significant associations have been selected.
\donttest{
data(dataset)
# for correlation network
t1 <- trans_network$new(dataset = dataset, cor_method = "pearson",
taxa_level = "OTU", filter_thres = 0.0002)
# for non-correlation network
t1 <- trans_network$new(dataset = dataset, cor_method = NULL)
}
cal_network()Construct network based on the igraph package or SpiecEasi package or julia FlashWeave package or beemStatic package.
trans_network$cal_network(
network_method = c("COR", "SpiecEasi", "gcoda", "FlashWeave", "beemStatic")[1],
COR_p_thres = 0.01,
COR_p_adjust = "fdr",
COR_weight = TRUE,
COR_cut = 0.6,
COR_optimization = FALSE,
COR_optimization_low_high = c(0.01, 0.8),
COR_optimization_seq = 0.01,
SpiecEasi_method = "mb",
FlashWeave_tempdir = NULL,
FlashWeave_meta_data = FALSE,
FlashWeave_other_para = "alpha=0.01,sensitive=true,heterogeneous=true",
FlashWeave_gml = NULL,
beemStatic_t_strength = 0.001,
beemStatic_t_stab = 0.8,
add_taxa_name = "Phylum",
delete_unlinked_nodes = TRUE,
usename_rawtaxa_notOTU = FALSE,
...
)network_methoddefault "COR"; "COR", "SpiecEasi", "gcoda", "FlashWeave" or "beemStatic";
network_method = NULL means skipping the network construction for the customized use.
The option details:
correlation-based network; use the correlation and p value matrices in res_cor_p list stored in the object;
See Deng et al. (2012) <doi:10.1186/1471-2105-13-113> for other details
SpiecEasi network; relies on algorithms of sparse neighborhood and inverse covariance selection;
belong to the category of conditional dependence and graphical models;
see https://github.com/zdk123/SpiecEasi for installing the R package;
see Kurtz et al. (2015) <doi:10.1371/journal.pcbi.1004226> for the algorithm details
hypothesize the logistic normal distribution of microbiome data; use penalized maximum likelihood method to estimate
the sparse structure of inverse covariance for latent normal variables to address the high dimensionality of the microbiome data;
belong to the category of conditional dependence and graphical models;
depend on the R NetCoMi package https://github.com/stefpeschel/NetCoMi;
see FANG et al. (2017) <doi:10.1089/cmb.2017.0054> for the algorithm details
FlashWeave network; Local-to-global learning framework; belong to the category of conditional dependence and graphical models;
good performance on heterogenous datasets to find direct associations among taxa;
see https://github.com/meringlab/FlashWeave.jl for installing julia language and
FlashWeave package; julia must be in the computer system env path, otherwise the program can not find it;
see Tackmann et al. (2019) <doi:10.1016/j.cels.2019.08.002> for the algorithm details
beemStatic network;
extend generalized Lotka-Volterra model to cases of cross-sectional datasets to infer interaction among taxa based on expectation-maximization algorithm;
see https://github.com/CSB5/BEEM-static for installing the R package;
see Li et al. (2021) <doi:10.1371/journal.pcbi.1009343> for the algorithm details
COR_p_thresdefault 0.01; the p value threshold for the correlation-based network.
COR_p_adjustdefault "fdr"; p value adjustment method, see method parameter of p.adjust function for available options,
in which COR_p_adjust = "none" means giving up the p value adjustment.
COR_weightdefault TRUE; whether use correlation coefficient as the weight of edges; FALSE represents weight = 1 for all edges.
COR_cutdefault 0.6; correlation coefficient threshold for the correlation network.
COR_optimizationdefault FALSE; whether use random matrix theory (RMT) based method to determine the correlation coefficient; see https://doi.org/10.1186/1471-2105-13-113
COR_optimization_low_highdefault c(0.01, 0.8); the low and high value threshold used for the RMT optimization; only useful when COR_optimization = TRUE.
COR_optimization_seqdefault 0.01; the interval of correlation coefficient used for RMT optimization; only useful when COR_optimization = TRUE.
SpiecEasi_methoddefault "mb"; either 'glasso' or 'mb';see spiec.easi function in package SpiecEasi and https://github.com/zdk123/SpiecEasi.
FlashWeave_tempdirdefault NULL; The temporary directory used to save the temporary files for running FlashWeave; If not assigned, use the system user temp.
FlashWeave_meta_datadefault FALSE; whether use env data for the optimization, If TRUE, the function automatically find the env_data in the object and
generate a file for meta_data_path parameter of FlashWeave package.
FlashWeave_other_paradefault "alpha=0.01,sensitive=true,heterogeneous=true"; the parameters passed to julia FlashWeave package;
user can change the parameters or add more according to FlashWeave help document;
An exception is meta_data_path parameter as it is generated based on the data inside the object, see FlashWeave_meta_data parameter for the description.
FlashWeave_gmldefault NULL; The path of FlashWeave output gml file for customized usage. This parameter is provided for some customized needs. For instance, it can be cumbersome to input bacterial and fungal abundances as separate input files for network analysis using the above parameter. Users can run FlashWeave on their own, and then provide the resulting gml file to this parameter, which allows them to continue using other functions.
beemStatic_t_strengthdefault 0.001; for network_method = "beemStatic"; the threshold used to limit the number of interactions (strength); same with the t.strength parameter in showInteraction function of beemStatic package.
beemStatic_t_stabdefault 0.8; for network_method = "beemStatic"; the threshold used to limit the number of interactions (stability); same with the t.stab parameter in showInteraction function of beemStatic package.
add_taxa_namedefault "Phylum"; one or more taxonomic rank name; used to add taxonomic rank name to network node properties.
delete_unlinked_nodesdefault TRUE; whether delete the nodes without any link.
usename_rawtaxa_notOTUdefault FALSE; whether use OTU name as representatives of taxa when taxa_level != "OTU".
Default FALSE means using taxonomic information of taxa_level instead of OTU name.
...parameters pass to SpiecEasi::spiec.easi when network_method = "SpiecEasi";
pass to NetCoMi::netConstruct when network_method = "gcoda";
pass to beemStatic::func.EM when network_method = "beemStatic".
res_network stored in object.
\dontrun{
# for correlation network
t1 <- trans_network$new(dataset = dataset, cor_method = "pearson",
taxa_level = "OTU", filter_thres = 0.001)
t1$cal_network(COR_p_thres = 0.05, COR_cut = 0.6)
t1 <- trans_network$new(dataset = dataset, cor_method = NULL, filter_thres = 0.003)
t1$cal_network(network_method = "SpiecEasi", SpiecEasi_method = "mb")
t1 <- trans_network$new(dataset = dataset, cor_method = NULL, filter_thres = 0.005)
t1$cal_network(network_method = "beemStatic")
t1 <- trans_network$new(dataset = dataset, cor_method = NULL, filter_thres = 0.001)
t1$cal_network(network_method = "FlashWeave")
}
cal_module()Calculate network modules and add module names to the network node properties.
trans_network$cal_module( method = "cluster_fast_greedy", module_name_prefix = "M" )
methoddefault "cluster_fast_greedy"; the method used to find the optimal community structure of a graph;
the following are available functions (options) from igraph package:
"cluster_fast_greedy", "cluster_walktrap", "cluster_edge_betweenness",
"cluster_infomap", "cluster_label_prop", "cluster_leading_eigen",
"cluster_louvain", "cluster_spinglass", "cluster_optimal".
For the details of these functions, please see the help document, such as help(cluster_fast_greedy);
Note that the default "cluster_fast_greedy" method can not be applied to directed network.
If directed network is provided, the function can automatically switch the default method from "cluster_fast_greedy" to "cluster_walktrap".
module_name_prefixdefault "M"; the prefix of module names; module names are made of the module_name_prefix and numbers; numbers are assigned according to the sorting result of node numbers in modules with decreasing trend.
res_network with modules, stored in object.
\donttest{
t1 <- trans_network$new(dataset = dataset, cor_method = "pearson",
taxa_level = "OTU", filter_thres = 0.0002)
t1$cal_network(COR_p_thres = 0.01, COR_cut = 0.6)
t1$cal_module(method = "cluster_fast_greedy")
}
save_network()Save network as gexf style, which can be opened by Gephi (https://gephi.org/).
trans_network$save_network(filepath = "network.gexf", ...)
filepathdefault "network.gexf"; file path to save the network.
...parameters pass to gexf function of rgexf package except for nodes,
edges, edgesLabel, edgesWeight, nodesAtt, edgesAtt and meta.
None
\dontrun{
t1$save_network(filepath = "network.gexf")
}
cal_network_attr()Calculate network properties.
trans_network$cal_network_attr()
res_network_attr stored in object.
\donttest{
t1$cal_network_attr()
}
get_node_table()Get the node property table. The properties include the node names, modules allocation, degree, betweenness, abundance, taxonomy, within-module connectivity (zi) and among-module connectivity (Pi) <doi:10.1186/1471-2105-13-113; 10.1016/j.geoderma.2022.115866>.
trans_network$get_node_table(node_roles = TRUE)
node_rolesdefault TRUE; whether calculate the node roles <doi:10.1038/nature03288; 10.1186/1471-2105-13-113>. The role of node i is characterized by its within-module connectivity (zi) and among-module connectivity (Pi) as follows
z_i = \dfrac{k_{ib} - \bar{k_b}}{\sigma_{k_b}}
P_i = 1 - \displaystyle\sum_{c=1}^{N_M} \biggl(\frac{k_{ic}}{k_i}\biggr)^2
where k_{ib} is the number of links of node i to other nodes in its module b,
\bar{k_b} and \sigma_{k_b} are the average and standard deviation of within-module connectivity, respectively
over all the nodes in module b, k_i is the number of links of node i in the whole network,
k_{ic} is the number of links from node i to nodes in module c, and N_M is the number of modules in the network.
res_node_table in object; Abundance expressed as a percentage;
betweenness_centrality: betweenness centrality; betweenness_centrality: closeness centrality; eigenvector_centrality: eigenvector centrality;
z: within-module connectivity; p: among-module connectivity.
\donttest{
t1$get_node_table(node_roles = TRUE)
}
get_edge_table()Get the edge property table, including connected nodes, label and weight.
trans_network$get_edge_table()
res_edge_table in object.
\donttest{
t1$get_edge_table()
}
get_adjacency_matrix()Get the adjacency matrix from the network graph.
trans_network$get_adjacency_matrix(...)
...parameters passed to as_adjacency_matrix function of igraph package.
res_adjacency_matrix in object.
\donttest{
t1$get_adjacency_matrix(attr = "weight")
}
plot_network()Plot the network based on a series of methods from other packages, such as igraph, ggraph and networkD3.
The networkD3 package provides dynamic network. It is especially useful for a glimpse of the whole network structure and finding
the interested nodes and edges in a large network. In contrast, the igraph and ggraph methods are suitable for relatively small network.
trans_network$plot_network(
method = c("igraph", "ggraph", "networkD3")[1],
node_label = "name",
node_color = NULL,
ggraph_layout = "fr",
ggraph_node_size = 2,
ggraph_node_text = TRUE,
ggraph_text_color = NULL,
ggraph_text_size = 3,
networkD3_node_legend = TRUE,
networkD3_zoom = TRUE,
...
)methoddefault "igraph"; The available options:
call plot.igraph function in igraph package for a static network; see plot.igraph for the parameters
call ggraph function in ggraph package for a static network
use forceNetwork function in networkD3 package for a dynamic network; see forceNetwork function for the parameters
node_labeldefault "name"; node label shown in the plot for method = "ggraph" or method = "networkD3";
Please see the column names of object$res_node_table, which is the returned table of function object$get_node_table;
User can select other column names in res_node_table.
node_colordefault NULL; node color assignment for method = "ggraph" or method = "networkD3";
Select a column name of object$res_node_table, such as "module".
ggraph_layoutdefault "fr"; for method = "ggraph"; see layout parameter of create_layout function in ggraph package.
ggraph_node_sizedefault 2; for method = "ggraph"; the node size.
ggraph_node_textdefault TRUE; for method = "ggraph"; whether show the label text of nodes.
ggraph_text_colordefault NULL; for method = "ggraph"; a column name of object$res_node_table used to assign label text colors.
ggraph_text_sizedefault 3; for method = "ggraph"; the node label text size.
networkD3_node_legenddefault TRUE; used for method = "networkD3"; logical value to enable node colour legends;
Please see the legend parameter in networkD3::forceNetwork function.
networkD3_zoomdefault TRUE; used for method = "networkD3"; logical value to enable (TRUE) or disable (FALSE) zooming;
Please see the zoom parameter in networkD3::forceNetwork function.
...parameters passed to plot.igraph function when method = "igraph" or forceNetwork function when method = "networkD3".
network plot.
\donttest{
t1$plot_network(method = "igraph", layout = layout_with_kk)
t1$plot_network(method = "ggraph", node_color = "module")
t1$plot_network(method = "networkD3", node_color = "module")
}
cal_eigen()Calculate eigengenes of modules, i.e. the first principal component based on PCA analysis, and the percentage of variance <doi:10.1186/1471-2105-13-113>.
trans_network$cal_eigen()
res_eigen and res_eigen_expla in object.
\donttest{
t1$cal_eigen()
}
plot_taxa_roles()Plot the roles or metrics of nodes based on the res_node_table data (coming from function get_node_table) stored in the object.
trans_network$plot_taxa_roles(
use_type = c(1, 2)[1],
roles_color_background = FALSE,
roles_color_values = NULL,
add_label = FALSE,
add_label_group = c("Network hubs", "Module hubs", "Connectors"),
add_label_text = "name",
label_text_size = 4,
label_text_color = "grey50",
label_text_italic = FALSE,
label_text_parse = FALSE,
plot_module = FALSE,
x_lim = c(0, 1),
use_level = "Phylum",
show_value = c("z", "p"),
show_number = 1:10,
plot_color = "Phylum",
plot_shape = "taxa_roles",
plot_size = "Abundance",
color_values = RColorBrewer::brewer.pal(12, "Paired"),
shape_values = c(16, 17, 7, 8, 15, 18, 11, 10, 12, 13, 9, 3, 4, 0, 1, 2, 14),
...
)use_typedefault 1; 1 or 2; 1 represents taxa roles plot (node roles include Module hubs, Network hubs,
Connectors and Peripherals <doi:10.1038/nature03288; 10.1186/1471-2105-13-113>).
The 'p' column (Pi, among-module connectivity) in res_node_table table is used in x-axis. The 'z' column (Zi, within-module connectivity) is used in y-axis;
2 represents the layered plot with taxa as x axis and the index (e.g., Zi and Pi) as y axis.
Please refer to res_node_table data stored in the object for the detailed information.
roles_color_backgrounddefault FALSE; for use_type=1; TRUE: use background colors for each area; FALSE: use classic point colors.
roles_color_valuesdefault NULL; for use_type=1; color palette for background or points.
add_labeldefault FALSE; for use_type = 1; whether add labels for the points.
add_label_groupdefault c("Network hubs", "Module hubs", "Connectors");
If add_label = TRUE, which part in taxa_roles column is used to show labels; character vectors.
add_label_textdefault "name"; If add_label = TRUE; which column of object$res_node_table is used to label the text.
label_text_sizedefault 4; The text size of the label.
label_text_colordefault "grey50"; The text color of the label.
label_text_italicdefault FALSE; whether use italic style for the label text.
label_text_parsedefault FALSE; whether parse the label text. See the parse parameter in ggrepel::geom_text_repel function.
plot_moduledefault FALSE; for use_type=1; whether plot the modules information.
x_limdefault c(0, 1); for use_type=1; x axis range when roles_color_background = FALSE.
use_leveldefault "Phylum"; for use_type=2; used taxonomic level in x axis.
show_valuedefault c("z", "p"); for use_type=2; indexes used in y axis. Please see res_node_table in the object for other available indexes.
show_numberdefault 1:10; for use_type=2; showed number in x axis, sorting according to the nodes number.
plot_colordefault "Phylum"; for use_type=2; variable for color.
plot_shapedefault "taxa_roles"; for use_type=2; variable for shape.
plot_sizedefault "Abundance"; for use_type=2; used for point size; a fixed number (e.g. 5) is also acceptable.
color_valuesdefault RColorBrewer::brewer.pal(12, "Paired"); for use_type=2; color vector.
shape_valuesdefault c(16, 17, 7, 8, 15, 18, 11, 10, 12, 13, 9, 3, 4, 0, 1, 2, 14); for use_type=2; shape vector, see ggplot2 tutorial for the shape meaning.
...parameters pass to geom_point function of ggplot2 package.
ggplot.
\donttest{
t1$plot_taxa_roles(roles_color_background = FALSE)
}
subset_network()Subset of the network.
trans_network$subset_network( node = NULL, edge = NULL, rm_single = TRUE, node_alledges = FALSE, return_igraph = TRUE )
nodedefault NULL; provide the node names that will be used in the sub-network.
edgedefault NULL; provide the edge label or numbers that need to be remained. For the edge label, it should must be "+" or "-".
For the numbers, they should fall within the range of rows in res_edge_table of the object.
rm_singledefault TRUE; whether remove the nodes without any edge in the sub-network. So this function can also be used to remove the nodes withou any edge when node and edge are both NULL.
node_alledgesdefault FALSE; whether remain the nodes and edges that related to the nodes provided in node parameter.
When this parameter is set to TRUE, the network will filter based on edges rather than directly on nodes.
The logic is that if at least one of the two nodes connected by an edge is included in the nodes provided by the node parameter,
the edge will be retained. Otherwise, it will be filtered out.
When this parameter is set to FALSE, the network will filter directly based on the node parameter.
Any nodes not included in the node parameter will be filtered out.
return_igraphdefault TRUE; whether return the network with igraph format. If FALSE, return trans_network object.
a new network
\donttest{
t1$subset_network(node = t1$res_node_table %>% base::subset(module == "M1") %>%
rownames, rm_single = TRUE)
# return a sub network that contains all nodes of module M1
}
cal_powerlaw()Fit degrees to a power law distribution. First, perform a bootstrapping hypothesis test to determine whether degrees follow a power law distribution. If the distribution follows power law, then fit degrees to power law distribution and return the parameters.
trans_network$cal_powerlaw(...)
...parameters pass to bootstrap_p function in poweRlaw package.
res_powerlaw_p and res_powerlaw_fit; see poweRlaw::bootstrap_p function for the bootstrapping p value details;
see igraph::fit_power_law function for the power law fit return details.
\donttest{
t1$cal_powerlaw()
}
cal_sum_links()This function is used to sum the links number from one taxa to another or in the same taxa, for example, at Phylum level. This is very useful to fast see how many nodes are connected between different taxa or within the taxa.
trans_network$cal_sum_links(taxa_level = "Phylum")
taxa_leveldefault "Phylum"; taxonomic rank.
res_sum_links_pos and res_sum_links_neg in object.
\donttest{
t1$cal_sum_links(taxa_level = "Phylum")
}
plot_sum_links()Plot the summed linkages among taxa.
trans_network$plot_sum_links(
plot_pos = TRUE,
plot_num = NULL,
color_values = RColorBrewer::brewer.pal(8, "Dark2"),
method = c("chorddiag", "circlize")[1],
...
)plot_posdefault TRUE; If TRUE, plot the summed positive linkages; If FALSE, plot the summed negative linkages.
plot_numdefault NULL; number of taxa presented in the plot.
color_valuesdefault RColorBrewer::brewer.pal(8, "Dark2"); colors palette for taxa.
methoddefault c("chorddiag", "circlize")[1]; chorddiag package <https://github.com/mattflor/chorddiag> or circlize package.
...pass to chorddiag::chorddiag function when method = "chorddiag" or
circlize::chordDiagram function when method = "circlize".
Note that for circlize::chordDiagram function, keep.diagonal, symmetric and self.link parameters have been fixed to fit the input data.
please see the invoked function.
\dontrun{
test1$plot_sum_links(method = "chorddiag", plot_pos = TRUE, plot_num = 10)
test1$plot_sum_links(method = "circlize", transparency = 0.2,
annotationTrackHeight = circlize::mm_h(c(5, 5)))
}
random_network()Generate random networks, compare them with the empirical network and get the p value of topological properties.
The generation of random graph is based on the erdos.renyi.game function of igraph package.
The numbers of vertices and edges in the random graph are same with the empirical network stored in the object.
trans_network$random_network(runs = 100, output_sim = FALSE)
runsdefault 100; simulation number of random network.
output_simdefault FALSE; whether output each simulated network result.
a data.frame with the following components:
ObservedTopological properties of empirical network
Mean_simMean of properties of simulated networks
SD_simSD of properties of simulated networks
p_valueSignificance, i.e. p values
When output_sim = TRUE, the columns from the five to the last are each simulated result.
\dontrun{
t1$random_network(runs = 100)
}
trans_comm()Transform classifed features to community-like microtable object for further analysis, such as module-taxa table.
trans_network$trans_comm(use_col = "module", abundance = TRUE)
use_coldefault "module"; which column to use as the 'community'; must be one of the name of res_node_table from function get_node_table.
abundancedefault TRUE; whether sum abundance of taxa. TRUE: sum the abundance for a taxon across all samples; FALSE: sum the frequency for a taxon across all samples.
a new microtable class.
\donttest{
t2 <- t1$trans_comm(use_col = "module")
}
print()Print the trans_network object.
trans_network$print()
clone()The objects of this class are cloneable with this method.
trans_network$clone(deep = FALSE)
deepWhether to make a deep clone.
## ------------------------------------------------
## Method `trans_network$new`
## ------------------------------------------------
data(dataset)
# for correlation network
t1 <- trans_network$new(dataset = dataset, cor_method = "pearson",
taxa_level = "OTU", filter_thres = 0.0002)
# for non-correlation network
t1 <- trans_network$new(dataset = dataset, cor_method = NULL)
## ------------------------------------------------
## Method `trans_network$cal_network`
## ------------------------------------------------
## Not run:
# for correlation network
t1 <- trans_network$new(dataset = dataset, cor_method = "pearson",
taxa_level = "OTU", filter_thres = 0.001)
t1$cal_network(COR_p_thres = 0.05, COR_cut = 0.6)
t1 <- trans_network$new(dataset = dataset, cor_method = NULL, filter_thres = 0.003)
t1$cal_network(network_method = "SpiecEasi", SpiecEasi_method = "mb")
t1 <- trans_network$new(dataset = dataset, cor_method = NULL, filter_thres = 0.005)
t1$cal_network(network_method = "beemStatic")
t1 <- trans_network$new(dataset = dataset, cor_method = NULL, filter_thres = 0.001)
t1$cal_network(network_method = "FlashWeave")
## End(Not run)
## ------------------------------------------------
## Method `trans_network$cal_module`
## ------------------------------------------------
t1 <- trans_network$new(dataset = dataset, cor_method = "pearson",
taxa_level = "OTU", filter_thres = 0.0002)
t1$cal_network(COR_p_thres = 0.01, COR_cut = 0.6)
t1$cal_module(method = "cluster_fast_greedy")
## ------------------------------------------------
## Method `trans_network$save_network`
## ------------------------------------------------
## Not run:
t1$save_network(filepath = "network.gexf")
## End(Not run)
## ------------------------------------------------
## Method `trans_network$cal_network_attr`
## ------------------------------------------------
t1$cal_network_attr()
## ------------------------------------------------
## Method `trans_network$get_node_table`
## ------------------------------------------------
t1$get_node_table(node_roles = TRUE)
## ------------------------------------------------
## Method `trans_network$get_edge_table`
## ------------------------------------------------
t1$get_edge_table()
## ------------------------------------------------
## Method `trans_network$get_adjacency_matrix`
## ------------------------------------------------
t1$get_adjacency_matrix(attr = "weight")
## ------------------------------------------------
## Method `trans_network$plot_network`
## ------------------------------------------------
t1$plot_network(method = "igraph", layout = layout_with_kk)
t1$plot_network(method = "ggraph", node_color = "module")
t1$plot_network(method = "networkD3", node_color = "module")
## ------------------------------------------------
## Method `trans_network$cal_eigen`
## ------------------------------------------------
t1$cal_eigen()
## ------------------------------------------------
## Method `trans_network$plot_taxa_roles`
## ------------------------------------------------
t1$plot_taxa_roles(roles_color_background = FALSE)
## ------------------------------------------------
## Method `trans_network$subset_network`
## ------------------------------------------------
t1$subset_network(node = t1$res_node_table %>% base::subset(module == "M1") %>%
rownames, rm_single = TRUE)
# return a sub network that contains all nodes of module M1
## ------------------------------------------------
## Method `trans_network$cal_powerlaw`
## ------------------------------------------------
t1$cal_powerlaw()
## ------------------------------------------------
## Method `trans_network$cal_sum_links`
## ------------------------------------------------
t1$cal_sum_links(taxa_level = "Phylum")
## ------------------------------------------------
## Method `trans_network$plot_sum_links`
## ------------------------------------------------
## Not run:
test1$plot_sum_links(method = "chorddiag", plot_pos = TRUE, plot_num = 10)
test1$plot_sum_links(method = "circlize", transparency = 0.2,
annotationTrackHeight = circlize::mm_h(c(5, 5)))
## End(Not run)
## ------------------------------------------------
## Method `trans_network$random_network`
## ------------------------------------------------
## Not run:
t1$random_network(runs = 100)
## End(Not run)
## ------------------------------------------------
## Method `trans_network$trans_comm`
## ------------------------------------------------
t2 <- t1$trans_comm(use_col = "module")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.