olink_one_non_parametric {OlinkAnalyze} | R Documentation |
Function which performs a Kruskal-Wallis Test or Friedman Test per protein
Description
Performs an Kruskal-Wallis Test for each assay (by OlinkID) in every panel using stats::kruskal.test.
Performs an Friedman Test for each assay (by OlinkID) in every panel using rstatix::friedman_test.
The function handles factor variable.
Samples that have no variable information or missing factor levels are automatically removed from the analysis (specified in a message if verbose = TRUE).
Character columns in the input dataframe are automatically converted to factors (specified in a message if verbose = T).
Numerical variables are not converted to factors.
If a numerical variable is to be used as a factor, this conversion needs to be done on the dataframe before the function call.
Inference is specified in a message if verbose = TRUE.
The formula notation of the final model is specified in a message if verbose = TRUE.
Adjusted p-values are calculated by stats::p.adjust according to the Benjamini & Hochberg (1995) method (“fdr”).
The threshold is determined by logic evaluation of Adjusted_pval < 0.05.
Usage
olink_one_non_parametric(
df,
variable,
dependence = FALSE,
subject = NULL,
verbose = TRUE
)
Arguments
df |
NPX or Quantified_value data frame in long format with at least protein name (Assay), OlinkID, UniProt, Panel and a factor with at least 3 levels. |
variable |
Single character value. |
dependence |
Boolean. Default: FALSE. When the groups are independent, the kruskal-Wallis will run, when the groups are dependent, the Friedman test will run. |
subject |
Group information for the repeated measurement. If (dependence = TRUE), this parameter need to be specified. |
verbose |
Boolean. Default: True. If information about removed samples, factor conversion and final model formula is to be printed to the console. |
Value
A tibble containing the Kruskal-Wallis Test or Friedman Test results for every protein.
Columns include:
Assay: "character" Protein symbol
OlinkID: "character" Olink specific ID
UniProt: "character" UniProt ID
Panel: "character" Name of Olink Panel
term: "character" term in model
df: "numeric" degrees of freedom
method: "character" which method was used
statistic: "named numeric" the value of the test statistic with a name describing it
p.value: "numeric" p-value for the test
Adjusted_pval: "numeric" adjusted p-value for the test (Benjamini&Hochberg)
Threshold: "character" if adjusted p-value is significant or not (< 0.05)
Examples
library(dplyr)
# One-way Kruskal-Wallis Test
try({ # May fail if dependencies are not installed
kruskal_results <- olink_one_non_parametric(df = npx_data1,
variable = "Site")
})
#Friedman Test
friedman_results <- olink_one_non_parametric(df = npx_data1,
variable = "Time",
subject = "Subject",
dependence = TRUE)