| check_npx | R Documentation |
This function performs various checks on NPX data, including checking column names, validating Olink identifiers, identifying assays with NA values for all samples and detecting duplicate sample identifiers.
check_npx(df, preferred_names = NULL)
df |
A "tibble" or "ArrowObject"
from |
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. |
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"
A list containing the following elements:
col_names List of column names from the input data frame marking the columns to be used in downstream analyses.
oid_invalid Character vector of invalid OlinkID.
assay_na Character vector of assays with all samples having NA values.
sample_id_dups Character vector of duplicate SampleID.
sample_id_na Character vector containing SampleID of samples with quantified values NA for all assays.
col_class Data frame with columns of incorrect type including column key col_key, column name col_name, detected column type col_class and expected column type expected_col_class.
assay_qc Character vector containing OlinkID of assays with at least one assay warning.
non_unique_uniprot Character vector of OlinkID mapped to more than one UniProt ID.
darid_invalid Character vector containing outdated combinations of DataAnalysisRefID and PanelDataArchiveVersion.
Masoumeh Sheikhi Klev Diamanti
## Not run:
# Example 0: Use npx_data1 to check that check_npx works
check_npx_result <- OlinkAnalyze::npx_data1 |>
OlinkAnalyze::check_npx() |>
suppressWarnings()
# 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(df = npx_df)
# Example 2: SampleType missing from data frame
npx_df |>
dplyr::select(
-dplyr::all_of(
c("SampleType")
)
) |>
OlinkAnalyze::check_npx()
# Example 3: Use PCNormalizedNPX instead on NPX
OlinkAnalyze::check_npx(
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(
preferred_names = c("quant" = "PCNormalizedNPX",
"lod" = "PlateLOD")
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.