Invalid spillover matrix with values greater than 1
1
0
Entering edit mode
David • 0
@4aed4ce5
Last seen 21 months ago
United States

Currently, I am attempting to compensate for spillover across channels in mass cytometry datasets. However, whenever I attempt to do so with files that were manually cleaned to remove debris and aggregates, the spillover matrix that is generated appears to have values greater than 1. I have absolutely no idea why this would be the case even after looking at the source code and documentation for the computeSpillmat function and CATALYST, and consequently I would appreciate any and all assistance to resolving this issue.


library(CATALYST)
library(cowplot)
library(flowCore)
library(ggplot2)
library(SingleCellExperiment)
library(readxl)
library(FlowSOM)

listfcs=c("20220318_Yukako_Sample1_Cleaned.fcs", "20220325_Stimulation_Cleaned.fcs","March_30_Cleaned_sample_1.fcs","March_30_Cleaned_sample_2.fcs", "March_30_Cleaned_sample_3.fcs","March_30_Cleaned_sample_4.fcs",
          "April_5_Cleaned_sample_1.fcs","April_5_Cleaned_sample_2.fcs", "April_5_Cleaned_sample_3.fcs","April_5_Cleaned_sample_4.fcs",
          "April_11_Cleaned_sample_1.fcs","April_11_Cleaned_sample_2.fcs", "April_11_Cleaned_sample_3.fcs","April_11_Cleaned_sample_4.fcs")
realdata <- read.flowSet(files=listfcs, path="C:/Users/DWQ/OneDrive - Mass General Brigham/Documents/Raw data/Cleaned")
setwd("C:/Users/DWQ/OneDrive - Mass General Brigham/Documents")
panel <- "Panel_markers.xlsx"
barkey <- "Fluidigm_20plex_barcode_key.csv"
panel <- read_excel(panel)
head(data.frame(panel))

md <- "Cleaned_metadata.xlsx"

md <- read_excel(md)
md$condition <- factor(md$condition, levels = c("Ref", "Radiotherapy"))
md$sample_id <- factor(md$sample_id, levels = md$sample_id[order(md$condition)])
set.seed(1234)
sce <- prepData(realdata, panel, md, features = panel$fcs_colname)
bc_ms <- c(89,103,120, 127,131,133,138, 140:156, 158:176,191,193:195,198,208,209)

sce <- assignPrelim(sce, bc_ms, verbose = FALSE)
sce <- applyCutoffs(estCutoffs(sce))

# compute & extract spillover matrix
sce <- computeSpillmat(sce, assay="exprs")
sm <- metadata(sce)$spillover_matrix

sce <- compCytof(sce, sm, method = "nnls", overwrite = TRUE)

sce <- cluster(sce, features = "state",
               xdim = 10, ydim = 10, maxK = 20, seed = 1234)
sce <- runDR(sce, "UMAP", cells = 1e3, features = "state")
sce <- runDR(sce, "TSNE", cells = 500, features = "state")

This is the resulting error:


> sce <- applyCutoffs(estCutoffs(sce))
Error in optim(startVec, opfct, hessian = TRUE, method = optMethod, control = list(maxit = maxIt,  : 
  non-finite finite-difference value [3]
Error in optim(startVec, opfct, hessian = TRUE, method = optMethod, control = list(maxit = maxIt,  : 
  non-finite finite-difference value [3]
Error in optim(startVec, opfct, hessian = TRUE, method = optMethod, control = list(maxit = maxIt,  : 
  non-finite finite-difference value [3]
Error in optim(startVec, opfct, hessian = TRUE, method = optMethod, control = list(maxit = maxIt,  : 
  non-finite finite-difference value [3]

> # compute & extract spillover matrix
> sce <- computeSpillmat(sce, assay="exprs")

> sm <- metadata(sce)$spillover_matrix

> sce <- compCytof(sce, sm, method = "nnls", overwrite = TRUE)
Error in .check_sm(x, isotope_list) : 
The supplied spillover matrix is invalid as it contains entries greater than 1.
Valid spill values are non-negative and mustn't exceed 1.

This is a list of the packages I am using:

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

Matrix products: default

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

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

other attached packages:
 [1] FlowSOM_2.4.0               igraph_1.3.4                readxl_1.4.0                ggplot2_3.3.6              
 [5] flowCore_2.8.0              cowplot_1.1.1               CATALYST_1.20.1             SingleCellExperiment_1.18.0
 [9] SummarizedExperiment_1.26.1 Biobase_2.56.0              GenomicRanges_1.48.0        GenomeInfoDb_1.32.2        
[13] IRanges_2.30.0              S4Vectors_0.34.0            BiocGenerics_0.42.0         MatrixGenerics_1.8.1       
[17] matrixStats_0.62.0         

loaded via a namespace (and not attached):
  [1] backports_1.4.1             circlize_0.4.15             drc_3.0-1                   plyr_1.8.7                 
  [5] ConsensusClusterPlus_1.60.0 splines_4.2.1               BiocParallel_1.30.3         scattermore_0.8            
  [9] scater_1.24.0               TH.data_1.1-1               digest_0.6.29               foreach_1.5.2              
 [13] viridis_0.6.2               fansi_1.0.3                 magrittr_2.0.3              ScaledMatrix_1.4.0         
 [17] CytoML_2.8.0                cluster_2.1.3               doParallel_1.0.17           aws.signature_0.6.0        
 [21] ComplexHeatmap_2.12.0       RcppParallel_5.1.5          sandwich_3.0-2              flowWorkspace_4.8.0        
 [25] cytolib_2.8.0               jpeg_0.1-9                  colorspace_2.0-3            ggrepel_0.9.1              
 [29] dplyr_1.0.9                 crayon_1.5.1                RCurl_1.98-1.7              jsonlite_1.8.0             
 [33] hexbin_1.28.2               graph_1.74.0                survival_3.3-1              zoo_1.8-10                 
 [37] iterators_1.0.14            glue_1.6.2                  polyclip_1.10-0             gtable_0.3.0               
 [41] nnls_1.4                    zlibbioc_1.42.0             XVector_0.36.0              GetoptLong_1.0.5           
 [45] DelayedArray_0.22.0         ggcyto_1.24.1               car_3.1-0                   BiocSingular_1.12.0        
 [49] Rgraphviz_2.40.0            shape_1.4.6                 abind_1.4-5                 scales_1.2.0               
 [53] pheatmap_1.0.12             mvtnorm_1.1-3               DBI_1.1.3                   rstatix_0.7.0              
 [57] Rcpp_1.0.9                  plotrix_3.8-2               viridisLite_0.4.0           clue_0.3-61                
 [61] rsvd_1.0.5                  httr_1.4.3                  RColorBrewer_1.1-3          ellipsis_0.3.2             
 [65] pkgconfig_2.0.3             XML_3.99-0.10               farver_2.1.1                scuttle_1.6.2              
 [69] deldir_1.0-6                utf8_1.2.2                  tidyselect_1.1.2            rlang_1.0.4                
 [73] reshape2_1.4.4              cellranger_1.1.0            munsell_0.5.0               tools_4.2.1                
 [77] cli_3.3.0                   generics_0.1.3              broom_1.0.0                 ggridges_0.5.3             
 [81] aws.s3_0.3.21               stringr_1.4.0               yaml_2.3.5                  purrr_0.3.4                
 [85] RBGL_1.72.0                 sparseMatrixStats_1.8.0     xml2_1.3.3                  compiler_4.2.1             
 [89] rstudioapi_0.13             beeswarm_0.4.0              curl_4.3.2                  png_0.1-7                  
 [93] ggsignif_0.6.3              tibble_3.1.8                tweenr_1.0.2                stringi_1.7.8              
 [97] lattice_0.20-45             Matrix_1.4-1                vctrs_0.4.1                 pillar_1.8.0               
[101] lifecycle_1.0.1             GlobalOptions_0.1.2         BiocNeighbors_1.14.0        data.table_1.14.2          
[105] bitops_1.0-7                irlba_2.3.5                 colorRamps_2.3.1            R6_2.5.1                   
[109] latticeExtra_0.6-30         gridExtra_2.3               RProtoBufLib_2.8.0          vipor_0.4.5                
[113] codetools_0.2-18            MASS_7.3-58                 gtools_3.9.3                assertthat_0.2.1           
[117] rjson_0.2.21                withr_2.5.0                 multcomp_1.4-19             GenomeInfoDbData_1.2.8     
[121] parallel_4.2.1              ncdfFlow_2.42.1             grid_4.2.1                  beachmat_2.12.0            
[125] tidyr_1.2.0                 ggpointdensity_0.1.0        DelayedMatrixStats_1.18.0   carData_3.0-5              
[129] Rtsne_0.16                  ggpubr_0.4.0                ggnewscale_0.4.7            ggforce_0.3.3              
[133] base64enc_0.1-3             ggbeeswarm_0.6.0            interp_1.1-3

Please let me know if you need any additional information.

CATALYST • 853 views
ADD COMMENT
0
Entering edit mode

Hi,

did you ever resolve the error? I am facing the same issue right now.

Best, Marlene

ADD REPLY
0
Entering edit mode
SamGG ▴ 360
@samgg-6428
Last seen 2 days ago
France/Marseille/Inserm

Hi,

There is a first error at sce <- applyCutoffs(estCutoffs(sce)). It should be solved before considering the next error, ie the spillover matrix.

In fact, the first error occurs because assignPrelim() was not given a valid debarcoding scheme. The debarcoding scheme describes the masses used for barcoding the samples, not the ones used for characterizing the cells. From CATALYST documentation, the debarcoding scheme is a binary table with sample IDs as row and numeric barcode masses as column names:

   102 104 105 106 108 110
A1   1   1   1   0   0   0
A2   1   1   0   1   0   0
A3   1   1   0   0   1   0
A4   1   1   0   0   0   1
A5   1   0   1   1   0   0
B1   1   0   1   0   1   0

This is typically created using Excel or so. There is an example of a barcoded FCS and a debarcoding CSV scheme at Nolan's lab as pointed by PF Gherardini debarcoding tool in Premessa.

Once this is solved, I guess the errors will not persist. If the data come from a core facility nearby, ask them.

Best, Samuel

ADD COMMENT

Login before adding your answer.

Traffic: 917 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