通过样本表创建一些物种/个体?

时间:2015-06-04 18:34:17

标签: r vegan

我在R中有一个巨大的丰度矩阵作为data.frame(下面的示例),我希望从中输出一个包含物种数量的简单表(Otu00001,以及具有多于1个属性序列的Otus)和数字每个样本(每行,ALG(...))的归因序列(个体,该样本的每个Otu中的数字)。

之后,对下表(SCIE_NAME)中的样本(rownames)进行平均。

Abundance matrix

这是包含样本对应类别的表格。

                  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

根据我的研究,vegan没有直接命令,你可以帮助我吗?

我的想法是得到一张桌子,我得到这样的东西:

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

感谢您的帮助!

安德烈

1 个答案:

答案 0 :(得分:0)

与此同时,我设法得到了我想要的东西,加上一些colSums行:

(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")