vignettes/CytoRSuite-Compensation.Rmd
CytoRSuite-Compensation.Rmd
CytoRSuite provides some useful functions to aid in compensation of fluorescent spillover, including spillover_compute
for automated compensation, spillover_edit
to interactively modify spillover matrices and cyto_plot_compensation
to visualise compensation. Here we aim to demonstrate the appropriate use of these functions to obtain accurate spillover values for compensation.
The CytoRSuite compensation workflow is as follows:
flowSet
.GatingSet
.gate_draw
to home in on a homogenous cell population (e.g. Single Cells).spillover_compute
to automatically calculate estimates for the spillover matrix.spillover_edit
.cyto_plot_compensation
to identify any issues.spillover_edit
.flowSet
Traditionally, all compensation controls including an universal unstained control are stored in a folder called “Compensation Controls” in the current working directory. For demonstration purposes we will use the Compensation
dataset supplied in CytoRSuiteData which is a flowSet containing 5 single stain compensation controls and a universal unstained control.
Let’s gate the samples to home in on the Single Cells population. Gating prior to using spillover_compute
will yield much more accurate spillover values.
spillover_compute
spillover_compute
will guide the user through channel selection for each of the compensation controls and save these selections to “Compensation-Channels.csv” for downstream use. This file can be passed to the channel_match
argument of cyto_plot_compensation
to bypass the channel selection process. Next the user gates the positive signal for each single stain control using an interval
gate. This population will be used internally to calculate the percentage spillover based on the unstained control. The calculated spillover matrix is returned and written to a csv file for downstream analyses. The name of this file is controlled by the spillover
argument.
Users are prompted to select a fluorescent channel for each of the compensation controls from a drop-down menu. The results are saved to a csv file called “Compensation-Channels.csv” for later use. This channel selection process can be bypassed by supplying the name of a channel match file to the channel_match
argument.
A density distribution of each control in the appropriate channel will be plotted for users to gate the positive signal to use for spillover calculation. The unstained control is overlaid in red as a reference for gating.
The calculated spillover matrix can be read into R using read.csv:
spill <- read.csv("Spillover-Matrix.csv", header = TRUE, row.names = 1)
colnames(spill) <- rownames(spill)
spill
## Alexa Fluor 488-A PE-A PE-Texas Red-A 7-AAD-A
## Alexa Fluor 488-A 1.000000 0.000000 0.000000 0.000000
## PE-A 0.091033 1.000000 0.651885 0.416292
## PE-Texas Red-A 0.000000 0.000000 1.000000 0.000000
## 7-AAD-A 0.063728 0.064851 0.081134 1.000000
## PE-Cy7-A 0.005500 0.012740 0.013858 0.019638
## Alexa Fluor 405-A 0.000000 0.000000 0.000000 0.000000
## Alexa Fluor 430-A 0.122271 0.103727 0.108006 0.104338
## Qdot 605-A 0.000000 0.000000 0.000000 0.000000
## Alexa Fluor 647-A 0.000000 0.000000 0.000000 0.000000
## Alexa Fluor 700-A 0.000000 0.000000 0.000000 0.000000
## APC-Cy7-A 0.020893 0.021993 0.025842 0.032989
## PE-Cy7-A Alexa Fluor 405-A Alexa Fluor 430-A Qdot 605-A
## Alexa Fluor 488-A 0.000000 0.000000 0.000000 0.000000
## PE-A 0.088103 0.119826 0.065562 0.404853
## PE-Texas Red-A 0.000000 0.000000 0.000000 0.000000
## 7-AAD-A 0.271757 0.099010 0.052167 0.210264
## PE-Cy7-A 1.000000 0.009957 0.005951 0.025511
## Alexa Fluor 405-A 0.000000 1.000000 0.000000 0.000000
## Alexa Fluor 430-A 0.035866 0.789992 1.000000 3.313563
## Qdot 605-A 0.000000 0.000000 0.000000 1.000000
## Alexa Fluor 647-A 0.000000 0.000000 0.000000 0.000000
## Alexa Fluor 700-A 0.000000 0.000000 0.000000 0.000000
## APC-Cy7-A 0.056412 0.028982 0.016159 0.064532
## Alexa Fluor 647-A Alexa Fluor 700-A APC-Cy7-A
## Alexa Fluor 488-A 0.000000 0.000000 0.000000
## PE-A 0.063705 0.041998 0.010067
## PE-Texas Red-A 0.000000 0.000000 0.000000
## 7-AAD-A 0.076405 0.143769 0.035942
## PE-Cy7-A 0.005629 0.016500 0.054000
## Alexa Fluor 405-A 0.000000 0.000000 0.000000
## Alexa Fluor 430-A 0.060548 0.023957 0.006892
## Qdot 605-A 0.000000 0.000000 0.000000
## Alexa Fluor 647-A 1.000000 0.000000 0.000000
## Alexa Fluor 700-A 0.000000 1.000000 0.000000
## APC-Cy7-A 0.087923 0.219586 1.000000
spillover_edit
spillover_edit
leverages a shiny interface to facilitate realtime visualisation of changes to fluorescent spillover values.
spillover_edit
features:
Modifying the spillover values will automatically result in the plot being updated. The correct spillover value is such that the median of the stained population is equal to that of the unstained population (i.e. red line and purple line should meet in the center of the stained population). Looks like the PE-Cy7 control is slightly over compensated in the APC-Cy7 channel, let’s modify the value and click save to correct this:
Clicking on the Plots tab will display fluorescence spillover in all fluorescent channels with options to overlay the unstained control and the un-compensated sample.
cyto_plot_compensation
cyto_plot_compensation
will automatically plot each compensation control in all fluorescent channels to identify any potential compensation issues. To identify any issues simply scroll through the plots by clicking the arrows in the Plots window. For brevity only the plots for PE Cy7 compensation control are shown below:
For more information on these compensation functions refer to the documentation for these functions in the Reference. To learn more about the gating functions included in CytoRSuite refer to Gating Functions vignette.