How to modify a compensation matrix in an fcs file
1
1
Entering edit mode
aguirre ▴ 20
@c6ce5d11
Last seen 8 months ago
France

I am trying to modify the compensation matrix of an fcs file using flowCore.

I have no error or warning but it seems that the modified compensation was not applied to the FlowFrame object.

Below is a code example.

Can anyone help me?

library(FlowCore)
frame <- read.FCS(myFile)    # this is an fcs 3.0 file
#let's create a dummy matrix for the example
mat <- diag(10)
mat[1,2] <- 0.5

# change the name for channels to match the names in the fcs 3.0 file
 colnames(mat) <- c("FL1-A",  "FL2-A",  "FL3-A",  "FL4-A",  "FL5-A",  "FL6-A",  "FL7-A",  "FL8-A",  "FL9-A",  "FL10-A")
 rownames(mat) <- c("FL1-A",  "FL2-A",  "FL3-A",  "FL4-A",  "FL5-A",  "FL6-A",  "FL7-A",  "FL8-A",  "FL9-A",  "FL10-A")

#These names match the names from the fcs file
> colnames(frame)
 [1] "FS-A"   "FS-W"   "SS-H"   "SS-A"   "SS-W"   "FL1-A"  "FL2-A"  "FL3-A"  "FL4-A"  "FL5-A"  "FL6-A"  "FL7-A"  "FL8-A" 
[14] "FL9-A"  "FL10-A" "TIME"

# Apply compensation to the flowFrame
  comp <- compensation(mat)
  frame_comp <- compensate(frame, comp)

# if we check if any modification of the original compensation matrix have been done
spillover(fcs)$`$SPILLOVER` == spillover(frame_comp)$`$SPILLOVER`

>         6    7    8    9   10   11   12   13   14   15
 [1,] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
 [2,] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
 [3,] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
 [4,] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
 [5,] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
 [6,] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
 [7,] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
 [8,] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
 [9,] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[10,] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE

# So no modification in the compensation have been done by the compensate() function..

sessionInfo( )

R version 4.2.1 (2022-06-23 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale:
[1] LC_COLLATE=French_France.utf8  LC_CTYPE=French_France.utf8    LC_MONETARY=French_France.utf8
[4] LC_NUMERIC=C                   LC_TIME=French_France.utf8    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] XML_3.99-0.12  flowCore_2.8.0

loaded via a namespace (and not attached):
 [1] compiler_4.2.1      RProtoBufLib_2.8.0  cytolib_2.8.0       tools_4.2.1         Rcpp_1.0.9         
 [6] Biobase_2.56.0      S4Vectors_0.34.0    BiocGenerics_0.42.0 matrixStats_0.62.0  RcppParallel_5.1.5 
[11] stats4_4.2.1
flowCore FlowCytometry • 1.2k views
ADD COMMENT
1
Entering edit mode
aguirre ▴ 20
@c6ce5d11
Last seen 8 months ago
France

Eventually I don't know why the previous code didn't work to modify the compensation matrix (I guess that my understanding of the compensate() function is insufficient).

But I did found a workaround. Adding the following codeline was all that was needed to modify the compensation matrix.

keyword(frame)$`$SPILLOVER` <- mat
ADD COMMENT

Login before adding your answer.

Traffic: 855 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6