Public methods
Method new()
Usage
trans_network$new(
dataset = NULL,
cor_method = c("pearson", "spearman", "kendall")[1],
cal_cor = c("base", "WGCNA", "SparCC", NA)[1],
taxa_level = "OTU",
filter_thres = 0,
nThreads = 1,
SparCC_simu_num = 100,
env_cols = NULL,
add_data = NULL
)Arguments
datasetthe object of microtable Class.
cor_methoddefault "pearson"; "pearson", "spearman" or "kendall"; correlation algorithm, only use for correlation based network.
cal_cordefault "base"; "base", "WGCNA", "SparCC" or NA; correlation method; NA represent do not calculate correlations, used for non-correlation based network.
taxa_leveldefault "OTU"; taxonomic rank.
filter_thresdefault 0; the relative abundance threshold.
nThreadsdefault 1; the thread number used for "WGCNA" and SparCC.
SparCC_simu_numdefault 100; SparCC simulation number for bootstrap.
env_colsdefault NULL; number or name vector to select the physicochemical data in dataset$sample_table.
add_datadefault NULL; provide physicochemical table additionally.
Returns
res_cor_p list.
Examples
\donttest{
data(dataset)
# correlation network
t1 <- trans_network$new(dataset = dataset, cal_cor = "base",
taxa_level = "OTU", filter_thres = 0.001)
}
Method cal_network()
Calculate network either based on the correlation method or based on SpiecEasi or based on the Probabilistic Graphical Models (PGM) in julia FlashWeave;
see Deng et al. (2012) <doi:10.1186/1471-2105-13-113> for correlation based method;
see Kurtz et al. (2015) <doi:doi:10.1371/journal.pcbi.1004226> for SpiecEasi method;
see Tackmann et al. (2019) <doi:10.1016/j.cels.2019.08.002> for PGM based method.
Usage
trans_network$cal_network(
network_method = c("COR", "SpiecEasi", "PGM")[1],
p_thres = 0.01,
COR_weight = TRUE,
COR_p_adjust = "fdr",
COR_cut = 0.6,
COR_low_threshold = 0.4,
COR_optimization = FALSE,
PGM_meta_data = FALSE,
PGM_sensitive = "true",
PGM_heterogeneous = "true",
SpiecEasi_method = "mb",
with_module = TRUE,
add_taxa_name = "Phylum",
usename_rawtaxa_when_taxalevel_notOTU = FALSE,
...
)Arguments
network_methoddefault "COR"; "COR", "SpiecEasi" or "PGM"; COR: correlation based method; PGM: Probabilistic Graphical Models based method.
p_thresdefault .01; the p value threshold.
COR_weightdefault TRUE; whether use correlation coefficient as the weight of edges.
COR_p_adjustdefault "fdr"; p.adjust method, see p.adjust.methods.
COR_cutdefault .6; correlation coefficient threshold.
COR_low_thresholddefault .4; the lowest correlation coefficient threshold, use with COR_optimization = TRUE.
COR_optimizationdefault FALSE; whether use random matrix theory to optimize the choice of correlation coefficient, see https://doi.org/10.1186/1471-2105-13-113
PGM_meta_datadefault FALSE; whether use env data for the optimization, If TRUE, will automatically find the env_data in the object.
PGM_sensitivedefault "true"; whether use sensitive type in the PGM model.
PGM_heterogeneousdefault "true"; whether use heterogeneous type in the PGM model.
SpiecEasi_methoddefault "mb"; either 'glasso' or 'mb';see spiec.easi in package SpiecEasi and https://github.com/zdk123/SpiecEasi.
with_moduledefault TRUE; whether calculate modules.
add_taxa_namedefault "Phylum"; add taxonomic rank name to the result.
usename_rawtaxa_when_taxalevel_notOTUdefault FALSE; whether replace the name of nodes using the taxonomic information.
...paremeters pass to spiec.easi in package SpiecEasi.
Returns
res_network in object.
Examples
\donttest{
t1$cal_network(p_thres = 0.01, COR_cut = 0.6)
}
Method save_network()
Save network as gexf style, which can be opened by Gephi <https://gephi.org/>.
Usage
trans_network$save_network(filepath = "network.gexf")
Arguments
filepathdefault "network.gexf"; file path.
Returns
None.
Method cal_network_attr()
Calculate network properties.
Usage
trans_network$cal_network_attr()
Returns
res_network_attr in object.
Examples
\donttest{
t1$cal_network_attr()
}
Method cal_node_type()
Calculate node properties.
Usage
trans_network$cal_node_type()
Returns
res_node_type in object.
Examples
\donttest{
t1$cal_node_type()
}
Method cal_eigen()
Calculate eigengenes of modules, i.e. the first principal component based on PCA analysis, and the percentage of variance.
Usage
trans_network$cal_eigen()
Returns
res_eigen and res_eigen_expla in object.
Examples
\donttest{
t1$cal_eigen()
}
Method plot_taxa_roles()
Plot the classification and importance of nodes.
Usage
trans_network$plot_taxa_roles(
use_type = c(1, 2)[1],
roles_colors = NULL,
plot_module = FALSE,
use_level = "Phylum",
show_value = c("z", "p"),
show_number = 1:10,
plot_color = "Phylum",
plot_shape = "taxa_roles",
plot_size = NULL,
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)
)Arguments
use_typedefault 1; 1 or 2; 1 represent the traditional taxa roles plot; 2 represent the plot with taxa names as x axis.
roles_colorsdefault NULL; for use_type 1; colors for each group.
plot_moduledefault FALSE; for use_type 1; whether plot the modules information.
use_leveldefault "Phylum"; for use_type 2; used taxonomic level in x axis.
show_valuedefault c("z", "p"); for use_type 2; used variable in y axis.
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; used variable for color.
plot_shapedefault "taxa_roles"; for use_type 2; used variable for shape.
plot_sizedefault NULL; for use_type 2; used variable for shape.
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.
Returns
ggplot.
Examples
\donttest{
t1$plot_taxa_roles()
}
Method 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.
Usage
trans_network$cal_sum_links(taxa_level = "Phylum")
Arguments
taxa_leveldefault "Phylum"; taxonomic rank.
Returns
res_sum_links_pos and res_sum_links_neg in object.
Examples
\donttest{
t1$cal_sum_links(taxa_level = "Phylum")
}
Method plot_sum_links()
Plot the summed linkages among taxa using chorddiag package <https://github.com/mattflor/chorddiag>.
Usage
trans_network$plot_sum_links(
plot_pos = TRUE,
plot_num = NULL,
color_values = NULL
)
Arguments
plot_posdefault TRUE; plot the summed positive or negative linkages.
plot_numdefault NULL; number of taxa presented in the plot.
color_valuesdefault NULL; If not provided, use default.
Returns
chorddiag plot
Method subset_network()
Subset of the network.
Usage
trans_network$subset_network(node = NULL, rm_single = TRUE)
Arguments
nodedefault NULL; provide the names of the nodes that you want to use in the sub-network.
rm_singledefault TRUE; whether remove the nodes without any edge in the sub-network.
Returns
a new network
Examples
\donttest{
t1$subset_network(node = t1$res_node_type %>% .[.$module == "M1", ] %>%
rownames, rm_single = TRUE)
# return a sub network that contains all nodes of module M1
}
Method print()
Print the trans_network object.
Usage
trans_network$print()
Method clone()
The objects of this class are cloneable with this method.
Usage
trans_network$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.