vignettes/CytoExploreR-Transformations.Rmd
CytoExploreR-Transformations.Rmd
CytoExploreR has full support for log, arcsinh, biexponential and logicle transformations implemented in the flowWorkspace package. In this vignette we will demonstrate how CytoExploreR facilitates fine tuning of transformation parameters and how these optimised transformations can be applied cytometry data. For consistency with the RGLab suite of cytometry data analysis packages, CytoExploreR uses a series of wrapper functions to add support for these transformations with improved support for customisation. Below is a list of the key functions that you will encounter in this vignette:
cyto_transformer_log
implements the flowjo_log_trans
version of the log transformation.cyto_transformer_arcsinh
implements the asing_Gml2
version of the arcsinh transformation.cyto_transformer_biex
implements the flowjo_biexp
version of the biexponential transformation.cyto_transformer_logicle
implements the estimateLogicle
version of the logicle transformation.cyto_transformer_combine
combines individual transformation definitions into a single list of transformers that can be applied to the data using cyto_transform
.cyto_transform
is capable of automatically computing transformers and is used to apply a set of transformers to the data.
# Load required packages
library(CytoExploreR)
library(CytoExploreRData)
# Activation dataset
Activation
# Save Activation dataset FCS files to Activation-Samples folder
cyto_save(Activation, save_as = "Activation-Samples")
cyto_setup
. It is recommended that experiment details be filled in at this point as this information can be used to easily select samples to use when customising transformations. If your computer struggles with applying the transformations, it is recommended that you set the restrict argument to TRUE in cyto_setup
to restrict the data to only the parameters for which markers have been assigned. Although not required for this vignette, it is always a good idea to ensure that the data has been compensated prior to data transformations. The spillover matrices attached to each of the files can be applied using cyto_compensate
.
# Activation GatingSet
gs <- cyto_setup("Activation-Samples")
# Apply compensation
gs <- cyto_compensate(gs)
cyto_transformer
functions to obtain optimised transformation definitions for each of the fluorescent channels. These transformer functions will automatically pool the supplied data, apply the transformation using the specified parameters to the specified channels and plot the resultant transformed data using cyto_plot
. The definition of the transformation can be altered by changing the arguments of the underlying flowWorkspace transformer function. It is important to note that these cyto_transformer
functions do not apply these transformers to the data, they are purely used to optimise the transformers prior to applying the combined transformers to the data using cyto_transform
. As a result, these cyto_transformer
functions do not return the transformed data, but instead the transformer definitions that can be applied to the data using cyto_transform
.
cyto_transformer
functions will automatically generate transformers for all fluorescent channels. To obtain transformers for a specific set of parameters. simply supply the names of these channels/markers to the channels argument. To use a specific subset of the data to visualise and customise the transformations, users can supply specific slection criteria to the select argument. Next we will explore each of these cyto_transformer
functions to obtain transformation definitions for all the fluorescent channels. This provides a quick overview of all possible transformer types to identify those that provide the best visualisation of the data.
# Default log transformer
trans_log <- cyto_transformer_log(gs)
# Default arcsinh transformer
trans_arcsinh <- cyto_transformer_arcsinh(gs)
# Default biexponentail transformer
trans_biex <- cyto_transformer_biex(gs)
# Default biexponentail transformer
trans_logicle <- cyto_transformer_logicle(gs)
trans_biex
which contains our transformation definitions for all the fluorescent channels.
# Remove PE-A & 7-AAD-A transformers
trans_biex <- trans_biex[-match(c("PE-A", "7-AAD-A"), names(trans_biex))]
# Check transformers have been removed
trans_biex
?cyto_transformer_biex
will open the help documentation that contains links to the relevant documents in flowWorkspace. After consulting these documents, it looks like we can use the widthBasis
argument to fine-tune the transformation definition. The default value is set to -10, so let’s try changing this to -100 and -1000 to see if it improves the visualisation of the data.
# default PE transformer
PE_biex <- cyto_transformer_biex(gs,
channels = "PE-A",
widthBasis = -10)
# PE transformer
<- cyto_transformer_biex(gs,
PE_biex channels = "PE-A",.
widthBasis = -100)
# PE transformer
<- cyto_transformer_biex(gs,
PE_biex channels = "PE-A",.
widthBasis = -1000)
cyto_transformer_combine
.
# PE transformer
<- cyto_transformer_biex(gs,
PE_biex channels = "PE-A",.
widthBasis = -100)
# Combine transformer definitions
<- cyto_transformer_combine(trans_biex,
trans
PE_biex, "7-AAD-A"])
trans_logicle[
# All transformer definitions
trans
cyto_transform
. It is important to optimise the transformers before using cyto_transform
as it is not currently possible to inverse the transformations applied to a GatingSet.
# Apply transformers to data
gs <- cyto_transform(gs,
trans = trans)
cyto_transform
can also apply batch transformers to the data using the flowWorkspace defaults. Simply indicate the type of transformation to apply through the type
argument and cyto_transform
will make a call to the relevant cyto_transformer
function to obtain the transformer definitions using the defaults in flowWorkspace. These transformers will then be applied to the data within cyto_transform
and the transformed data will be returned. It is important to note that transformer definitions cannot be customised on a per channel basis using this method. For this reason, it is recommended that the transformer definitions be optimised using the cyto_transformer
functions prior to apply them to the data using cyto_transform
.
# Activation GatingSet
gs <- cyto_setup("Activation-Samples")
# Apply compensation
gs <- cyto_compensate(gs)
# Apply transformers
gs <- cyto_transform(gs,
type = "logicle")
cyto_transformer
function, by altering the parameters in the underlying flowWorkspace function. Transformers can be applied to the data using cyto_transform
. cyto_transform
is also capable of applying batch transformers using the default flowWorkspace parameters. Flow cytometry users must remember to always apply the data transformations post compensation.