Skip to content

Unexpected behavior of transformList #267

@timmocking

Description

@timmocking

I want to create a transformList object by supplying a custom "w" parameter for every channel in a loop. However, when I create a list of transformations, the w-parameter is retro-actively modified for earlier items in the list.

transforms <- list()
for (i in 1:8){
  transforms[[LETTERS[i]]] <- flowCore::logicleTransform(w = i)
}
# Print the width of "A" (should be 1)
print(as.list(environment(transforms[1]$A@.Data))$w) # output: [1] 8

For some reason, this can be prevented by calling summary() on the list if flowCore is loaded. However, the list becomes a closure type if flowCore is not loaded...

library(flowCore)
transforms <- list()
for (i in 1:8){
  transforms[[LETTERS[i]]] <- flowCore::logicleTransform(w = i)
  summary(transforms[[LETTERS[i]]])
}
# Print the width of "A" (should be 1)
print(as.list(environment(transforms[1]$A@.Data))$w) # output: [1] 1

Is this the expected behavior?

R version 4.3.1 (2023-06-16)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.6 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_GB.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       

time zone: Europe/Amsterdam
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] compiler_4.3.1      RProtoBufLib_2.12.1 cytolib_2.12.1      tools_4.3.1         rstudioapi_0.15.0   Biobase_2.60.0      S4Vectors_0.38.2    flowCore_2.12.2     BiocGenerics_0.46.0
[10] matrixStats_1.2.0   stats4_4.3.1      

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions