Skip to contents

Calculate OTU relative abundances from a shared file

Usage

calc_relabun(abs_abun_dat)

Arguments

abs_abun_dat

a data frame from reading in a shared file. Should contain a Group column for sample names, Otu columns for absolute counts of each OTU, and rows as each sample.

Value

a new data frame with OTU relative abundances in long format.

Author

Kelly Sovacool sovacool@umich.edu

Examples

shared_dat <- readr::read_tsv(system.file("extdata", "test.shared",
  package = "schtools"
))
#> Rows: 10 Columns: 15
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: "\t"
#> chr  (1): Group
#> dbl (14): label, numOtus, Otu0001, Otu0003, Otu0004, Otu00008, Otu0044, Otu0...
#> 
#>  Use `spec()` to retrieve the full column specification for this data.
#>  Specify the column types or set `show_col_types = FALSE` to quiet this message.
shared_dat %>% calc_relabun()
#> # A tibble: 120 × 3
#>    sample otu      rel_abun
#>    <chr>  <chr>       <dbl>
#>  1 p1     Otu0001      0   
#>  2 p1     Otu0003      0   
#>  3 p1     Otu0004      0   
#>  4 p1     Otu00008     0   
#>  5 p1     Otu0044      0.25
#>  6 p1     Otu0056      0.25
#>  7 p1     Otu0057      0   
#>  8 p1     Otu0058      0.25
#>  9 p1     Otu0159      0   
#> 10 p1     Otu0208      0.25
#> # ℹ 110 more rows