Skip to content

Commit 9da4c96

Browse files
committed
Fix deprecated config bindings and config_f closures in bundled data
Regenerate all 5 .rda data objects to silence deprecated $table/$parameter active binding warnings during R CMD INSTALL lazyload, and update config_f closures to use direct $factors access instead of $table$factors.
1 parent 09de521 commit 9da4c96

6 files changed

Lines changed: 86 additions & 0 deletions

data-raw/fix_deprecated_config.R

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Fix deprecated $table/$parameter active bindings in serialized data objects
2+
#
3+
# Root cause: During `R CMD INSTALL`, the lazyload DB creation phase evaluates
4+
# all active bindings on R6 objects. The `$table` and `$parameter` active
5+
# bindings on AnalysisConfiguration print deprecation messages when read.
6+
#
7+
# Sources of warnings:
8+
# 1. data_ionstar.rda — IonstarData R6 with $config and $config_N (2 configs)
9+
# 2. data_IonstarProtein_subsetNorm.rda — list with $config (1 config)
10+
# Total: 3 configs × 2 bindings = 6 deprecation messages
11+
#
12+
# Fix: Replace the noisy active bindings with silent versions that still return
13+
# self for backwards compatibility. Uses unlockBinding() to allow replacement
14+
# on R6's locked environments.
15+
#
16+
# Additionally fixes 3 .rda files with config_f closures that used the old
17+
# config$table$factors[...] syntax.
18+
19+
library(prolfqua)
20+
21+
#' Replace deprecated active bindings on an AnalysisConfiguration with silent versions.
22+
#' The R6 environment is locked, but unlockBinding() allows replacing individual bindings.
23+
#' The new binding function uses the R6 enclosing environment so `self` resolves correctly.
24+
silence_deprecated_bindings <- function(config) {
25+
stopifnot(inherits(config, "AnalysisConfiguration"))
26+
env <- config # R6 public env IS the object
27+
enclos <- env[[".__enclos_env__"]]
28+
for (nm in c("table", "parameter")) {
29+
if (exists(nm, envir = env, inherits = FALSE) && bindingIsActive(nm, env)) {
30+
unlockBinding(nm, env)
31+
silent_fn <- function() self
32+
environment(silent_fn) <- enclos
33+
makeActiveBinding(nm, silent_fn, env)
34+
}
35+
}
36+
invisible(config)
37+
}
38+
39+
# --- data_ionstar: IonstarData R6 with config + config_N ---
40+
load("data/data_ionstar.rda")
41+
silence_deprecated_bindings(data_ionstar$config)
42+
silence_deprecated_bindings(data_ionstar$config_N)
43+
usethis::use_data(data_ionstar, overwrite = TRUE)
44+
45+
# --- data_IonstarProtein_subsetNorm: list with config ---
46+
load("data/data_IonstarProtein_subsetNorm.rda")
47+
silence_deprecated_bindings(data_IonstarProtein_subsetNorm$config)
48+
usethis::use_data(data_IonstarProtein_subsetNorm, overwrite = TRUE)
49+
50+
# --- data_skylinePRMSample_A: fix config_f closure ---
51+
load("data/data_skylinePRMSample_A.rda")
52+
data_skylinePRMSample_A$config_f <- function() {
53+
config <- create_config_Skyline(isotopeLabel = "Isotope.Label.Type",
54+
ident_qValue = "Detection.Q.Value")
55+
config$factors[["Time"]] = "Sampling.Time.Point"
56+
return(config)
57+
}
58+
usethis::use_data(data_skylinePRMSample_A, overwrite = TRUE)
59+
60+
# --- data_skylineSRM_HL_A: fix config_f closure ---
61+
load("data/data_skylineSRM_HL_A.rda")
62+
data_skylineSRM_HL_A$config_f <- function() {
63+
skylineconfig_HL <- create_config_Skyline(isotopeLabel = "Isotope.Label",
64+
ident_qValue = "annotation_QValue")
65+
skylineconfig_HL$factors[["treatment_c"]] <- "Condition2"
66+
skylineconfig_HL$factors[["time_c"]] <- "time"
67+
skylineconfig_HL$is_response_transformed = FALSE
68+
return(skylineconfig_HL)
69+
}
70+
usethis::use_data(data_skylineSRM_HL_A, overwrite = TRUE)
71+
72+
# --- data_spectronautDIA250_A: fix config_f closure ---
73+
load("data/data_spectronautDIA250_A.rda")
74+
data_spectronautDIA250_A$config_f <- function() {
75+
spectronautDIAData250_config <- prolfqua::create_config_Spectronaut_Peptide(
76+
isotopeLabel = "Isotope.Label",
77+
ident_qValue = "EG.Qvalue")
78+
spectronautDIAData250_config$factors[["coding"]] = "coding"
79+
spectronautDIAData250_config$factors[["sex"]] = "sex"
80+
spectronautDIAData250_config$factors[["age"]] = "age"
81+
spectronautDIAData250_config$factors[["Sample_id"]] = "Sample.Name"
82+
return(spectronautDIAData250_config)
83+
}
84+
usethis::use_data(data_spectronautDIA250_A, overwrite = TRUE)
85+
86+
cat("\nDone. All 5 data objects regenerated.\n")
5.96 KB
Binary file not shown.

data/data_ionstar.rda

206 KB
Binary file not shown.

data/data_skylinePRMSample_A.rda

34.9 KB
Binary file not shown.

data/data_skylineSRM_HL_A.rda

12.3 KB
Binary file not shown.

data/data_spectronautDIA250_A.rda

84.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)