Build protein models from data

build_model(
  data,
  model_strategy,
  subject_Id = if ("LFQData" %in% class(data)) {
     data$subject_Id()
 } else {
    
    "protein_Id"
 },
  modelName = model_strategy$model_name
)

Arguments

data

data - a data frame

subject_Id

grouping variable

modelName

model name

modelFunction

model function

Value

a object of class Model

Examples

D <- prolfqua::sim_lfq_data_peptide_config(Nprot = 20, weight_missing = 0.1)
#> creating sampleName from fileName column
#> Warning: no nr_children column specified in the data, adding column nr_children and setting to 1.
#> completing cases
D$data$abundance |> is.na() |> sum()
#> [1] 68
D <- prolfqua::sim_lfq_data_peptide_config(Nprot = 20, weight_missing = 0.1, seed =3)
#> creating sampleName from fileName column
#> Warning: no nr_children column specified in the data, adding column nr_children and setting to 1.
#> completing cases
D$data$abundance |> is.na() |> sum()
#> [1] 59
modelName <- "f_condtion_r_peptide"
formula_randomPeptide <-
  strategy_lmer("abundance  ~ group_ + (1 | peptide_Id) + (1 | sampleName)",
   model_name = modelName)


mod <- prolfqua::build_model(
 D$data,
 formula_randomPeptide,
 modelName = modelName,
 subject_Id = D$config$table$hierarchy_keys_depth())
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> Warning: There were 6 warnings in `dplyr::mutate()`.
#> The first warning was:
#>  In argument: `linear_model = purrr::map(data, model_strategy$model_fun, pb =
#>   pb)`.
#>  In group 1: `protein_Id = "0GRprF~7339"`.
#> Caused by warning in `value[[3L]]()`:
#> ! WARN :Error: grouping factors must have > 1 sampled level
#>  Run `dplyr::last_dplyr_warnings()` to see the 5 remaining warnings.
#> Joining with `by = join_by(protein_Id)`
aovtable <- mod$get_anova()

mod <- prolfqua::build_model(
 LFQData$new(D$data, D$config),
 formula_randomPeptide,
 modelName = modelName)
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> Warning: There were 6 warnings in `dplyr::mutate()`.
#> The first warning was:
#>  In argument: `linear_model = purrr::map(data, model_strategy$model_fun, pb =
#>   pb)`.
#>  In group 1: `protein_Id = "0GRprF~7339"`.
#> Caused by warning in `value[[3L]]()`:
#> ! WARN :Error: grouping factors must have > 1 sampled level
#>  Run `dplyr::last_dplyr_warnings()` to see the 5 remaining warnings.
#> Joining with `by = join_by(protein_Id)`
model_summary(mod)
#> $exists
#> 
#> FALSE  TRUE 
#>     6    14 
#> 
#> $isSingular
#> 
#> TRUE 
#>   14 
#>