knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  warning = FALSE,
  message = TRUE,
  out.width = "100%"
)

Data preparation

library(massdataset)
library(tidyverse)
library(massstat)
data("liver_aging_pos")
liver_aging_pos

Distance

library(massdataset)
library(tidyverse)
data("expression_data")
data("sample_info")
data("sample_info_note")
data("variable_info")
data("variable_info_note")
object =
  create_mass_dataset(
    expression_data = expression_data,
    sample_info = sample_info,
    variable_info = variable_info,
    sample_info_note = sample_info_note,
    variable_info_note = variable_info_note
  )
object
x =
  object %>%
  log(2) %>%
  scale()
variable_distance <-
  dist_mass_dataset(x = x, margin = "variable")
head(as.matrix(variable_distance)[, 1:5])
sample_distance <-
  dist_mass_dataset(x = x, margin = "sample")
head(as.matrix(sample_distance)[, 1:5])
plot(hclust(d = sample_distance))

Correlation

library(massdataset)
library(tidyverse)
data("liver_aging_pos")
x =
  liver_aging_pos %>%
  `+`(1) %>% 
  log(2) %>%
  scale()

variable_cor <-
  cor_mass_dataset(x = x[1:100,], margin = "variable")
head(as.matrix(variable_cor)[, 1:5])
sample_cor <-
  cor_mass_dataset(x = x, margin = "sample")
head(as.matrix(sample_cor)[, 1:5])
library(corrplot)
corrplot(sample_cor)

Session information

sessionInfo()


jaspershen/massstat documentation built on March 14, 2024, 7:02 p.m.