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 898 697 2706 1924 1658
#> S2 868 6373 2061 700 4015
#> S3 912 2881 3406 4747 3084
#> S4 542 1714 2802 319 562
#> S5 1005 776 1832 2267 819
#> S6 1008 3069 623 3300 1981
#> S7 2507 3898 2123 875 1494
#> S8 1358 1142 738 1131 328
#> S9 4463 2685 1033 218 3920
#> S10 399 3956 576 443 1561
#> 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 169 129 190 259 203 14 17 29 21 9
#> S2 19184 16106 21985 48841 51481 1911 2253 1955 2895 2644
#> 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