Apply function requiring a matrix to tidy table

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
#> Warning: no nr_children column specified in the data, adding column nr_children and setting to 1.
#> completing cases
data <- bb$data
conf <- bb$config
res <- apply_to_response_matrix(data, conf, .func = base::scale)
#> Warning: Expected 2 pieces. Additional pieces discarded in 4200 rows [1, 2, 3, 4, 5, 6,
#> 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, ...].
#> Joining with `by = join_by(sampleName, protein_Id, peptide_Id)`

stopifnot("abundance_base..scale" %in% colnames(res))
stopifnot("abundance_base..scale" == conf$table$get_response())
conf <- bb$config$clone(deep=TRUE)
conf$table$workIntensity <- "abundance"
res <- apply_to_response_matrix(data, conf$clone(deep=TRUE), .func = robust_scale)
#> Warning: Expected 2 pieces. Additional pieces discarded in 4200 rows [1, 2, 3, 4, 5, 6,
#> 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, ...].
#> Joining with `by = join_by(sampleName, 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)
}
#> Warning: Expected 2 pieces. Additional pieces discarded in 4200 rows [1, 2, 3, 4, 5, 6,
#> 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, ...].
#> Joining with `by = join_by(sampleName, protein_Id, peptide_Id)`