Skip to contents

Apply function requiring a matrix to tidy table

Usage

apply_to_response_matrix(data, config, .func, .funcname = NULL)

Arguments

data

data.frame

config

AnalysisConfiguration

.func

function

.funcname

name of function (used for creating new column)

Examples



bb <- sim_lfq_data_peptide_config(Nprot = 100)
#> creating sampleName from fileName column
#> completing cases
#> completing cases done
#> setup done
data <- bb$data
conf <- bb$config
res <- apply_to_response_matrix(data, conf, .func = base::scale)
#> Joining with `by = join_by(sampleName, isotopeLabel, protein_Id, peptide_Id)`

stopifnot("abundance_base..scale" %in% colnames(res))
stopifnot("abundance_base..scale" == conf$get_response())
conf <- bb$config$clone(deep=TRUE)
conf$workIntensity <- "abundance"
res <- apply_to_response_matrix(data, conf$clone(deep=TRUE), .func = robust_scale)
#> Joining with `by = join_by(sampleName, isotopeLabel, protein_Id, peptide_Id)`

# Normalize data using the vsn method from bioconductor

if( require("vsn")){
 res <- apply_to_response_matrix(data, conf$clone(deep=TRUE), .func = vsn::justvsn)
}
#> Joining with `by = join_by(sampleName, isotopeLabel, protein_Id, peptide_Id)`