【发布时间】:2022-11-16 05:34:25
【问题描述】:
我正在寻找一个 R 解决方案(或一个通用逻辑解决方案)来将 Homo sapiens 基因名称转换为 Danio rerio 基因名称。我目前的编码技能相当原始,所以我尝试用 for 循环和 if 语句编写一些东西,但它只能提取一个直系同源基因,但是有多个。例如,对于人类基因 REG3G,存在三个斑马鱼同源基因:si:ch211-125e6.13、zgc:172053、凝集素。我已经添加了我编写的代码,但它只选择了最后一个,但我希望它输出所有三个。
我也一直难以找到 R/BiomaRt 代码来帮助完成这项任务,我希望得到任何建议。
# Read excel file containing list of zebrafish genes and their human orthologs.
ortho_genes <- read_excel("/Users/talha/Desktop/Ortho_Gene_List.xlsx")
# Separate data from excel file into lists.
zebrafish <- ortho_genes$`Zebra Gene Name`
human <- ortho_genes$`Human Gene Name`
# Read sample list of differential expressed genes
sample_list <- c("GREB1L","SIN3B","NCAPG2","FAM50A","PSMD12","BPTF","SLF2","SMC5", "SMC6", "TMEM260","SSBP1","TCF12", "ANLN", "TFAM", "DDX3X","REG3G")
# Make a matrix with same number of columns as genes in the supplied list.
final_m <- matrix(nrow=length(sample_list),ncol=2)
# Iterate through every gene in the supplied list
for(x in 1:length(sample_list)){
# Iterate through every human gene
for(y in 1:length(human)){
# If the gene from the supplied list matches a human gene
if(sample_list[x] == human[y]){
# Fill our matrix in with the supplied gene and the zebrafish ortholog
# that matches up with the cell of the human gene
final_m[x,1] = sample_list[x]
final_m[x,2] = zebrafish[y]
}
}
}
【问题讨论】:
-
请包括
zebrafish和human的前几行。 ortho_genes 列表之间是否存在 1:1 的关系?这可能适合join()或merge()而不是嵌套循环 -
如果您包含一个简单的 reproducible example 以及可用于测试和验证可能的解决方案的示例输入和所需的输出,则可以更轻松地为您提供帮助。在问题本身而不是外部文件中包含数据。
标签: r bioinformatics