Adds labels to rows of all individual spectra in collections. Such labels are required for subsequent processing functions that aggregate spectral collections by group, for example colmean_group_apply(). It can also be used to initialize a single spectral collection with labels when inputting a single matrix, data frame or data.table.

ids_apply(X, dt_prep_sets = NULL, vec_row, vec_id, vec_group)

Arguments

X

matrix, data.frame or data.table for which label rows are to be applied.

dt_prep_sets

A standardized data.table, i.e. returned from specprepper::*_apply() function. Contains labelled sets of preprocessed spectra: This argument allows to chain preprocessing in sequential manner, and i.e. apply variable Savitzky-Golay smoothers with a single function application.

vec_row

atomic vector with row labels; need to have same length as nrow(X) or rows in all spc_proc list-column data.table's.

vec_id

atomic vector with id labels, needs to have same length as nrow(X) or rows in all spc_proc list-column data.table's. id_vec typically represents the smallest hiararchical unit in the measurement design, e.g., a replicate spectrum measured.

vec_group

atomic vector with group labels; needs to have same length as nrow(X) or rows in all spc_proc list-column data.table's. id_group typically represents the group to aggregate by in specific methods applied later. Currently, this is colmean_group_apply() that takes grouped means of spectra or collections of spectra.

Value

If X is specified:

  • A one-row "data.table" with the following columns

    • prep_set: "init_ids",

    • prep_label: "prep_label"

    • prep_params: list-column of length 1 with "data.table" containing init_ids = NA

    • id_labels: list-column (repeated across rows) with "data.table" containing columns with labels: row (from vec_row), id (from vec_id), and group (from vec_group). If dt_prep_sets is specified:

  • A "data.table" with as many rows as spectral collections. A spectral collection typically represents an outcome of one or more specific preprocessing with methods and possibly associated parameters used. Specifically, it augments the input dt_prep_sets and outputs the following (list-)columns:

    • prep_set: appends "-init_ids to the input string that states what the main preprocessings done in previous steps.

    • prep_label: appends "-init_ids to the input string that states what was done with abbreviations of methods in previous steps.

    • prep_params: augments each data.table element in the list-column with a new non-specific column init_ids = NA (indicating a new label column but no direct effect on the processed spectra).

    • id_labels: new list-column that contains a set of labels that applies for all spectral collections nested within respective rows of the dt_prep_sets input. Each data.table in the list contains the label columns row (from vec_row),id (from vec_id), and group (from vec_group).

    • spec_prep: unmodified list-column with sets of already prepared, processed spectra. Each element is a data.table which rows corresponds to the row labels in id_labels.