【发布时间】:2016-04-18 03:10:34
【问题描述】:
这是我的问题。我有一个对象“列表”和一个数据框,如下所示:
0
0 hsa-let-7f-2-3p
1 hsa-let-7f-2-5p
2 hsa-miR-105-3p
3 hsa-miR-105-5p
6 hsa-miR-106a-3p
和
Gene_ID miRNA_family_ID
1452449 NM_001038707 hsa-let-7f-2-3p
14537388 NM_058241 hsa-let-7f-2-3p
14540512 NM_078467 hsa-let-7f-2-3p
15618969 NM_153051 hsa-let-7f-2-3p
5500627 NM_001184880 hsa-let-7f-2-3p
他们的 len.index 是不同的 对于“列表”
`>>> len(miRNAs.index)`
175
>>> len(Alvos_Mir.index)
18744
它们的两个 dtypes 都是对象。
我真正需要做的是使用列表的内容与miRNA_family_ID 列进行比较,以将所有具有它的Gene_ID 保存在.csv 文件中,因为它是miRNA。
我尝试做的是:
for i in range(len(miRNAs)):
GenesAlvo_miRNA = [Alvos_Mir['miRNA_family_ID'] == miRNAs[i]];
colunas_interesse_to_save = GenesAlvo_miRNA.ix[:, ['Gene_ID']];
#here i put the values.tolist() beacause I need the format of the output to be like (1,2,3,4,5) and not as a column
colunas_interesse_to_save = colunas_interesse_to_save.values.tolist()
#I need that the name of the output file is the content current being compare
colunas_interesse_to_save.to_csv(miRNAs[i], index=False)
我收到错误:
Traceback (most recent call last): File "<stdin>", line 2, in <module> File "/home/beatriz/anaconda/lib/python2.7/site-packages/pandas/core/ops.py", line 582, in wrapper raise ValueError('Series lengths must match to compare') ValueError: Series lengths must match to compare
有什么建议吗? 提前致谢
【问题讨论】:
-
我需要创建多个新文件,命名为每个 miRNA_id,包含每个 miRNA_ID 的多个基因 ID。也就是说,我需要根据每个 miRNA_id 将原始文件拆分为多个包含gene_id 列的行的文件。每个文件一个 miRNA_ID。这更清楚吗?非常感谢您的帮助
标签: python bioinformatics genetics