diff --git a/DESCRIPTION b/DESCRIPTION index 359457b..b0ae639 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: OmicsProcessing Type: Package Title: OmicsProcessing -Version: 1.1.1 +Version: 1.1.2 Date: 2025-03-03 Authors@R: c( person("Vivian", "Viallon", role = c("aut")), diff --git a/R/normalization_SERRF.R b/R/normalization_SERRF.R index 2ae0ab6..b4b6355 100644 --- a/R/normalization_SERRF.R +++ b/R/normalization_SERRF.R @@ -9,10 +9,12 @@ #' single-level strata is created so all samples are treated as one batch. When #' provided, the column must exist in `df` with no NA values. #' @param num_screen_SERRF Number of correlated features to use in model fitting. Default is 10. +#' @param seed Set a random number generator seed, default 0. #' #' @return A normalized data frame. #' @export -normalise_SERRF <- function(df, target_cols = NULL, is_qc = NULL, strata_col = NULL, num_screen_SERRF = 10) { +normalise_SERRF <- function(df, target_cols = NULL, is_qc = NULL, strata_col = NULL, num_screen_SERRF = 10, seed = 0) { + set.seed(seed) # ---- Validation ---- temp_strata_cols <- character(0) @@ -75,7 +77,7 @@ normalise_SERRF <- function(df, target_cols = NULL, is_qc = NULL, strata_col = N # ---- Normalize Each Feature ---- for (j in seq_along(target_cols)) { - if (j %% 250 == 1) cat("Feature", j, "\n") + if (j %% 250 == 1) cat(j, "out of ", target_cols, " features normalised\n") feature_name <- target_cols[j] for (batch in batch_levels) { diff --git a/man/normalise_SERRF.Rd b/man/normalise_SERRF.Rd index ed43245..16c3488 100644 --- a/man/normalise_SERRF.Rd +++ b/man/normalise_SERRF.Rd @@ -9,7 +9,8 @@ normalise_SERRF( target_cols = NULL, is_qc = NULL, strata_col = NULL, - num_screen_SERRF = 10 + num_screen_SERRF = 10, + seed = 0 ) } \arguments{ @@ -24,6 +25,8 @@ single-level strata is created so all samples are treated as one batch. When provided, the column must exist in \code{df} with no NA values.} \item{num_screen_SERRF}{Number of correlated features to use in model fitting. Default is 10.} + +\item{seed}{Set a random number generator seed, default 0.} } \value{ A normalized data frame. diff --git a/vignettes/feature-clustering.Rmd b/vignettes/feature-clustering.Rmd index 6188e0f..b3e7fc4 100644 --- a/vignettes/feature-clustering.Rmd +++ b/vignettes/feature-clustering.Rmd @@ -46,6 +46,7 @@ res_scores <- OmicsProcessing::cluster_features_by_retention_time( target_cols = target_cols, rt_height = 0.07, method = "scores", + corr_thresh = 0.75, scores = scores ) @@ -53,7 +54,9 @@ clustered_df <- res_scores$clustered_df # original features + representative rep_map <- res_scores$representatives_map # mapping of representatives to raw features ``` -The `rt_height` parameter defines the maximum RT span for forming a cluster: features whose RTs differ by less than this value are grouped. Within each cluster, the supplied `scores` determine the representative. In this example, pre-normalisation mean intensities serve as scores; consequently, each representative is the feature with the highest mean intensity before normalisation. The `representatives_map` lists representatives as names, with vectors of raw feature names as their values. +The `rt_height` parameter defines the maximum RT span for forming a cluster: features whose RTs differ by less than this value are grouped. Within each RT‑based group, pairwise correlations between features are calculated, and the features are further partitioned into correlation‑based subclusters. The supplied `scores` determine the representative feature for each subcluster. In this example, pre-normalisation mean intensities serve as scores; consequently, each representative is the feature with the highest mean intensity before normalisation. + +The `representatives_map` lists representatives as names, with vectors of raw feature names as their values. In effect, features with similar retention times are identified, and among those with high correlation, the feature with the highest pre‑normalisation mean intensity is selected as the representative. ### How representatives are selected with the correlation method