This function estimate the dimension of low dimensional embedding for a given cell by gene expression matrix. For more details, see Franklin et al. (1995) and Crawford et al. (2010).

diagnostic.cor.eigs(object, ...)

# S3 method for default
diagnostic.cor.eigs(
  object,
  q_max = 50,
  plot = TRUE,
  n.sims = 10,
  parallel = TRUE,
  ncores = 10,
  seed = 1,
  ...
)

# S3 method for Seurat
diagnostic.cor.eigs(
  object,
  assay = NULL,
  slot = "data",
  nfeatures = 2000,
  q_max = 50,
  seed = 1,
  ...
)

Arguments

object

A Seurat or matrix object

...

Other arguments passed to diagnostic.cor.eigs.default.

q_max

the upper bound of low dimensional embedding. Default is 50.

plot

a indicator of whether plot eigen values.

n.sims

number of simulaton times. Default is 10.

parallel

a indicator of whether use parallel analysis.

ncores

the number of cores used in parallel analysis. Default is 10.

seed

a postive integer, specify the random seed for reproducibility

assay

an optional string, specify the name of assay in the Seurat object to be used.

slot

an optional string, specify the name of slot.

nfeatures

an optional integer, specify the number of features to select as top variable features. Default is 2000.

Value

A data.frame with attribute `q_est` and `plot`, which is the estimated dimension of low dimensional embedding. In addition, this data.frame containing the following components:

  • q - The index of eigen values.

  • eig_value - The eigen values on observed data.

  • eig_sim - The mean value of eigen values of n.sims simulated data.

  • q_est - The selected dimension in attr(obj, 'q_est').

  • plot - The plot saved in attr(obj, 'plot').

References

1. Franklin, S. B., Gibson, D. J., Robertson, P. A., Pohlmann, J. T., & Fralish, J. S. (1995). Parallel analysis: a method for determining significant principal components. Journal of Vegetation Science, 6(1), 99-106.

2. Crawford, A. V., Green, S. B., Levy, R., Lo, W. J., Scott, L., Svetina, D., & Thompson, M. S. (2010). Evaluation of parallel analysis methods for determining the number of factors.Educational and Psychological Measurement, 70(6), 885-901.

Examples

n <- 100
p <- 50
d <- 15
object <- matrix(rnorm(n*d), n, d) %*% matrix(rnorm(d*p), d, p)
diagnostic.cor.eigs(object, n.sims=2)
#> Warning: q_max is not less than the number of columns of X. Set it as ncol(X) - 1
#> Warning: You're computing too large a percentage of total singular values, use a standard svd instead.
#> Warning: You're computing too large a percentage of total singular values, use a standard svd instead.
#> Warning: did not converge--results might be invalid!; try increasing work or maxit
#> Warning: You're computing too large a percentage of total singular values, use a standard svd instead.
#> Warning: did not converge--results might be invalid!; try increasing work or maxit

#>     q    eig_value   eig_sim
#> 1   1 6.787478e+00 2.7296224
#> 2   2 6.746649e+00 2.5998668
#> 3   3 5.482065e+00 2.4281943
#> 4   4 5.079823e+00 2.3160924
#> 5   5 4.222738e+00 2.2546295
#> 6   6 3.924795e+00 2.1499993
#> 7   7 3.222806e+00 2.0107977
#> 8   8 2.807144e+00 1.8784125
#> 9   9 2.602241e+00 1.8070276
#> 10 10 2.257877e+00 1.7429637
#> 11 11 1.719065e+00 1.6508146
#> 12 12 1.615663e+00 1.5513549
#> 13 13 1.391435e+00 1.4839385
#> 14 14 9.345711e-01 1.4132661
#> 15 15 7.056510e-01 1.3504219
#> 16 16 1.128058e-31 1.3008385
#> 17 17 3.644070e-32 1.2770930
#> 18 18 3.644070e-32 1.2028010
#> 19 19 3.644070e-32 1.1495144
#> 20 20 3.644070e-32 1.0373263
#> 21 21 3.644070e-32 1.0007974
#> 22 22 3.644070e-32 0.9480358
#> 23 23 3.644070e-32 0.9042866
#> 24 24 3.644070e-32 0.8777858
#> 25 25 3.644070e-32 0.8126820
#> 26 26 3.644070e-32 0.7971829
#> 27 27 3.644070e-32 0.7473634
#> 28 28 3.644070e-32 0.7215422
#> 29 29 3.644070e-32 0.6603520
#> 30 30 3.644070e-32 0.6266713
#> 31 31 3.644070e-32 0.6127033
#> 32 32 3.644070e-32 0.5712889
#> 33 33 3.644070e-32 0.5361208
#> 34 34 3.644070e-32 0.5017992
#> 35 35 3.644070e-32 0.4719108
#> 36 36 3.644070e-32 0.4645224
#> 37 37 3.644070e-32 0.4337665
#> 38 38 3.644070e-32 0.4024438
#> 39 39 3.644070e-32 0.3778852
#> 40 40 3.644070e-32 0.3498087
#> 41 41 3.644070e-32 0.3256078
#> 42 42 3.644070e-32 0.2940739
#> 43 43 3.644070e-32 0.2729165
#> 44 44 3.644070e-32 0.2395894
#> 45 45 3.644070e-32 0.2213664
#> 46 46 3.644070e-32 0.2017337
#> 47 47 3.644070e-32 0.1878001
#> 48 48 3.644070e-32 0.1639835
#> 49 49 3.644070e-32 0.1154468