-1

I have a huge abundance matrix as a data.frame (example below) in R from which I want to output a simple table with the number of species present (Otu00001, and whichever Otus with more than 1 attributed sequence) and number of attributed sequences (individuals, numbers in each Otu for that sample) for each sample (each row, ALG(...)).

After that, averaging samples (rownames) regarding in the table below (SCIE_NAME).

Abundance matrix

Here's the table with the categories which the samples correspond.

                  SCIE_NAME
ALG12.100.1019556  Cliona viridis
ALG12.101.1020199  Cliona viridis
ALG12.102.1019695  Cliona viridis
ALG12.103.1020514  Cliona celata complex
ALG12.104.1020008  Phorbas fictitius
ALG12.105.1019558  Phorbas fictitius
ALG12.106.1020012  Phorbas fictitius
ALG12.107.1019998  Dysidea fragilis
ALG12.108.1020068  Dysidea fragilis
ALG12.109.1019636  Dysidea fragilis
ALG12.110.1020285  Cliona celata complex
ALG12.111.1019802  Cliona celata complex
ALG12.112.1019618  Cliona celata complex
ALG12.113.1019525  Cliona celata complex
ALG12.114.1019900  Cliona celata complex
ALG12.115.1020456  Cliona celata complex
ALG12.90.1019650   Phorbas fictitius
ALG12.91.1020146   Phorbas fictitius
ALG12.92.1020337   Phorbas fictitius
ALG12.93.1019916   Phorbas fictitius
ALG12.94.1020032   Phorbas fictitius
ALG12.95.1019784   Phorbas fictitius
ALG12.96.1019911   Phorbas fictitius
ALG12.97.1020523   Phorbas fictitius
ALG12.98.1019513   Phorbas fictitius
ALG12.99.1020247   Cliona viridis

From what I have researched, there is no direct command in vegan for such, can you help me?

My idea is to get a table in which I get something like this:

                     OTU Number     Sequence number
 Cliona viridis      xxx            yyy
 Phorbas fictitius   zzz            aaa

Thanks for all the help!

André

André Soares
  • 309
  • 1
  • 13
  • 5
    It is very unclear what you are asking. First, it's not helpful to share data as an image. See [how to create a reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). Also, clearly describe the desired output for the sample input. What do the values in the columns represent in your data? – MrFlick Jun 04 '15 at 18:37
  • I think you can try `table` i.e. `table(data.frame(rn=rownames(yourdata), NAME=yourdata$SCIE_NAME))` – akrun Jun 04 '15 at 18:44

1 Answers1

0

Meanwhile I managed to get what I wanted, plus a little colSums row:

(df<-merge dataset according to metadata...)

OTUs <- as.matrix(specnumber(df))
Seqs<-transform(df, sum=rowSums(df))
OTU_Seq_Table<-cbind(OTUs, Seqs$sum)
colnames(OTU_Seq_Table) <- c("OTUs", "Sequences")

sums_OTUSeqTable<-colSums(OTU_Seq_Table)
OTU_Seq_Table<-rbind(OTU_Seq_Table, sums_OTUSeqTable)
row.names(OTU_Seq_Table)[5]<-"Sums"

write.csv(OTU_Seq_Table, "OTU_Seq_Table_ALG.csv")
Gavin Simpson
  • 170,508
  • 25
  • 396
  • 453
André Soares
  • 309
  • 1
  • 13