Last data update: 2014.03.03

R: divsubsamples
divsubsamplesR Documentation

divsubsamples

Description

Function to generate the rarefaction data from a given sample

Usage

divsubsamples(mainsamp, nrf, minrarefac=1,
maxrarefac=length(format.input(mainsamp)), NResamples=1000)

Arguments

mainsamp

the main sample, either as a 2-column data.frame (species ID, count of species), or a vector of species IDs.

nrf

difference between lengths of successive rarefaction datapoints.

minrarefac

minimum rarefaction data x-axis value. Default is 1.

maxrarefac

maximum rarefaction data x-axis value. Default is length of the sample mainsamp.

NResamples

number of resamples used to calculate the rarefaction data.

Details

This function produces a vector of subsamples diversity values with subsample lengths evenly distributed between a specified minimum and maximum number. The curvature of the rarefaction curve can be obtained with the function Curvature.

Value

a list of class divsubsamples containing resampling results (i.e. the diversity data). This includes the following:

RarefacXAxis

vector of x-axis rarefaction data

RarefacYAxis

vector of y-axis rarefaction data

div_sd

vector of y-axis rarefaction data standard deviations

NResamples

number of sampling iterations used to calculate sample means of each subsample diversity

Author(s)

Daniel Laydon, Aaron Sim, Charles Bangham, Becca Asquith

References

Laydon, D., Melamed, A., Sim, A., Gillet, N. A., Sim, K., Darko, S., Kroll, S., Douek, D. C., Price, D., Bangham, C. R. M., Asquith, B., Quantification of HTLV-1 clonality and TCR diversity, PLOS Comput. Biol. 2014

Examples

require(DivE)
data(Bact1)

dss_1 <- divsubsamples(Bact1, nrf=2, minrarefac=1, maxrarefac=100,
                        NResamples=10) 
dss_2 <- divsubsamples(Bact1, nrf=20, minrarefac=1, maxrarefac=100,
                        NResamples=10)
# Default NResamples=1000; low value of NResamples=10 is a set for quick evaluation

dss_1
dss_2

summary(dss_1)
dss_1$div_sd
dss_1$NResamples

Curvature(dss_1)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(DivE)
Loading required package: deSolve

Attaching package: 'deSolve'

The following object is masked from 'package:graphics':

    matplot

Loading required package: FME
Loading required package: rootSolve
Loading required package: coda
Loading required package: rgeos
rgeos version: 0.3-19, (SVN revision 524)
 GEOS runtime version: 3.5.0-CAPI-1.9.0 r4084 
 Linking to sp version: 1.2-3 
 Polygon checking: TRUE 

Loading required package: sp
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/DivE/divsubsamples.Rd_%03d_medium.png", width=480, height=480)
> ### Name: divsubsamples
> ### Title: divsubsamples
> ### Aliases: divsubsamples divsubsamples.default print.divsubsamples
> ###   summary.divsubsamples print.summary.divsubsamples
> ### Keywords: diversity
> 
> ### ** Examples
> 
> require(DivE)
> data(Bact1)
> 
> dss_1 <- divsubsamples(Bact1, nrf=2, minrarefac=1, maxrarefac=100,
+                         NResamples=10) 
> dss_2 <- divsubsamples(Bact1, nrf=20, minrarefac=1, maxrarefac=100,
+                         NResamples=10)
> # Default NResamples=1000; low value of NResamples=10 is a set for quick evaluation
> 
> dss_1
RarefacXAxis:
 [1]   1   3   5   7   9  11  13  15  17  19  21  23  25  27  29  31  33  35  37
[20]  39  41  43  45  47  49  51  53  55  57  59  61  63  65  67  69  71  73  75
[39]  77  79  81  83  85  87  89  91  93  95  97  99 100

RarefacYAxis (Mean diversity values):
 [1]  1.0  3.0  4.9  6.7  8.4 10.0 11.4 13.1 14.5 16.2 18.0 19.2 20.5 21.6 22.8
[16] 24.1 25.4 26.6 27.8 28.9 30.0 30.9 32.2 33.2 33.8 34.9 35.8 36.9 37.5 38.2
[31] 39.0 39.6 40.4 41.3 41.7 42.2 42.8 43.8 44.6 45.3 46.0 46.5 46.9 47.5 47.9
[46] 48.6 49.2 49.9 50.7 51.0 51.2
> dss_2
RarefacXAxis:
[1]   1  21  41  61  81 100

RarefacYAxis (Mean diversity values):
[1]  1.0 18.1 30.6 40.0 47.5 53.6
> 
> summary(dss_1)
Call:
divsubsamples.default(mainsamp = Bact1, nrf = 2, minrarefac = 1, 
    maxrarefac = 100, NResamples = 10)

Subsample data summary:
     Subsample.size Subsample.diversity No.of.rarefac.points Iterations
[1,]            100                51.2                   51         10
     Ave.StdErr
[1,] 0.08009353
> dss_1$div_sd
 [1] 0.0000000 0.0000000 0.3162278 0.4830459 0.5163978 0.6666667 0.8432740
 [8] 1.1005049 1.3540064 1.3984118 1.4142136 1.7511901 1.7795130 1.7763883
[15] 2.2997584 2.2335821 2.5473298 2.6749870 3.0477679 3.0349812 2.6666667
[22] 2.3781412 2.3475756 2.6161889 2.5733679 2.8848262 3.1552426 3.2128215
[29] 3.1001792 3.4253954 3.2317866 3.1340425 3.4383459 3.6530049 4.0290611
[36] 4.0221608 3.7947332 3.5839147 4.0055517 4.0013886 4.0000000 4.3525216
[43] 3.9846929 3.8658045 3.5418137 3.5652645 3.4576807 3.2128215 3.3349996
[50] 3.5276684 3.6147845
> dss_1$NResamples
[1] 10
> 
> Curvature(dss_1)
[1] 0.2282813
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>