# ab.assign: Randomly draw individuals into species according to specified... In NST: Normalized Stochasticity Ratio

 ab.assign R Documentation

## Randomly draw individuals into species according to specified probabilities

### Description

This funciton is to assign abundances to species when randomizing communities based on null models considering abundances. Individuals are randomly drawn into species according to the specified probabilities.

### Usage

```ab.assign(comm.b, samp.ab=NULL, prob.ab)
```

### Arguments

 `comm.b` numeric matrix, binary (present/absent) community data, rownames are sample/site names, colnames are species names. `samp.ab` numeric vector, total abundances (total individual numbers) in each sample. If samp.ab=NULL, Dirichlet distribution will be used to generate randomized community matrix with relative abundance (proportion) of each taxon in each sample. `prob.ab` numeric matrix, probability of each species into which the individuals in a certain sample are drawn.

### Details

This function is called by the function `taxo.null` to generate randomized communities.

### Value

A matrix of community data with abundances (or relative abundance) is returned. rownames are sample/site names, and colnames are species names.

### Note

Version 3: 2021.7.27, debug, if samp.ab is lower than samp.rich, no need to assign abundance. Version 2: 2021.4.16, add new algorithm based on Dirichlet distribution. Version 1: 2015.10.22.

Daliang Ning

### References

Stegen JC, Lin X, Fredrickson JK, Chen X, Kennedy DW, Murray CJ, Rockhold ML, and Konopka A. Quantifying community assembly processes and identifying features that impose them. Isme Journal 7, 2069-2079 (2013).

`taxo.null`

### Examples

```data(tda)
comm=tda\$comm
comm.b=comm
comm.b[comm.b>0]=1
samp.ab=rowSums(comm)
prob.ab=matrix(colSums(comm),nrow=nrow(comm),ncol=ncol(comm),byrow=TRUE)
comm.rand=ab.assign(comm.b,samp.ab,prob.ab)
```

NST documentation built on June 7, 2022, 1:07 a.m.