0

I'm having some problems with trying to run cor.test, based on two OTU tables (essentially an abundance matrix).

I have a table with 8 different sampling spots (columns 1 to 44) and for each sampling spot I measured a variable (VARIABLE1, first row) and the presence of a series of species (OTUs on the rows). Here you can see an example of what these OTU tables look like below:

Samples 1 - 8 are the columns

#OTUID  1   2   3   4   5   6   7   8
OTU1    0   0   0   0   0   3   0   0
OTU2    0   0   0   0   0   0   13  0
OTU3    5   99  0   0   0   0   0   0
OTU4    0   0   0   0   0   0   0   0
OTU5    0   0   0   0   0   0   0   2
OTU6    0   0   19  0   9   236 59  2
OTU7    0   55  0   2   4   2   3   0
OTU8    0   44  10  5   0   0   7   0
OTU9    6   0   13  2   0   0   17  6
OTU10   0   100 0   0   0   3   0   0
OTU11   4   13  0   0   2   1   2   0
OTU12   0   0   0   0   0   101 1   0

I have two of these tables in .biom format. I want to calculate spearman's correlation coefficients (R) between paired samples (e.g sample1(OTU table 1) vs sample1(OTU table 2); sample2(OTU table 1) vs sample2(OTU table 2), etc....etc) for EACH OTU. I have approximately 100 samples and abundance data for 4000 OTUs. Hence, I want to calculate the correlation coefficient for 44 pairs of data for each of the 4000 OTUs. So basically just correlating an ~4k long vector once per sample.

Finally I will take the average of the correlations for the 4k long vector for each sample and plot these averages on a scatterplot.

Keep in mind all my abundance data is in this .biom format! I've converted it all to .txt to make it easier to manipulate.

Thanks again!!

An example of how this would look as below:

enter image description here

Here is some sample data:

OTU table 1: https://1drv.ms/u/s!Ah_Q0DzXKdX-gZUl8SCetQdYE8S3CA

OTU table 2: https://1drv.ms/u/s!Ah_Q0DzXKdX-gZUnaIwEIJiYMnrQIA

user3105519
  • 309
  • 4
  • 10
  • So is there a problem or an error that you are getting or you want the code to create it? – Dinesh.hmn Aug 15 '16 at 18:30
  • I am looking for a code to create it. Thanks – user3105519 Aug 15 '16 at 19:17
  • How exactly are you defining the correlation between these two matrices? How many correlation values are you looking to create? It's not clear to me what you think the desired output is. – MrFlick Aug 15 '16 at 19:20
  • 1
    I think they are doing row-by-row spearman across the two tables (of equal rows), so their desired output is a spearman coefficient for each OTU row – mitoRibo Aug 15 '16 at 19:29
  • I am attempting to do something similar to the paper here: http://www.nature.com/nbt/journal/v31/n9/full/nbt.2676.html. Rbierman is spot on. That is exactly what I want to do. Then I would visualize the correlation between paired rows with one OTU table on the X axis and the other on the Y axis. – user3105519 Aug 15 '16 at 19:29
  • Provide 2 matrices for testing. [How to make a great R reproducible example](http://stackoverflow.com/questions/5963269) – zx8754 Aug 16 '16 at 10:52
  • @zx8754 I added the matrices for testing and clarified what I was trying to do. – user3105519 Aug 17 '16 at 02:28
  • I solved the problem. – user3105519 Aug 17 '16 at 21:34

0 Answers0