Skip to contents

Extracts columns relevant for a configuration from a data frame and create new columns e.g. sampleName column etc.

Usage

setup_analysis(data, configuration, cc = TRUE, from_factors = FALSE)

Arguments

data

data.frame

configuration

AnalysisConfiguration

cc

complete cases default TRUE

from_factors

if TRUE, create sampleName from factor columns

Examples


skylineconfig <- create_config_Skyline(isotopeLabel = "Isotope.Label.Type",
 ident_qValue = "Detection.Q.Value")
skylineconfig$factors[["Time"]] = "Sampling.Time.Point"
sample_analysis <- setup_analysis(prolfqua_data('data_skylinePRMSample_A')$data, skylineconfig)
#> creating sampleName from fileName column
#> Warning: no nr_children column specified in the data, adding column nr_children and setting to 1.
#> completing cases
#> completing cases done
#> setup done

# Example with normValue column (e.g., creatinine)
set.seed(1234)
data <- sim_lfq_data(Nprot = 10, PEPTIDE = TRUE, N = 4)
data$nr_children <- 1
data$isotopeLabel <- "light"
data$qValue <- 0

# Add creatinine values per sample (not per protein/peptide)
sample_creatinine <- data |> dplyr::select(sample) |> dplyr::distinct() |>
  dplyr::mutate(creatinine = rnorm(dplyr::n(), mean = 100, sd = 10))
data <- dplyr::inner_join(data, sample_creatinine, by = "sample")

config <- AnalysisConfiguration$new()
config$fileName = "sample"
config$factors["group_"] = "group"
config$hierarchy[["protein_Id"]] = c("proteinID", "idtype2")
config$hierarchy[["peptide_Id"]] = "peptideID"
config$set_response("abundance")
config$normValue = "creatinine"

adata <- setup_analysis(data, config)
#> creating sampleName from fileName column
#> completing cases
#> completing cases done
#> setup done