Spillover compensation and data transformation for flow cytometry. Covers compensation matrix calculation, application, and biexponential/arcsinh transforms. Use when correcting spectral overlap between fluorophores or transforming data for analysis.
Before using code patterns, verify installed versions match. If versions differ:
R: packageVersion('<pkg>') then ?function_name to verify parameters
If code throws ImportError, AttributeError, or TypeError, introspect the installed
package and adapt the example to match the actual API rather than retrying.
Compensation and Transformation
"Compensate and transform my flow cytometry data" → Correct spectral overlap between fluorophores using a compensation matrix and apply biexponential/arcsinh transforms for visualization and analysis.
R: flowCore::compensate() then flowCore::transform() with estimateLogicle()
Load Compensation Matrix
library(flowCore)
# From FCS file keywords
fcs <- read.FCS('sample.fcs', transformation = FALSE)
comp_matrix <- keyword(fcs)$`$SPILLOVER`
# Or from CSV file
comp_matrix <- as.matrix(read.csv('compensation.csv', row.names = 1))
Goal: Apply a standard compensation-then-transformation workflow to all samples in a flowSet.
Approach: Define a reusable preprocessing function that first applies the spillover compensation matrix, then auto-estimates and applies logicle transformation on marker channels, and map it across all samples with fsApply.