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

mass_dataset object support many R base functions.

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
  )

For example, you can get the information of your object.

dim(object)
nrow(object)
ncol(object)
dimnames(object)

This means that object has 1000 variables and 8 samples.

apply(object, 2, mean)

You can also get the sample ids and variables.

colnames(object)
head(rownames(object))

Use [ to select variables and samples from object.

##only remain first 5 variables
object[1:5,]

##only remain first 5 samples
object[,1:5]

##only remain first 5 samples and 5 variables
object[1:5,1:5]

If you know the variables or sample names you want to select, you can also use the samples ids or variables ids.

colnames(object)
object[,c("Blank_3", "Blank_4")]
###log
object2 = 
  log(object + 1, 10)
unlist(object[1,,drop = TRUE])
unlist(object2[1,,drop = TRUE])

###scale
object2 = 
  scale(object, center = TRUE, scale = TRUE)
unlist(object[1,,drop = TRUE])
unlist(object2[1,,drop = TRUE])

Session information

sessionInfo()


tidymass/massdataset documentation built on Jan. 30, 2024, 2:55 p.m.