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

Better start value for x0 when estimating dropout parameters #142

Closed
duohongrui opened this issue Mar 27, 2022 · 3 comments
Closed

Better start value for x0 when estimating dropout parameters #142

duohongrui opened this issue Mar 27, 2022 · 3 comments
Labels

Comments

@duohongrui
Copy link

duohongrui commented Mar 27, 2022

Hi,
Splatter is an ideal tool to simulate different kinds of single-cell profiling data. Recently I met a commo problem for most of my reference datasets using the function splatEstimate when Splatter was estimating the dropout parameters. The error said:

Error in nls(y ~ logistic(x, x0 = x0, k = k), data = df, start = list(x0 = 0,  : singular gradient
In addition: Warning message:
In value[[3L]](cond) :
  Fitting dropout using the Gauss-Newton method failed, using the Golub-Pereyra algorithm instead

It seems like fitting the reference data to the logistic model failed. After that, I looked for the solutions on the Internet and found one. https://github.com/broadinstitute/infercnv/blob/master/R/SplatterScrape.R. It adds x_approx_mid <- median(x[which(y>0.2& y < 0.8)]) step before fit <- nls(y ~ .logistic(x, x0 = x0, k = k), data = df, start = list(x0 = x_approx_mid, k = -1)) and considers x_approx_mid as the x0 starting point.
I accepted this alteration and rerun the estimating step. Finally, it works for all of my datasets. However, I am not good at statistics and cannot find out why it works. Here is my R environment.

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

Matrix products: default

locale:
[1] LC_COLLATE=Chinese (Simplified)_China.936  LC_CTYPE=Chinese (Simplified)_China.936   
[3] LC_MONETARY=Chinese (Simplified)_China.936 LC_NUMERIC=C                              
[5] LC_TIME=Chinese (Simplified)_China.936    

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

other attached packages:
 [1] splatter_1.16.1             SingleCellExperiment_1.14.1 SummarizedExperiment_1.22.0 Biobase_2.52.0             
 [5] GenomicRanges_1.44.0        GenomeInfoDb_1.28.4         IRanges_2.26.0              S4Vectors_0.30.2           
 [9] BiocGenerics_0.38.0         MatrixGenerics_1.4.3        matrixStats_0.61.0          amap_0.8-18 

Could you check this problem and fix this bug in splat-estimate.R? Thanks very much!

@lazappi lazappi changed the title There is something wrong when estimating Splat dropout parameters Better start value for x0 when estimating dropout parameters Mar 28, 2022
@lazappi lazappi added the bug label Mar 28, 2022
@lazappi
Copy link
Collaborator

lazappi commented Mar 28, 2022

Hi @duohongrui

Thanks for the issue and the suggested solution! This seems like it is related to #133. After that issue I added another fallback method which might work in this case, you can try it using the development version of {splatter}.

This solution from {infercnv} is probably more robust though so I will look at adding it. I can definitely see how having a better starting estimate of x0 would improve the fitting.

@duohongrui
Copy link
Author

I see. Thanks again!

@lazappi
Copy link
Collaborator

lazappi commented Apr 23, 2022

I have added this to the development version and it will be in the upcoming release

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

No branches or pull requests

2 participants