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

Introduction

We can use masscleaner for missing value (MV) imputation.

First, we need to prepare samples for masscleaner.

library(masscleaner)
library(massdataset)
library(tidyverse)

Data preparation

Load the data in previous step.

load("peak_tables/POS/object")
get_mv_number(object)
head(massdataset::get_mv_number(object, by = "sample"))
head(massdataset::get_mv_number(object, by = "variable"))

head(massdataset::get_mv_number(object, by = "sample", show_by = "percentage"))
head(massdataset::get_mv_number(object, by = "variable"), show_by = "percentage")

Impute missing values

zero

object_zero = 
  impute_mv(object = object, method = "zero")
get_mv_number(object_zero)

KNN

object = 
  impute_mv(object = object, method = "knn")
get_mv_number(object)

More methods can be found ?impute_mv().

Note

If there are blank samples in dataset, we use different method to impute missing values.

For Blank samples, just use the zero.

For non-Blank samples, just use the knn or other method

Save data for next analysis.

save(object, file = "peak_tables/POS/object")

Session information

sessionInfo()


tidymass/masscleaner documentation built on Sept. 4, 2023, 3:21 a.m.