convert_mass_dataset2graph: mutate_fc

View source: R/correlation_network.R

convert_mass_dataset2graphR Documentation

mutate_fc

Description

Calculate fold change.

Usage

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
)

Arguments

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

Value

tbl_graph class object (from tidygraph)

Author(s)

Xiaotao Shen shenxt1990@outlook.com

Examples

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

tidymass/massstat documentation built on March 12, 2024, 6:24 a.m.