I have a very large OTU (abundance) table. There are over 100 samples and 4000 observations per sample (4000 taxa).
An example of the OTU table is here:
#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 would like to get this table in a long format so I can perform some pair wise tests between samples on another table. I am only interested in the count data, although if I could have the samples they belong two and the respective OTU I'll take it but it is not necessary. The data should look like this:
COUNT OTUID SAMPLEID
0 OTU1 1
0 OTU2 1
5 OTU3 1
0 OTU4 1
0 OTU5 1
0 OTU6 1
0 OTU7 1
0 OTU8 1
6 OTU9 1
0 OTU10 1
4 OTU11 1
0 OTU12 1
0 OTU1 2
0 OTU2 2
99 OTU3 2
0 OTU4 2
My script seems to work although I do get the NO id variable error message it still runs. If anyone has any idea how to fix that I would greatly appreciate it.
library(reshape2)
test = read.csv("test_otu.csv", sep=",", row.names=1)
test2 <- melt(test)
No ID variables; using all as measure variables
test2
Please help!