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 <- AnalysisConfiguration$new()
skylineconfig$file_name <- "Replicate.Name"
skylineconfig$hierarchy[["protein_Id"]] <- "Protein.Name"
skylineconfig$hierarchy[["peptide_Id"]] <- "Peptide.Sequence"
skylineconfig$hierarchy[["precursor_Id"]] <- c("Peptide.Sequence", "Precursor.Charge")
skylineconfig$hierarchy[["fragment_Id"]] <- c(
  "Peptide.Sequence", "Precursor.Charge",
  "Fragment.Ion", "Product.Charge"
)
skylineconfig$ident_q_value <- "Detection.Q.Value"
skylineconfig$set_response("Area")
skylineconfig$isotope_label <- "Isotope.Label.Type"
skylineconfig$factors[["Time"]] = "Sampling.Time.Point"
sample_analysis <- setup_analysis(prolfqua_data('data_skylinePRMSample_A')$data, skylineconfig)
#> creating sampleName from file_name 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$file_name = "sample"
config$factors["group_"] = "group"
config$hierarchy[["protein_Id"]] = c("proteinID", "idtype2")
config$hierarchy[["peptide_Id"]] = "peptideID"
config$set_response("abundance")
config$norm_value = "creatinine"

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