MarioniLab / scran

Clone of the Bioconductor repository for the scran package.
https://bioconductor.org/packages/devel/bioc/html/scran.html
40 stars 22 forks source link

computeSumFactors #36

Closed s2hui closed 5 years ago

s2hui commented 5 years ago

Hi.

Running into the following error when running computeSumFactors() - I didn't encounter this problem in Bioconductor 3.8 ( I am now running Bioconductor 3.9). I am not sure what the problem is? Thanks for your help.

sce.cs <- computeSumFactors(sce) Error in qr.qty(QR, resid) : NA/NaN/Inf in foreign function call (arg 5) In addition: Warning messages: 1: In FUN(...) : encountered negative size factor estimates 2: In FUN(...) : encountered negative size factor estimates 3: In FUN(...) : encountered negative size factor estimates 4: In FUN(...) : encountered negative size factor estimates 5: In FUN(...) : encountered negative size factor estimates

sce class: SingleCellExperiment dim: 33694 15111 metadata(0): assays(1): counts rownames(33694): RP11-34P13.3 FAM138A ... AC213203.1 FAM231B rowData names(0): colnames(15111): AACGTTGCAGTCAGCC AACTCAGGTTCAACCA ... CTAAGACGTTACAGAA TGCTACCTCACCACCT colData names(2): channel clusterId reducedDimNames(0): spikeNames(0):

sessionInfo() R version 3.6.0 (2019-04-26) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS Mojave 10.14.4

Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/Current/Resources/lib/libRlapack.dylib

Random number generation: RNG: Mersenne-Twister Normal: Inversion Sample: Rounding

locale: [1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8

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

other attached packages: [1] DropletUtils_1.4.0 Matrix_1.2-17 dplyr_0.8.1
[4] Seurat_3.0.1 scran_1.12.0 EnsDb.Hsapiens.v86_2.99.0
[7] ensembldb_2.8.0 AnnotationFilter_1.8.0 GenomicFeatures_1.36.1
[10] AnnotationDbi_1.46.0 scater_1.12.2 ggplot2_3.1.1
[13] SingleCellExperiment_1.6.0 SummarizedExperiment_1.14.0 DelayedArray_0.10.0
[16] BiocParallel_1.18.0 matrixStats_0.54.0 Biobase_2.44.0
[19] GenomicRanges_1.36.0 GenomeInfoDb_1.20.0 IRanges_2.18.0
[22] S4Vectors_0.22.0 BiocGenerics_0.30.0

loaded via a namespace (and not attached): [1] plyr_1.8.4 igraph_1.2.4.1 lazyeval_0.2.2
[4] splines_3.6.0 listenv_0.7.0 digest_0.6.19
[7] htmltools_0.3.6 viridis_0.5.1 gdata_2.18.0
[10] magrittr_1.5 memoise_1.1.0 cluster_2.0.9
[13] ROCR_1.0-7 limma_3.40.2 globals_0.12.4
[16] Biostrings_2.52.0 R.utils_2.8.0 prettyunits_1.0.2
[19] colorspace_1.4-1 blob_1.1.1 ggrepel_0.8.1
[22] crayon_1.3.4 RCurl_1.95-4.12 jsonlite_1.6
[25] survival_2.44-1.1 zoo_1.8-5 ape_5.3
[28] glue_1.3.1 gtable_0.3.0 zlibbioc_1.30.0
[31] XVector_0.24.0 BiocSingular_1.0.0 Rhdf5lib_1.6.0
[34] future.apply_1.2.0 HDF5Array_1.12.1 scales_1.0.0
[37] DBI_1.0.0 edgeR_3.26.3 bibtex_0.4.2
[40] Rcpp_1.0.1 metap_1.1 viridisLite_0.3.0
[43] progress_1.2.2 reticulate_1.12 dqrng_0.2.1
[46] bit_1.1-14 rsvd_1.0.0 SDMTools_1.1-221.1
[49] tsne_0.1-3 htmlwidgets_1.3 httr_1.4.0
[52] gplots_3.0.1.1 RColorBrewer_1.1-2 ica_1.0-2
[55] pkgconfig_2.0.2 XML_3.98-1.19 R.methodsS3_1.7.1
[58] locfit_1.5-9.1 dynamicTreeCut_1.63-1 labeling_0.3
[61] reshape2_1.4.3 tidyselect_0.2.5 rlang_0.3.4
[64] munsell_0.5.0 tools_3.6.0 RSQLite_2.1.1
[67] ggridges_0.5.1 stringr_1.4.0 npsurv_0.4-0
[70] bit64_0.9-7 fitdistrplus_1.0-14 caTools_1.17.1.2
[73] purrr_0.3.2 RANN_2.6.1 pbapply_1.4-0
[76] future_1.13.0 nlme_3.1-140 R.oo_1.22.0
[79] biomaRt_2.40.0 compiler_3.6.0 beeswarm_0.2.3
[82] plotly_4.9.0 curl_3.3 png_0.1-7
[85] lsei_1.2-0 tibble_2.1.1 statmod_1.4.30
[88] stringi_1.4.3 lattice_0.20-38 ProtGenerics_1.16.0
[91] pillar_1.4.0 Rdpack_0.11-0 lmtest_0.9-37
[94] BiocNeighbors_1.2.0 data.table_1.12.2 cowplot_0.9.4
[97] bitops_1.0-6 irlba_2.3.3 gbRd_0.4-11
[100] rtracklayer_1.44.0 R6_2.4.0 KernSmooth_2.23-15
[103] gridExtra_2.3 vipor_0.4.5 codetools_0.2-16
[106] MASS_7.3-51.4 gtools_3.8.1 assertthat_0.2.1
[109] rhdf5_2.28.0 withr_2.1.2 sctransform_0.2.0
[112] GenomicAlignments_1.20.0 Rsamtools_2.0.0 GenomeInfoDbData_1.2.1
[115] hms_0.4.2 grid_3.6.0 tidyr_0.8.3
[118] DelayedMatrixStats_1.6.0 Rtsne_0.15 ggbeeswarm_0.6.0

LTLA commented 5 years ago

There weren't any major changes in computeSumFactors() between 3.8 and 3.9, so I don't know what the problem is. The errors make no sense to me - there certainly isn't a qr.qty call in computeSumFactors (or in scran at all), and there is no reason to get 5 FUN() warnings.

LTLA commented 5 years ago

Having thought about it - the qr.qty comes from nls(), which comes from cleanSizeFactors(), which is called because you have negative size factors somewhere. The 5 warnings come from the fact that the data is arbitrarily split up into 5 groups to avoid memory problems with qr.coef when there are too many cells - each of those groups has at least one negative size factor. You can avoid the current error by setting positive=FALSE, which will skip cleanSizeFactors(); but you will still get the warnings, and it doesn't really fix the problem downstream as you'll have negative size factors. You'll have to get rid of these in some other way.

s2hui commented 5 years ago

Thanks for your insight. I set positive=FALSE and the error is no longer there. I will look at addressing the neg. size factors in my data. Thanks.

LTLA commented 5 years ago

If you want to help with this problem, see if you can recover the error with this:

mult <- 6
realloc <- rep(seq_len(mult), length.out=ncol(sce))
sce2 <- computeSumFactors(sce[,realloc==5], positive=FALSE) # should warn
cleanSizeFactors(sizeFactors(sce2), nexprs(sce2, byrow=FALSE)) # should error

... and then send me the values of sizeFactors(sce2) and nexprs(sce, byrow=FALSE).

I'm also going to guess that you are working with UMI data, in which case you should really read the relevant instructions here. And if you're working with 10X data specifically, also read this.

LTLA commented 5 years ago

I'm going to assume this is no longer a problem.