In a FCS file, the count of cells  is written in the HEADER. In the DATA segment of the FCS file, the measurements table is written and its count of cells should match the count of the header. When the read.FCS function of the flowCore package detects that counts are not the same, it stops the reading of the FCS file, which could also stop the application using it.

file ... seems to be corrupted.
The actual number of cells in data section is not consistent with keyword '$TOT'

In order to prevent such a failure, the following R function reads all the FCS of the selected directory and reports errors. Once launched, the system asks to select a FCS file. All FCS in the same directory will be scanned.

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

# 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

Email us to report your comments.