【问题标题】:ID Conversion from Human Gene Symbols to Zebrafish Gene Symbols从人类基因符号到斑马鱼基因符号的 ID 转换
【发布时间】: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]
    }
  }
}

【问题讨论】:

  • 请包括zebrafishhuman 的前几行。 ortho_genes 列表之间是否存在 1:1 的关系?这可能适合 join()merge() 而不是嵌套循环
  • 如果您包含一个简单的 reproducible example 以及可用于测试和验证可能的解决方案的示例输入和所需的输出,则可以更轻松地为您提供帮助。在问题本身而不是外部文件中包含数据。

标签: r bioinformatics


【解决方案1】:

您没有指定ortho_genes 的结构。这是我的猜测:

ortho_genes <- tibble::tibble(Zebra = c("greb1l", "sin3b", "ncapg2", "fam50a", "psmd12", "bptf", "fam178a"),
                              Human = c("GREB1L","SIN3B","NCAPG2","FAM50A","PSMD12","BPTF","SLF2"))

您可以简单地用 sample_list 索引表(它是一个向量,而不是列表)

sample_list <- c("NCAPG2", "SLF2", "GREB1L")
ortho_genes[ortho_genes$Human %in% sample_list,]

您也没有指定您想要的输出方式。你需要矩阵吗?如果要将结果写入文件,矩阵可能不是最优的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-04-17
    • 2017-02-28
    • 1970-01-01
    • 1970-01-01
    • 2016-11-10
    • 2020-04-02
    • 1970-01-01
    相关资源
    最近更新 更多