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

rPLN(
  n = 10,
  mu = rep(0, ncol(Sigma)),
  Sigma = diag(1, 5, 5),
  depths = rep(10000, n)
)

Arguments

n

the sample size

mu

vectors of means of the latent variable

Sigma

covariance matrix of the latent variable

depths

Numeric vector of target depths. The first is recycled if there are not n values

Value

a n * p count matrix, with row-sums close to depths, with an attribute "offsets" corresponding to the true generated offsets (in log-scale).

Details

The default value for mu and Sigma assume equal abundances and no correlation between the different species.

Examples

## 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  125   79   48   99   148  12   21   15  13   7
#> S2 5242 4271 4260 6964 11308 360 1040 1050 546 423
#> 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