作者:萍萍jean | 来源:互联网 | 2023-05-17 06:45
I have a text file that looks like this:
我有一个看起来像这样的文本文件:
gene1 gene2 gene3
a d c
b e d
c f g
d g
h
i
(Each column is a human gene, and each contains a variable number of proteins (strings, shown as letters here) that can bind to those genes).
(每列都是一个人类基因,每个都包含可变数量的蛋白质(字符串,这里显示为字母),可以与这些基因结合)。
What I want to do is count how many columns each string is represented in, output that number and all the column headers, like this:
我想要做的是计算每个字符串表示的列数,输出该数字和所有列标题,如下所示:
a 1 gene1
b 1 gene1
c 2 gene1 gene3
d 3 gene1 gene2 gene3
e 1 gene2
f 1 gene2
g 2 gene2 gene3
h 1 gene2
i 1 gene2
I have been trying to figure out how to do this in Perl and R, but without success so far. Thanks for any help.
我一直试图弄清楚如何在Perl和R中做到这一点,但到目前为止还没有成功。谢谢你的帮助。
5 个解决方案