Learn R Programming

SRS (version 0.1.1)

Scaling with ranked subsampling curve (SRScurve): Scaling with ranked subsampling curve (SRScurve)

Description

For each column of the input data, draws a line plot of alpha diversity indices (see metric) at different sample sizes (specified by step) normalized by scaling with ranked subsampling (using SRS). Minimum sample size (cutoff-level) can be evaluated by specifying sample. The function further allows to visualize trade-offs between cutoff-level and alpha diversity and enables direct comparison of SRS and repeated rarefying.

See Beule & Karlovsky (2020) <doi:10.7717/peerj.9593> for details regarding SRS.

Usage

SRScurve(x, metric = "richness", step = 50, sample = 0, 
        rarefy.comparison = FALSE, rarefy.repeats = 100, 
        rarefy.comparison.legend = FALSE, xlab = "Sample Size", 
        ylab = "Metric", label = FALSE, col, lty, ...)

Arguments

x

Data frame (species count or OTU table) in which columns are samples and rows are the counts of species or OTUs. Only integers are accepted as data.

metric

Character, "richness" (using specnumber) for species richness or shannon, simpson or invsimpson (using diversity) for common diversity indices. Default is "richness".

step

Numeric, specifying the step used to vary the sample size. Default is 50.

sample

Numeric, specifying the cutoff-level to visualize trade-offs between cutoff-level and alpha diversity.

rarefy.comparison

Logical, if TRUE, mean values of rarefy with n repeats (specified by rarefy.repeats) will be drawn for comparison. Default is FALSE.

rarefy.repeats

Numberic, specifying the number of repeats used to obtain mean values for rarefying. Default is 100.

rarefy.comparison.legend

Logical, if TRUE, a legend for the comparison between SRS and rarefy is plotted. Default is FALSE.

xlab, ylab, label, col, lty, ...

Graphical parameters.

Value

Returns a line plot visualizing the change in alpha diversity indices with changing sample size.

Details

See Beule & Karlovsky (2020) <doi:10.7717/peerj.9593> for details regarding scaling with ranked subsampling.

References

Beule L, Karlovsky P. 2020. Improved normalization of species count data in ecology by scaling with ranked subsampling (SRS): application to microbial communities. PeerJ 8:e9593

<https://doi.org/10.7717/peerj.9593>

Examples

Run this code
# NOT RUN {
##Samples should be arranged columnwise.
##Input data should not contain any categorial
##data such as taxonomic assignment or barcode sequences.
##An example of the input data can be found below:

example_input_data <- as.data.frame(matrix(c(sample(1:80, 100, replace = TRUE),
                                             sample(1:90, 100, replace = TRUE),
                                             sample(1:100, 100, replace = TRUE)), 
                                             nrow = 100))
colnames(example_input_data) <- c("sample_1","sample_2","sample_3")

##Default settings of SRScurve.
SRScurve(example_input_data, metric = "richness", step = 50,
         ylab = "Species richness", 
         col = c("#000000", "#E69F00", "#56B4E9"))

##SRScurve with comparison of SRS (solid lines) and repeated rarefying (dashed lines).
##Different colors correspond to indiviual samples. Cuttoff-level set to 500.
SRScurve(example_input_data, metric = "richness", step = 50,
         sample = 500, 
         rarefy.comparison = TRUE, rarefy.repeats = 10, rarefy.comparison.legend = TRUE,
         ylab = "Species richness", 
         col = c(rep("#000000",2), rep("#E69F00",2), rep("#56B4E9",2)),
         lty = c(1,2))
# }

Run the code above in your browser using DataLab