From 0031c5535b4544fb94c0f327656bb76af73959fc Mon Sep 17 00:00:00 2001 From: Tim Mocking Date: Wed, 7 Feb 2024 09:49:40 +0100 Subject: [PATCH] Fix bug with transformLists and environments Based on https://github.com/RGLab/flowCore/issues/267 --- R/getLogicle.R | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/R/getLogicle.R b/R/getLogicle.R index 914623b..d7d3e40 100644 --- a/R/getLogicle.R +++ b/R/getLogicle.R @@ -79,6 +79,7 @@ getLogicle <- function(files, verbose = TRUE){ # Estimate linearization widths wParams <- estimateLogicles(files) transforms <- list() + widths <- c() for (channel in colnames(wParams)){ w <- median(wParams[, channel]) if (verbose){ @@ -87,10 +88,11 @@ getLogicle <- function(files, verbose = TRUE){ } transforms[[channel]] <- flowCore::logicleTransform(w = w, transformationId = channel) - # For some reason, running the the line below is required to construct - # a proper transformList??? I cannot figure out why... - # If not called, the same width is used for all channels - summary(transforms[[channel]]) + widths <- c(widths, w) + } + # Assign every w again because every transform has its own environment + for (i in seq_along(widths)) { + assign("w", widths[i], envir = environment(transforms[[colnames(wParams)[i]]])) } tfList <- flowCore::transformList(colnames(wParams), transforms) return(tfList)