Post Thu Apr 27, 2023 3:16 pm

file ... seems to be corrupted.

Ever encountered this message under R? Ever been stopped in a process?

To avoid such a failure, the following R function reads all FCS in the selected directory and reports errors. Once started, the system asks to select an FCS file. All FCS in the same directory will be analysed.

We observed such an error when exporting FCS files from FlowJo. Although it is not frequent, it is annoying to be stopped during a process. Re-exporting the file usually solves the error.

Update will be published at http://impact-cyto.inserm.fr/en/fcs-fil ... corrupted/

Hope this helps,
Samuel

  Code:
# check FCS are not corrupted when reading with flowCore
# run the following code once per R session
check_fcs_ok_flowcore = function() {
# verify required package are installed, which is usually true
pkg_ok = TRUE
for (pkg in c("tcltk", "flowCore")) {
  if (system.file(package=pkg)=="") {
    cat(pkg, "needs to be installed first.\n")
    pkg_ok = FALSE
  }
}
if (!pkg_ok)
  stop("install required packages first.", call. = FALSE)
# allow the user to select a FCS file
# all FCS in the same directory will be scanned
my_dir = dirname(tcltk::tk_choose.files())
# stop if user cancelled
if (length(my_dir)==0)
  stop("no FCS file selected", call. = FALSE)
# get the list of FCS files and try to read them
files = list.files(path = my_dir, full.names = TRUE, pattern = "\\.fcs$")
scan = sapply(files, function(fn) {
  cat(fn, "\n")
  try(suppressWarnings({ ff = read.FCS(fn) }))
})
}
# run the following code for each directory to check
check_fcs_ok_flowcore()