Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plotSpillmat error #247

Closed
MayaCyTOFnewbie opened this issue Jan 10, 2022 · 8 comments
Closed

plotSpillmat error #247

MayaCyTOFnewbie opened this issue Jan 10, 2022 · 8 comments

Comments

@MayaCyTOFnewbie
Copy link

Hi!

I am trying to run compensation matrix, currently without samples, just to test if I can make the code work.
The single-antibody stained bead sample ran with EQ beads.
I get the error:
Error in .check_sm(sm, isotope_list) :
The supplied spillover matrix seems to be invalid.
All isotopes should appear in isotope_list.

Thanks!

Maya

here is what I did:

read fcs file

ff =read.FCS(file.path(dir,"20211220_CompBeads_01.FCS"), transformation = FALSE, truncate_max_range = FALSE)

#check colnames
colnames(ff)

#data in SCE format
sce = prepData(ff)

view number of events per sample

table(sce$sample_id)

view non-mass channels

names(int_colData(sce))

specify mass channels stained for & debarcode

bc_ms <- c(111:116,141:176)
sce <- assignPrelim(sce, bc_ms, verbose = FALSE)

#Estimation of distance separation cutoffs
sce <- applyCutoffs(estCutoffs(sce))

compute & extract spillover matrix

sce <- computeSpillmat(sce)
sm <- metadata(sce)$spillover_matrix

do some sanity checks

chs <- channels(sce)
ss_chs <- chs[rowData(sce)$is_bc]
all(diag(sm[ss_chs, ss_chs]) == 1)
all(sm >= 0 & sm <= 1)

Spillover matrix heatmap

plotSpillmat(sce)

Error in .check_sm(sm, isotope_list) :
The supplied spillover matrix seems to be invalid.
All isotopes should appear in isotope_list.

dimnames(sm)
[[1]]
[1] "Cd111Di" "Cd112Di" "In113Di" "Cd114Di" "In115Di" "Cd116Di" "Pr141Di" "Nd142Di" "Nd143Di" "Nd144Di" "Nd145Di" "Nd146Di" "Sm147Di" "Nd148Di" "Sm149Di" "Nd150Di"
[17] "Eu151Di" "Sm152Di" "Eu153Di" "Sm154Di" "Gd155Di" "Gd156Di" "Gd157Di" "Gd158Di" "Tb159Di" "Gd160Di" "Dy161Di" "Dy162Di" "Dy163Di" "Dy164Di" "Ho165Di" "Er166Di"
[33] "Er167Di" "Er168Di" "Tm169Di" "Er170Di" "Yb171Di" "Yb172Di" "Yb173Di" "Yb174Di" "Lu175Di" "Yb176Di"

[[2]]
[1] "Pd102Di" "Rh103Di" "Pd104Di" "Pd105Di" "Pd106Di" "Pd108Di" "Pd110Di" "Cd111Di" "Cd112Di" "In113Di" "Cd114Di" "In115Di" "Cd116Di"
[14] "La139Di" "Ce140Di" "Pr141Di" "Nd142Di" "Nd143Di" "Nd144Di" "Nd145Di" "Nd146Di" "Sm147Di" "Nd148Di" "Sm149Di" "Nd150Di" "Eu151Di"
[27] "Sm152Di" "Eu153Di" "Sm154Di" "Gd155Di" "Gd156Di" "Gd157Di" "Gd158Di" "Tb159Di" "Gd160Di" "Dy161Di" "Dy162Di" "Dy163Di" "Dy164Di"
[40] "Ho165Di" "Er166Di" "Er167Di" "Er168Di" "Tm169Di" "Er170Di" "Yb171Di" "Yb172Di" "Yb173Di" "Yb174Di" "Lu175Di" "Yb176Di" "BCKG190Di"
[53] "Ir191Di" "Ir193Di"

ss_chs
111Cd 112Cd 113In 114Cd 115In 116Cd 141Pr 142Nd 143Nd 144Nd 145Nd 146Nd 147Sm 148Nd 149Sm 150Nd
"Cd111Di" "Cd112Di" "In113Di" "Cd114Di" "In115Di" "Cd116Di" "Pr141Di" "Nd142Di" "Nd143Di" "Nd144Di" "Nd145Di" "Nd146Di" "Sm147Di" "Nd148Di" "Sm149Di" "Nd150Di"
151Eu 152Sm 153Eu 154Sm 155Gd 156Gd 157Gd 158Gd 159Tb 160Gd 161Dy 162Dy 163Dy 164Dy 165Ho 166Er
"Eu151Di" "Sm152Di" "Eu153Di" "Sm154Di" "Gd155Di" "Gd156Di" "Gd157Di" "Gd158Di" "Tb159Di" "Gd160Di" "Dy161Di" "Dy162Di" "Dy163Di" "Dy164Di" "Ho165Di" "Er166Di"
167Er 168Er 169Tm 170Er 171Yb 172Yb 173Yb 174Yb 175Lu 176Yb
"Er167Di" "Er168Di" "Tm169Di" "Er170Di" "Yb171Di" "Yb172Di" "Yb173Di" "Yb174Di" "Lu175Di" "Yb176Di"

sessionInfo()
R version 4.1.1 (2021-08-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows Server x64 (build 17763)

Matrix products: default

locale:
[1] C

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

other attached packages:
[1] circlize_0.4.13 ComplexHeatmap_2.9.3 data.table_1.14.2 premessa_0.2.6 pals_1.7
[6] CytoML_2.4.0 flowWorkspace_4.4.0 ggpubr_0.4.0 RColorBrewer_1.1-2 forcats_0.5.1
[11] dplyr_1.0.7 purrr_0.3.4 readr_2.0.2 tidyr_1.1.4 tibble_3.1.5
[16] tidyverse_1.3.1 uwot_0.1.10 Matrix_1.3-4 cytofclean_1.0.3 scales_1.1.1
[21] cowplot_1.1.1 tcltk2_1.2-11 pheatmap_1.0.12 cytutils_0.1.0 stringr_1.4.0
[26] flowCut_1.3.1 flowAI_1.23.0 CytoNorm_0.0.6 remotes_2.4.1 ggplot2_3.3.5
[31] FlowSOM_2.1.24 igraph_1.2.7 flowCore_2.4.0 flowDensity_1.27.2 CATALYST_1.17.3
[36] SingleCellExperiment_1.15.2 SummarizedExperiment_1.23.4 Biobase_2.52.0 GenomicRanges_1.45.0 GenomeInfoDb_1.29.5
[41] IRanges_2.27.2 S4Vectors_0.30.0 BiocGenerics_0.39.2 MatrixGenerics_1.5.4 matrixStats_0.61.0
[46] devtools_2.4.2 usethis_2.1.3 FlowRepositoryR_1.23.0

loaded via a namespace (and not attached):
[1] scattermore_0.7 knitr_1.36 irlba_2.3.3 multcomp_1.4-17 DelayedArray_0.19.1
[6] RCurl_1.98-1.5 doParallel_1.0.16 generics_0.1.1 ScaledMatrix_1.1.0 callr_3.7.0
[11] TH.data_1.1-0 proxy_0.4-26 ggpointdensity_0.1.0 tzdb_0.1.2 lubridate_1.8.0
[16] xml2_1.3.2 assertthat_0.2.1 viridis_0.6.2 xfun_0.27 hms_1.1.1
[21] evaluate_0.14 fansi_0.5.0 dbplyr_2.1.1 caTools_1.18.2 readxl_1.3.1
[26] Rgraphviz_2.36.0 DBI_1.1.1 ellipsis_0.3.2 RSpectra_0.16-0 ggcyto_1.21.0
[31] ggnewscale_0.4.5 backports_1.3.0 cytolib_2.5.3 RSEIS_4.0-3 RcppParallel_5.1.4
[36] sparseMatrixStats_1.5.3 vctrs_0.3.8 Cairo_1.5-12.2 GEOmap_2.4-4 abind_1.4-5
[41] cachem_1.0.6 withr_2.4.2 ggforce_0.3.3 aws.signature_0.6.0 RPMG_2.2-3
[46] prettyunits_1.1.1 splancs_2.01-42 cluster_2.1.2 dotCall64_1.0-1 crayon_1.4.1
[51] drc_3.0-1 labeling_0.4.2 pkgconfig_2.0.3 tweenr_1.0.2 vipor_0.4.5
[56] pkgload_1.2.3 changepoint_2.2.2 rlang_0.4.11 lifecycle_1.0.1 sandwich_3.0-1
[61] modelr_0.1.8 rsvd_1.0.5 dichromat_2.0-0 cellranger_1.1.0 rprojroot_2.0.2
[66] polyclip_1.10-0 graph_1.70.0 carData_3.0-4 zoo_1.8-9 reprex_2.0.1
[71] base64enc_0.1-3 beeswarm_0.4.0 ggridges_0.5.3 GlobalOptions_0.1.2 processx_3.5.2
[76] png_0.1-7 viridisLite_0.4.0 rjson_0.2.20 bitops_1.0-7 ConsensusClusterPlus_1.57.0
[81] KernSmooth_2.23-20 spam_2.7-0 DelayedMatrixStats_1.15.4 shape_1.4.6 jpeg_0.1-9
[86] rstatix_0.7.0 ggsignif_0.6.3 aws.s3_0.3.21 beachmat_2.9.1 memoise_2.0.0
[91] magrittr_2.0.1 plyr_1.8.6 hexbin_1.28.2 gplots_3.1.1 zlibbioc_1.38.0
[96] compiler_4.1.1 RFOC_3.4-6 plotrix_3.8-2 clue_0.3-60 cli_3.0.1
[101] XVector_0.33.0 ncdfFlow_2.38.0 ps_1.6.0 MASS_7.3-54 tidyselect_1.1.1
[106] stringi_1.7.5 RProtoBufLib_2.5.1 yaml_2.2.1 BiocSingular_1.9.1 latticeExtra_0.6-29
[111] ggrepel_0.9.1 tools_4.1.1 parallel_4.1.1 rio_0.5.27 rstudioapi_0.13
[116] foreach_1.5.1 foreign_0.8-81 gridExtra_2.3 MBA_0.0-9 farver_2.1.0
[121] Rtsne_0.15 rgeos_0.5-8 digest_0.6.28 BiocManager_1.30.16 Rcpp_1.0.7
[126] car_3.0-11 broom_0.7.9 scuttle_1.3.1 RcppAnnoy_0.0.19 IDPmisc_1.1.20
[131] httr_1.4.2 colorspace_2.0-2 rvest_1.0.2 XML_3.99-0.8 fs_1.5.0
[136] splines_4.1.1 fields_12.5 RBGL_1.68.0 scater_1.21.3 sp_1.4-5
[141] mapproj_1.2.7 sessioninfo_1.1.1 jsonlite_1.7.2 testthat_3.1.0 R6_2.5.1
[146] pillar_1.6.4 htmltools_0.5.2 nnls_1.4 glue_1.4.2 fastmap_1.1.0
[151] BiocParallel_1.27.4 BiocNeighbors_1.11.0 class_7.3-19 codetools_0.2-18 maps_3.4.0
[156] pkgbuild_1.2.0 mvtnorm_1.1-3 utf8_1.2.2 lattice_0.20-45 flowViz_1.57.2
[161] Rwave_2.6-0 curl_4.3.2 ggbeeswarm_0.6.0 colorRamps_2.3 gtools_3.9.2
[166] zip_2.2.0 openxlsx_4.2.4 survival_3.2-13 rmarkdown_2.11 desc_1.4.0
[171] munsell_0.5.0 e1071_1.7-9 GetoptLong_1.0.5 GenomeInfoDbData_1.2.6 iterators_1.0.13
[176] haven_2.4.3 reshape2_1.4.4 gtable_0.3.0

@MayaCyTOFnewbie
Copy link
Author

Hi again,

I found issue #35 and modified the isotope list accordingly:

isotope_list2 <- c(CATALYST::isotope_list, list(BCKG=190))
sce = compCytof(x = sce, isotope_list = isotope_list2)

then ran the plot

plotSpillmat(sce)

which works! with a warning I don't understand:

Warning messages:
1: In sprintf("%2.2f", colSums(sm) * 100 - 100, "%") :
  one argument not used by format '%2.2f'
2: It is deprecated to specify `guide = FALSE` to remove a guide. Please use `guide = "none"` instead. 

additionally, the plot generated is missing channels 169:176

I tried to fix using suggestion from issue #204 but I don't have a "panel" object.

I'm not sure if it is relevant, but I think that some the staining for the single stained beads didn't work:

table(sce$bc_id)

111   112   113   114   115   116   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162 
2159  1254   587  1240  1095   946  1079  1081   993  1752  1880     **1**  1600  1972  1197  1459  1227  1769 22832  1023    63   860  1316  1141  1271  3498     **1**  1150 
 163   164   165   166   167   168   169   170   171   172   173   174   175   176 
1282  2663  2947  2081  4154  3694  3520  3019  1935  1911  1212  1623  5007  6474 

BR

Maya

@SamGG
Copy link

SamGG commented Jan 11, 2022

sprintf("%2.2f", colSums(sm) * 100 - 100, "%") :
  one argument not used by format '%2.2f'

The extra "%" is not take into account. "%2.2f" should be replaced by "%2.2f%s". Alt. the extra "%" should be removed and included in the format string as %%.

@MayaCyTOFnewbie
Copy link
Author

Hi Sam,

Thank you for the quick reply!
Can you please translate your reply to a medium/beginner level R programmer? how do I remove the extra "%" and include in the format string as %%?

@SamGG
Copy link

SamGG commented Jan 11, 2022

Hi Maya,
My comment is intended to the package manager or an advanced programmer that would like to find and correct this error.
The initial error message is a warning, and should not change your result. Just ignore it unless you feel a numerical value is wrong.
Best.

@HelenaLC
Copy link
Owner

Hm, I don't really understand how table can give **1** for 146/147; never seen this before. Could you do table(sce$bc_id == "146/7")? Not sure this will really help, but I don't fully understand the issue from the output above.

@MayaCyTOFnewbie
Copy link
Author

MayaCyTOFnewbie commented Jan 11, 2022

Hi,

the issue is that I am missing isotopes 169:176 in my spillover matrix (attached)

I also noticed that some of my single stained beads didn't work. I added this information because I thought it might be the reason for the warning that I don't understand

table(sce$bc_id ==146)

FALSE TRUE
97967 1

thanks again!

Maya

sm_plot

@nilseling
Copy link

I also now ran into this issue. What I noticed is that after removing entries in the spillover matrix via sm[, colSums(sm) != 0] here, the subsetting operation bc_chs <- chs[rowData(x)$is_bc] here is invalid since chs and rowData(x)$is_bc are of different length. This should be corrected and will also address #204 I guess.

@HelenaLC
Copy link
Owner

Relates to #204 (in progress)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants