cor_mass_dataset: cor_mass_dataset

View source: R/dist_cor.R

cor_mass_datasetR Documentation

cor_mass_dataset

Description

cor_mass_dataset

Usage

cor_mass_dataset(
  x,
  y = NULL,
  margin = c("variable", "sample"),
  use = c("everything", "all.obs", "complete.obs", "na.or.complete",
    "pairwise.complete.obs"),
  method = c("spearman", "pearson", "kendall"),
  data_type = c("wider", "longer"),
  p_adjust_method = c(c("BH", "holm", "hochberg", "hommel", "bonferroni", "BY", "fdr",
    "none"))
)

Arguments

x

mass_dataset class

y

NULL

margin

sample or variable

use

an optional character string giving a method for computing covariances in the presence of missing values. This must be (an abbreviation of) one of the strings "everything", "all.obs", "complete.obs", "na.or.complete", or "pairwise.complete.obs".

method

a character string indicating which correlation coefficient (or covariance) is to be computed. One of "pearson" (default), "kendall", or "spearman": can be abbreviated.

data_type

wider or longer

p_adjust_method

see ?p.adjust

Value

dist returns an object of class "dist".

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

cor_data <-
  object %>%
  cor_mass_dataset(margin = "variable", data_type = "wider")

head(cor_data$correlation[,1:5])
head(cor_data$p_value[,1:5])
head(cor_data$n[,1:5])

cor_data <-
  object %>%
  cor_mass_dataset(margin = "variable", data_type = "longer")

head(cor_data)

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