Random generation for the PLN model with latent mean equal to mu, latent covariance matrix equal to Sigma and average depths (sum of counts in a sample) equal to depths
the sample size
vectors of means of the latent variable
covariance matrix of the latent variable
Numeric vector of target depths. The first is recycled if there are not n
values
a n * p count matrix, with row-sums close to depths, with an attribute "offsets" corresponding to the true generated offsets (in log-scale).
The default value for mu and Sigma assume equal abundances and no correlation between the different species.
## 10 samples of 5 species with equal abundances, no covariance and target depths of 10,000
rPLN()
#> Y1 Y2 Y3 Y4 Y5
#> S1 513 947 2286 5596 9514
#> S2 350 3007 2854 5971 76
#> S3 676 4368 247 1177 445
#> S4 2848 3051 165 1584 2017
#> S5 418 1126 2149 1834 3402
#> S6 159 5210 1035 1525 339
#> S7 3369 2674 2436 1191 421
#> S8 290 659 807 595 11794
#> S9 1249 2402 319 477 2186
#> S10 9480 4030 2043 1148 1935
#> attr(,"offsets")
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 7.100902 7.100902 7.100902 7.100902 7.100902
#> [2,] 7.100902 7.100902 7.100902 7.100902 7.100902
#> [3,] 7.100902 7.100902 7.100902 7.100902 7.100902
#> [4,] 7.100902 7.100902 7.100902 7.100902 7.100902
#> [5,] 7.100902 7.100902 7.100902 7.100902 7.100902
#> [6,] 7.100902 7.100902 7.100902 7.100902 7.100902
#> [7,] 7.100902 7.100902 7.100902 7.100902 7.100902
#> [8,] 7.100902 7.100902 7.100902 7.100902 7.100902
#> [9,] 7.100902 7.100902 7.100902 7.100902 7.100902
#> [10,] 7.100902 7.100902 7.100902 7.100902 7.100902
## 2 samples of 10 highly correlated species with target depths 1,000 and 100,000
## very different abundances
mu <- rep(c(1, -1), each = 5)
Sigma <- matrix(0.8, 10, 10); diag(Sigma) <- 1
rPLN(n=2, mu = mu, Sigma = Sigma, depths = c(1e3, 1e5))
#> Y1 Y2 Y3 Y4 Y5 Y6 Y7 Y8 Y9 Y10
#> S1 51 72 50 135 60 8 15 16 1 10
#> S2 5018 1832 3759 1615 2299 306 551 563 400 409
#> attr(,"offsets")
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
#> [1,] 3.671389 3.671389 3.671389 3.671389 3.671389 3.671389 3.671389 3.671389
#> [2,] 8.276560 8.276560 8.276560 8.276560 8.276560 8.276560 8.276560 8.276560
#> [,9] [,10]
#> [1,] 3.671389 3.671389
#> [2,] 8.276560 8.276560