Skip to content

RTK Tutorial

Paul edited this page Apr 24, 2017 · 8 revisions

Using RTK is straight forward. We recommend using the swap mode if memory is limited and the hard disks are fairly fast.

How to run

First install RTK as described or download the .exe. RTK is called via the command line and parameters are passed as arguments:

rtk mode [parameters]

Or loaded as an R package in R

install.packages('rtk') # install from cran
require('rtk') # load package

Processing OTU tables

We will be using the Lotus example data set from http://psbweb05.psb.ugent.be/lotus/tutorial_R.html as an example OTU input (dataset: http://psbweb05.psb.ugent.be/lotus/data/LotuStutorial.tar.gz).

Using RTK from the command line

To rarefy the OTU table, first the total column sums of all samples can be counted as such:

./rtk colsums -i OTU_mat.txt -o out_

# shows that bl33 is smalles column with 2329 counts
# rarefy to a single depth of 90%
depth=$((90*2329/100))

./rtk swap -i OTU_mat.txt -o out_ -d $depth

This will produce several files as described in the README with richness and other estimators for the rarefied dataset. Multiple depth for rarefaction curves can be passed like this:

./rtk swap -i OTU_mat.txt -o out_ -d 100,200,500,1000,1500,2000

These files can the again be loaded into R and plotted using basic packages and functions.

Using the R package

If plots should be produced it may be easier to directly work in R.

# load or install the package
if (!require("rtk")) install.packages("rtk"); 
library(rtk)

otu      <- 'OTU_mat.txt'
depth    <- 2000
# rarefy table directly to a known depth
rarefied <- rtk(otu, depth = depth)

This can the be plotted in groups, definable via a simple vector:

Clone this wiki locally