Knowledgebase: R Integration

R Integration in FCS Express 6

FCS Express can integrate R scripts via the new R integration transformation options within the Transformations tool. The goal of R integration and implementation in FCS Express is to allow users to run their own R scripts and work on the resulting output directly within FCS Express. FCS Express 6 currently supports two types of R scripts, one for adding new transformed parameters (R Add Parameters) and one for adding clustering assignment (R Cluster Transformation). Additional script support will be added soon.

Jump to:

Enabling R Scripts

Creating R Scripts

R Script Details

R Integration in Manual

Short Video Overview of R in FCS Express

Using the FlowClean Script

 

 

Enabling R Integration for FCS Express

  1. Installation
    • On PC Operating Systems:

      When using the PC version of FCS Express, R must be first installed on your machine to enable integration. Please refer to www.r-project.org to download and install R as well as learn more about using R.
    • On Mac Operating Systems:

      R will not need to be installed separately from FCS Express on Mac Operating Systems.
  2. Enable the Application Bridge

    FCS Express integrates R via an External Application Bridge that is enabled in the User Options. Access the File tab→Options→Startup category and check the box for Start the De Novo Software External Application Bridge on login.

  3. Close FCS Express and the FCS Express Startup Screen (if open).
  4. Run FCS Express.

FCS Express will now run and start the external application bridge to R by default allowing you to use transformations from R scripts that you have defined. An icon referring to the External Application Bridge will appear in your tray confirming that the External Application Bridge is active. The icon will appear on the macOS as in the image below left or on the PC in the image below right.

Creating R Scripts Compatible with FCS Express

Full details on the specifications for R scripts running in FCS Express can be found in the FCS Express Manual R Integration Section while the general workflow of R Integration in FCS Express is outlined below.

R Transformations in FCS Express fall within two categories

  • R Add Parameters
  • R Cluster Transformations.
Example of each are outlined in the table below. Click on the links in the table below to access full details in the FCS Express Manual.

##Script Below

Execute <- function(mat)
{
setClass("TransformationResult",
 representation(
newParamData="matrix",
numberOfNewParams="integer",
newParamNames="character"
),

     prototype(

newParamData=c(),
numberOfNewParams=as.integer(0),
newParamNames=""
)
)

   result <- new("TransformationResult")

   result@numberOfNewParams <- as.integer(A)
   result@newParamData <- B
   result@newParamNames <- C

   return(result)
}

##Script Below

Execute <- function(mat)
{
setClass("ClusteringResult",
representation(
clusterAssignments="integer",
numberOfClusters="integer",
clusterNames="character"
),

     prototype(

clusterAssignments=c(),
numberOfClusters=integer(0),
clusterNames=""
)
)

   result <- new("ClusteringResult")

   result@numberOfClusters <- as.integer(A)
   result@clusterAssignments <- as.integer(B)
   result@clusterNames <- C

   return(result)
}

  • Where A, B and C values are defined by the user. As stated above:
  • A can be any integer number. Note that the as.integer() function is required since numbers are otherwise stored as object of class numeric.
  • B can be the result of any user-defined transformation. B must be an object of class matrix with events in columns and parameters in rows. The number of events (i.e. the number of columns) must match the number of events in the mat matrix and the number of parameters (i.e. the number of rows) must match the value defined in B.
  • C is a vector of class character containing the names of the new parameters. Multiple names can be specified using the c() function (e.g. c("name1","name2","name3") ). Please also note that the name of the parameters included in the mat matrix are accessible in R by using the rownames() or the colnames() functions (when parameter are in rows and in columns respectively). Thus parameter names can be derived and used as part of generating new parameter names.
  • Where A, B and C values are defined by the user. As stated above:
  • A can be any integer number. Note that the as.integer() function is required since numbers are otherwise stored as object of class numeric;
  • B can be the membership resulting from any user-defined clustering. It must be a vector of integer values of length equal to the number of events in the mat matrix. The number of unique integer values must be equal to A. The numbering of clusters must begin at 0.
  • C is a vector of class character containing the names of the clusters. Multiple names can be specified using the c() function (e.g. c("name1","name2","name3") ). The length has to be equal to A.