Skip to contents

Compares adjusted p-values from two SplineOmics result objects across standard categories. Calculates Spearman correlation globally and for significant hits only, generates diagnostic plots, and summarizes overlap statistics including Jaccard index and hit counts.

Note: The feature_names columns in the topTables of splineomics1 and splineomics2 must have the same names, otherwise, no comparisons are possible.

Usage

compare_results(
  splineomics1,
  splineomics2,
  splineomics1_description = "SplineOmics_1",
  splineomics2_description = "SplineOmics_2",
  adj_p_tresh1 = 0.05,
  adj_p_tresh2 = 0.05
)

Arguments

splineomics1

SplineOmics: A list containing limma_splines_result with topTables organized by category and subcategory.

splineomics2

SplineOmics: Same structure as splineomics1; the object to compare.

splineomics1_description

character(1): Character label used for x-axis annotation.

splineomics2_description

character(1): Character label used for y-axis annotation.

adj_p_tresh1

numeric(1): Numeric p-value threshold for calling hits in analysis 1.

adj_p_tresh2

numeric(1): Numeric p-value threshold for calling hits in analysis 2.

Value

A list with components:

correlation_summary

Data frame of global and hit-level correlations

plots

Named list of ggplot objects for all and hit-only subsets.

hits_summary

Data frame with hit counts, overlap, and Jaccard index

Examples

# Minimal runnable example (offline)
if (requireNamespace("ggplot2", quietly = TRUE)) {
  # Two tiny topTables per category with matching feature_names
  feats <- paste0("g", 1:6)
  ttA_te <- data.frame(feature_names = feats,
                       adj.P.Val = c(.01, .2, .03, .8, .5, .04))
  ttB_te <- data.frame(feature_names = feats,
                       adj.P.Val = c(.02, .25, .01, .7, .4, .06))
  ttA_c2 <- data.frame(feature_names = feats,
                       adj.P.Val = c(.2, .8, .04, .3, .9, .7))
  ttB_c2 <- data.frame(feature_names = feats,
                       adj.P.Val = c(.3, .7, .03, .4, .95, .6))
  ttA_c3 <- data.frame(feature_names = feats,
                       adj.P.Val = c(.5, .6, .7, .04, .9, .8))
  ttB_c3 <- data.frame(feature_names = feats,
                       adj.P.Val = c(.6, .55, .65, .03, .85, .75))

  # Assemble limma_splines_result lists (one subcategory per cat)
  lsr1 <- list(
    time_effect = list(WT = ttA_te),
    avrg_diff_conditions = list(comp = ttA_c2),
    interaction_condition_time = list(comp = ttA_c3)
  )
  lsr2 <- list(
    time_effect = list(WT = ttB_te),
    avrg_diff_conditions = list(comp = ttB_c2),
    interaction_condition_time = list(comp = ttB_c3)
  )

  # Minimal SplineOmics shells holding the results
  so1 <- list(limma_splines_result = lsr1); class(so1) <- "SplineOmics"
  so2 <- list(limma_splines_result = lsr2); class(so2) <- "SplineOmics"

  cmp <- compare_results(
    splineomics1 = so1,
    splineomics2 = so2,
    splineomics1_description = "Analysis A",
    splineomics2_description = "Analysis B",
    adj_p_tresh1 = 0.05,
    adj_p_tresh2 = 0.05
  )

  # Inspect outputs
  head(cmp$correlation_summary)
  names(cmp$plots)
  head(cmp$hits_summary)
}
#>                     category subcategory hits_1 hits_2 n_overlap jaccard_index
#> 1                time_effect          WT      3      2         2         0.667
#> 2       avrg_diff_conditions        comp      1      1         1         1.000
#> 3 interaction_condition_time        comp      1      1         1         1.000