我想比较23andme的一些基因组序列原始数据,并使用Python进行比较
我已按如下方式导入我的数据:
import pandas as pd
import os
sample_1 = pd.read_csv('sample_1.txt', delimiter ='\t', dtype={"rsid": str, "chromosome": str, "position": int, "genotype": str})
sample_2 = pd.read_csv('sample_2_new.txt', delimiter ='\t', dtype={"rsid": str, "chromosome": str, "position": int, "genotype": str})
现在,我只想确保Y染色体的安全,以便以后进行爆炸性比较。因此,我需要数据帧中一列的字符串条目作为一个连续字符串,如"AATTGCTT..."
y_1 = sample_1.loc[sample_5['chromosome'] == "Y"]
y_1_blast = y_1.to_string(columns = ["genotype"], header=False, index=False, index_names=False)
由于输出也包含'\n'
,我尝试通过以下方式删除分隔符:
y_1_blast.rstrip()
但这是行不通的。
我还得到了' ... '
包围的整个输出,这让我怀疑这是否是问题所在
是的! 如果输出实际上是一个连续字符串,则可以选择正则表达式替换startegy
甚至更安全(即除去所有ATGC信件以外的所有信件)
相关问题 更多 >
编程相关推荐