fit_nonlinear {proBatch} | R Documentation

## Fit a non-linear trend (currently optimized for LOESS)

### Description

Fit a non-linear trend (currently optimized for LOESS)

### Usage

    fit_nonlinear(
      df_feature_batch,
      measure_col = "Intensity",
      order_col = "order",
      feature_id = NULL,
      batch_id = NULL,
      fit_func = "loess_regression",
      optimize_span = FALSE,
      no_fit_imputed = TRUE,
      qual_col = "m_score",
      qual_value = 2,
      min_measurements = 8,
      ...
    )

### Arguments

`df_feature_batch` | data frame containing response variable e.g. samples in order and explanatory variable e.g. measurement for a specific feature (peptide) in a specific batch
`measure_col` | if `df_long` is among the parameters, it is the column with expression/abundance/intensity; otherwise, it is used internally for consistency.
`order_col` | column in `sample_annotation` that determines sample order. It is used for in initial assessment plots (plot_sample_mean_or_boxplot) and feature-level diagnostics (feature_level_diagnostics). Can be 'NULL' if sample order is irrelevant (e.g. in genomic experiments). For more details, order definition/inference, see define_sample_order and date_to_sample_order
`feature_id` | the name of the feature, required for warnings
`batch_id` | the name of the batch, required for warnings
`fit_func` | function to use for the fit, e.g. `loess_regression`
`optimize_span` | logical, whether to specify span or optimize it (specific entirely for LOESS regression)
`no_fit_imputed` | (logical) whether to fit the imputed (requant) values
`qual_col` | column to color point by certain value denoted by `color_by_qual_value`. Design with inferred/requant values in OpenSWATH output data, which means argument value has to be set to `m_score`.
`qual_value` | value in `qual_col` to color. For OpenSWATH data, this argument value has to be set to `2` (this is an `m_score` value for imputed values (requant values).
`min_measurements` | the absolute threshold to filter
`...` | additional parameters to be passed to the fitting function

### Value

vector of fitted response values

### Examples

    test_peptide = example_proteome$peptide_group_label[1]
    selected_peptide = example_proteome$peptide_group_label == test_peptide
    df_selected = example_proteome[selected_peptide,]
    selected_batch = example_sample_annotation$MS_batch == 'Batch_1'
    batch_selected_df = example_sample_annotation[selected_batch,]
    df_for_test = merge(df_selected, batch_selected_df, by = 'FullRunName')
    fit_values = fit_nonlinear(df_for_test)

    #for the case where are two many missing values, no curve is fit
    selected_batch = example_sample_annotation$MS_batch == 'Batch_2'
    batch_selected_df = example_sample_annotation[selected_batch,]
    df_for_test = merge(df_selected, batch_selected_df, by = 'FullRunName')
    fit_values = fit_nonlinear(df_for_test)
    missing_values = df_for_test[['m_score']] == 2
    all(fit_values[!is.na(fit_values)] == df_for_test[['Intensity']][!missing_values])

[Package proBatch version 1.6.0 Index]