hildebra / Rarefaction

Rarefaction scripts
GNU General Public License v2.0
17 stars 13 forks source link

C++ binary works with input TSV but R library does not generate desired output #21

Closed aboffin closed 5 years ago

aboffin commented 6 years ago

Hi,

I am able to run rtk with 16S rRNA OTU abundance as follows:

/Users/sen/git_repos/rtk/rtk rarefaction \
 -i ~/exp/ynp/results/plt_CRAnoxy/Anoxy.s3 \
 -o ~/exp/ynp/results/plt_CRAnoxy/rtk_CR.tbl.1000 \
 -r 1000 -w 1 -t 8;

The above works as intended and I get the output tables for alpha diversity measurements.

I want to plot the alpha diversity measures in R. So instead, I thought of using the rtk library provided for R and I used the same CSV input file.

library(rtk)
d <- rtk(input='../results/plt_CRAnoxy/Anoxy.s3', ReturnMatrix=1)

And d shows:

> d
$divvs
list()

$raremat
$raremat[[1]]
<0 x 0 matrix>

$ICE
$ICE[[1]]
numeric(0)

$ACE
$ACE[[1]]
numeric(0)

$chao2
$chao2[[1]]
numeric(0)

$skipped
character(0)

$div.median
$div.median$median.richness
NULL

$div.median$median.shannon
NULL

$div.median$median.simpson
NULL

$div.median$median.invsimpson
NULL

$div.median$median.chao1
NULL

$div.median$median.eveness
NULL

$depths
[1] 0

$repeats
[1] 10

attr(,"class")

The data in the CSV file looks like this:

           628D 629B 629F 629H 630B 630C 721C 723ABG 723AZ 724A 724B 725AB 725AO
Otu00001   51 2574 2955 7176 1573   22   11      1     0   23  971  1496 18047
Otu00002    1 3626 4971 3175 2044   19 2231      0     0   13    2   472  1119
Otu00003    1   10    3    3 4242   69 7968      0     0   56    1  3140   256
Otu00004  110 3217  307  613 2965   81 8978      2     0  119   61  4212  1050
Otu00005    1    4    3    1 2732   20 6631      1     0   81    0  3459   218
Otu00006    0 1178   13    7   67    2  139      2     0  151    0  3769 12176

Any pointers on how to import the tabular data generated by the C++ binary in R as rtk object for plotting the results are appreciated.

Thank you in advance, Sen

openpaul commented 5 years ago

Thank you, I could reproduce the issue and found that this is cause by a wrong default depth. The documentation said default depth will be 1000 but apparently this was set to 0. So if you run it with a depth set it will work:

d <- rtk(input='../results/plt_CRAnoxy/Anoxy.s3', ReturnMatrix=1, depth = 1000)

I'll fix this small bug in the future.

I hope this solves the issue, if not please let me know.

openpaul commented 5 years ago

Fixed in https://github.com/hildebra/Rarefaction/commit/beb590dcd85cc35bfbee5d10b46dc1c727f57620