Applies the centred log-ratio (clr) transformation to the count matrix and
performs PCA on the transformed data, then returns the smallest number of
components whose eigenvalues explain at least prop of the total
variance. This is the data-driven rule for setting K described in the
paper.
Value
An integer, the suggested K. The full eigenvalue vector is
attached as attribute "eigenvalues".
Examples
sim <- simulate_bcaia(seed = 1)
choose_K(sim$Y)
#> [1] 6
#> attr(,"eigenvalues")
#> [1] 2.874167e+01 5.916151e+00 3.625730e+00 2.408626e+00 2.110645e+00
#> [6] 6.095488e-01 5.103859e-01 4.583081e-01 3.389422e-01 2.673896e-01
#> [11] 1.845620e-01 1.007298e-01 9.736230e-02 6.822095e-02 5.060356e-16