【发布时间】:2020-05-17 09:38:18
【问题描述】:
我目前有一个数据框,它说明基因组中的特定基因簇,它被定义为格式良好的制表符分隔文件,它基本上看起来像下面的数据框(示例):
Gene Cluster Genome
-----------------------------
GCF3372 Streptomyces_hygroscopicus
GCF3450 Streptomyces_sp_Hm1069
GCF3371 Streptomyces_sp_MBT13
GCF3371 Streptomyces_xiamenensis
基于此,我想根据该数据框创建一个缺失/存在表或列联表,其值为 0 和 1,具体取决于基因组中特定基因簇的缺失或存在。整个想法是让我能够测量基因组中特定基因簇的出现,因此我需要一个存在/不存在表,以便能够对该矩阵进行统计分析。
x <- data.frame(gc = c('GCF3372','GCF3450','GCF3371','GCF3371','GCF3371'),
strain = c('Streptomyces_hygroscopicus', 'Streptomyces_sp_Hm1069',
'Streptomyces_sp_MBT13', 'Streptomyces_xiamenensis','Streptomyces_hygroscopicus'))
dput(head(x[, c(1,2)]))
【问题讨论】:
-
你试过
table(Gene Cluster, Genome)吗?没有可重复的数据,很难更具体。使用 dput() 给我们几行数据或组成一些具有相同结构的数据。 -
@dcarlson 很抱歉给您带来不便,我已对其进行了编辑以使其变得更好。
标签: r dataframe datatables contingency