View source: R/olink_ordinal_regression.R
| olink_ordinal_regression_posthoc | R Documentation |
Performs a post hoc ANOVA test using emmeans::emmeans with Tukey p-value
adjustment per assay (by OlinkID) for each panel at confidence level 0.95.
See olink_anova for details of input notation.
The function handles both factor and numerical variables and/or covariates. The posthoc test for a numerical variable compares the difference in means of the ordinal outcome variable (default: NPX) for 1 standard deviation difference in the numerical variable, e.g. mean ordinal NPX at mean(numerical variable) versus mean NPX at mean(numerical variable) + 1*SD(numerical variable).
olink_ordinal_regression_posthoc(
df,
olinkid_list = NULL,
variable,
covariates = NULL,
effect,
effect_formula,
mean_return = FALSE,
post_hoc_padjust_method = "tukey",
check_log = NULL,
verbose = TRUE
)
olink_ordinalRegression_posthoc(
df,
olinkid_list = NULL,
variable,
covariates = NULL,
effect,
effect_formula,
mean_return = FALSE,
post_hoc_padjust_method = "tukey",
check_log = NULL,
verbose = TRUE
)
df |
NPX data frame in long format with at least protein name (Assay), OlinkID, UniProt, Panel and a factor with at least 3 levels. |
olinkid_list |
Character vector of OlinkID's on which to perform post hoc analysis. If not specified, all assays in df are used. |
variable |
Single character value or character array. Variable(s) to test. If length > 1, the included variable names will be used in crossed analyses. Also takes ':' notation. |
covariates |
Single character value or character array. Default: NULL. Covariates to include. Takes ':'/'*' notation. Crossed analysis will not be inferred from main effects. |
effect |
Term on which to perform post-hoc. Character vector. Must be subset of or identical to variable. |
effect_formula |
(optional) A character vector specifying the names of
the predictors over which estimated marginal means are desired as defined in
the |
mean_return |
Boolean. If true, returns the mean of each factor level rather than the difference in means (default). Note that no p-value is returned for mean_return = TRUE and no adjustment is performed. |
post_hoc_padjust_method |
P-value adjustment method to use for post-hoc
comparisons within an assay. Options include |
check_log |
A named list returned by |
verbose |
Boolean. Default: True. If information about removed samples, factor conversion and final model formula is to be printed to the console. |
Tibble of posthoc tests for specified effect, arranged by ascending adjusted p-values. 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
contrast: "character" the groups that were compared
estimate: "numeric" difference in mean of the ordinal NPX between groups
Adjusted_pval: "numeric" adjusted p-value for the test
Threshold: "character" if adjusted p-value is significant or not (< 0.05)
if (rlang::is_installed(pkg = c("ordinal", "emmeans"))) {
npx_df <- OlinkAnalyze::npx_data1 |>
dplyr::filter(
!grepl(
pattern = "control",
x = .data[["SampleID"]],
ignore.case = TRUE
)
)
check_log <- OlinkAnalyze::check_npx(df = npx_df)
# Two-way Ordinal Regression with CLM.
# Results in model NPX~Treatment+Time+Treatment:Time.
ordinalRegression_results <- OlinkAnalyze::olink_ordinal_regression(
df = npx_df,
variable = "Treatment:Time"
)
significant_assays <- ordinalRegression_results |>
dplyr::filter(
.data[["Threshold"]] == "Significant"
& .data[["term"]] == "Time"
) |>
dplyr::pull(
.data[["OlinkID"]]
) |>
unique()
# Posthoc test
ordRegr_results_posthoc <- OlinkAnalyze::olink_ordinal_regression_posthoc(
df = npx_df,
variable = c("Treatment:Time"),
olinkid_list = significant_assays,
effect = "Time",
check_log = check_log
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.