RGLab / flowWorkspace

flowWorkspace
GNU Affero General Public License v3.0
45 stars 21 forks source link

Cannot subet cytoset by name #343

Closed DillonHammill closed 4 years ago

DillonHammill commented 4 years ago

@mikejiang & @jacobpwagner, I was hoping that you may be able to help me with a problem that a user is experiencing with their FCS files. The files load in OK, but any operation which calls fsApply() internally fails because the individuals flowFrames cannot be extracted by name. I have attached couple of the file for you try: fcs.zip

files <- list.files("fcs", full.names = TRUE)
cs <- load_cytoset_from_fcs(files)

# This is the problematic code:
print(sampleNames(cs))
lapply(sampleNames(cs), function(n) {
  print(n)
  y <- cs[[n, returnType = "flowFrame"]]
  print(y)
})

Looks like it has something to with the leading underscore in the sample names, when it is removed the code succeeds:

sampleNames(cs) <- gsub("^_", "", sampleNames(cs))

# This works:
print(sampleNames(cs))
lapply(sampleNames(cs), function(n) {
  print(n)
  y <- cs[[n, returnType = "flowFrame"]]
  print(y)
})

Would be possible to allow leading underscore in sample names to protect the user from encountering this error or perhaps throw a warning when the files are read in? fsApply() is used frequently so the code often fails. Sure, the files should not be named this way but it may happen by accident and it is quite difficult to troubleshoot.

Thanks for you help! Dillon

mikejiang commented 4 years ago

let me know if the fix works for you

DillonHammill commented 4 years ago

Thanks @mikejiang this is working now.