View source: R/correlation_network.R
convert_mass_dataset2graph | R Documentation |
Calculate fold change.
convert_mass_dataset2graph(
object,
margin = c("variable", "sample"),
cor_method = c("spearman", "pearson", "kendall"),
p_adjust_method = c(c("BH", "holm", "hochberg", "hommel", "bonferroni", "BY", "fdr",
"none")),
p_adjust_cutoff = 0.05,
p_value_cutoff = 0.05,
pos_cor_cutoff = 0,
neg_cor_cutoff = 0
)
object |
tidymass-class object. |
margin |
variable or sample |
cor_method |
spearman, pearson or kendall |
p_adjust_method |
see ?p.adjust |
p_adjust_cutoff |
between 0 to 1 |
p_value_cutoff |
between 0 to 1 |
pos_cor_cutoff |
between 0 to 1 |
neg_cor_cutoff |
between -1 to 0 |
tbl_graph class object (from tidygraph)
Xiaotao Shen shenxt1990@outlook.com
library(massdataset)
library(magrittr)
library(dplyr)
data("liver_aging_pos")
liver_aging_pos
qc_id <-
liver_aging_pos %>%
activate_mass_dataset(what = "sample_info") %>%
dplyr::filter(group == "QC") %>%
dplyr::pull(sample_id)
object <-
mutate_rsd(liver_aging_pos, according_to_samples = qc_id)
###only remain the features with rt > 100, mz > 150 and rsd < 30
object <-
object %>%
activate_mass_dataset(what = "variable_info") %>%
dplyr::filter(rt > 100) %>%
dplyr::filter(mz > 150) %>%
dplyr::filter(rsd < 30)
##only remain the week 24 samples
object <-
object %>%
activate_mass_dataset(what = "sample_info") %>%
dplyr::filter(group == "24W")
dim(object)
object <-
object %>%
`+`(1) %>%
log(10) %>%
scale_data(method = "auto")
graph_data <-
convert_mass_dataset2graph(
object = object,
margin = "variable",
cor_method = "spearman",
p_adjust_cutoff = 1,
p_value_cutoff = 0.0001,
pos_cor_cutoff = 0.7,
neg_cor_cutoff = -0.7
)
library(ggraph)
extrafont::loadfonts()
ggraph(graph = graph_data, layout = "kk") +
geom_edge_fan(aes(width = -log(p_value, 10)),
show.legend = TRUE) +
geom_node_point(aes(size = mz)) +
theme_graph()
ggraph(graph = graph_data, layout = "fr") +
geom_edge_fan(aes(width = -log(p_value, 10)),
show.legend = TRUE) +
geom_node_point(aes(size = mz)) +
theme_graph()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.