check_npx_col_names: Check, update and define column names used in downstream...

View source: R/check_npx.R

check_npx_col_namesR Documentation

Check, update and define column names used in downstream analyses

Description

OlinkAnalyze uses pre-defined names of columns of data frames to perform downstream analyses. At the same time, different Olink platforms export data with different column names (e.g. different protein quantification metric). This function aims to instruct each function of OlinkAnalyze on the column it should be using for the downstream analysis. This should be seamless for data exported from Olink Software and imported to R using the read_npx function.

However, in certain cases the columns of interest might be named differently. This function allows assigning custom-named columns of a data frame to internally expected variables that will in turn instruct Olink Analyze functions to use them for downstream analysis. For example, if one wished to use the column PCNormalizedNPX for their analysis instead of the column NPX, then they can assign this new name to the internal variable quant to inform the package that in the downstream analysis PCNormalizedNPX should be used. See example 3.

Similarly, in case of multiple matches (e.g. the data frame contains both columns LOD and PlateLOD) the ties will need to be resolved by the user using the argument preferred_names from this function. See example 4.

The argument preferred_names is a named character vector with internal column names as names and column names of the current data set as values. Names of the input vector can be one or more of the following: sample_id, sample_type, assay_type, olink_id, uniprot, assay, panel, block, plate_id, panel_version, lod, quant, ext_npx, count, qc_warning, assay_warn, normalization, and qc_version

Usage

check_npx_col_names(df, preferred_names = NULL)

Arguments

df

A "tibble" or "ArrowObject" from read_npx.

preferred_names

A named character vector where names are internal column names and values are column names to be selected from the input data frame. Read the description for further information.

Value

List of column names from the input data frame marking the columns to be used in downstream analyses.

Author(s)

Klev Diamanti Masoumeh Sheikhi

Examples


# read NPX data
npx_file <- system.file("extdata",
                        "npx_data_ext.parquet",
                        package = "OlinkAnalyze")
npx_df <- OlinkAnalyze::read_npx(filename = npx_file)

# Example 1: run df as is
OlinkAnalyze:::check_npx_col_names(df = npx_df)

# Example 2: SampleType missing from data frame
npx_df |>
  dplyr::select(
    -dplyr::all_of(
      c("SampleType")
    )
  ) |>
  OlinkAnalyze:::check_npx_col_names()

# Example 3: Use PCNormalizedNPX instead on NPX
OlinkAnalyze:::check_npx_col_names(
  df = npx_df,
  preferred_names = c("quant" = "PCNormalizedNPX")
)

# Example 4: Use PCNormalizedNPX instead on NPX, and PlateLOD instead of LOD
npx_df |>
  dplyr::mutate(
    LOD = 1L,
    PlateLOD = 2L
  ) |>
  OlinkAnalyze:::check_npx_col_names(
    preferred_names = c("quant" = "PCNormalizedNPX",
                        "lod" = "PlateLOD")
  )



OlinkAnalyze documentation built on June 24, 2026, 1:06 a.m.