Here we show how to install packages and how to carry out a panel harmonization.


Only once per R installation, i.e. whenever you install a new version of R.

# 2020-05-11: tested with R4.0.0
# 2020-03-24: update the github location of cytulis

# cytutils is installed by the next command
# install_github("ismmshimc/cytutils")
# but we need an update from the original package
# so, do install the following update
# cytofcore is installed by the next command


Use as many times as you need.

You should copy command lines from the section below, and paste them into the R console. There are 2 stages where you have to edit CSV files. Open them with Excel, edit them, and save them in CSV. Go slow, copy/paste one line at a time in order to understand what you are doing and to catch any error at the exact point it occurs.

The first stage will create in the working directory a channel_rename.csv file and a channel_rename folder where the resulting FCS files are stored. The second stage takes place in it.

The second stage creates a cytofcore_channels.csv file and a relabeled directory where the resulting FCS files are stored. There are the processed files with aligned channels that are needed for cytofkit analysis.

The configuration allows you selecting the folder to process.

### Configuration STAGE

# In the following example, the copies of the original FCS have been placed in
# the "FCS NK" directory on the disk E: (Windows example)
# working.folder = "E:/FCS a renommer/FCS NK" 
# choose a FCS file within the directory of FCS to process
working.folder = dirname(file.choose())
if (!dir.exists(working.folder)) {
  stop("The directory of FCS files is not valid.")
cat("The working folder is ", working.folder, "\n")
# You should run the next lines of the script without any change,
# if everything goes well ;)

### channelRename STAGE
### it allows to rename channel names and their description


# The first call of the command channelRename() scans the FCS files and
# create the "channel_rename.csv" file

# Then you open the csv file with Excel and edit the channel name and the
# channel description (aka marker)
# Save the file in CSV format

# In the NEXT calls, the command channelRename() scans the FCS and
# renames the FCS files according to the channel_rename.csv file

### cytofCore.updatePanel STAGE
### it makes all FCS having the same set of channels


# Build a file name
working.folder.2 = file.path(working.folder, "channel_rename")
cat(paste0("cytofcore working directory, STEP 2:\n", working.folder.2))
cytofcore.template = file.path(working.folder.2, "cytofcore_channels.csv")

# Create a new report of renamed FCS files
files.list = dir(path = working.folder.2, pattern = "*.fcs", full.names = TRUE)
channels = importChannelNames(files.list, na.mass.rm = FALSE)
channels <- channels[order(channels$name), ]
write.table(channels[, c("name", "desc")], cytofcore.template, 
  row.names = FALSE, col.names = FALSE, sep = ",", quote = TRUE)

# Then you open the csv file with Excel. The main goal is to remove the 
# channels you don't want. You may also edit the channel name and the 
# channel description (aka marker)
# Save the file in CSV format
# Reconciliate panel
cytofCore.updatePanel(templateFile = cytofcore.template, fcsFolder = working.folder.2)


At the first stage, be sure to rename the name and the description of each channel.

At the second stage, be sure to add missing channels in order to keep channels aligned across all FCS files.