如何使用rentrez跟踪哪个蛋白质ID与哪个基因ID相关联

如何使用rentrez跟踪哪个蛋白质ID与哪个基因ID相关联,r,bioconductor,ncbi,rentrez,R,Bioconductor,Ncbi,Rentrez,我有一堆蛋白质ID,我想在不丢失蛋白质ID的情况下获取相应的编码序列(CDS)。我已经设法下载了相应的CDS,但不幸的是,CDS ID与NCBI中的蛋白质ID非常不同 我有以下R代码: library(rentrez) Prot_ids <- c("XP_012370245.1","XP_004866438.1","XP_013359583.1") links <- entrez_link(dbfrom="protein", db="nuccore", id=Prot_ids, by

我有一堆蛋白质ID,我想在不丢失蛋白质ID的情况下获取相应的编码序列(CDS)。我已经设法下载了相应的CDS,但不幸的是,CDS ID与NCBI中的蛋白质ID非常不同

我有以下R代码:

library(rentrez)
Prot_ids <- c("XP_012370245.1","XP_004866438.1","XP_013359583.1")
links <- entrez_link(dbfrom="protein", db="nuccore", id=Prot_ids, by_id = TRUE)
然而,正如您所看到的参数“by_id=TRUE”只是列出了三个elink对象,但现在我丢失了蛋白质id

我想要像这样的东西:

蛋白质ID XP_012370245.1 XP_004866438.1 XP_013359583.1

CDS ID XM_004866381.2 XM_012514791.1 XM_013504129.1

欢迎提出任何建议,谢谢

库(rentrez)
library(rentrez)
Prot_ids <- c("XP_012370245.1","XP_004866438.1","XP_013359583.1")
links <- entrez_link(dbfrom="protein", db="nuccore", id=Prot_ids, by_id = TRUE)
linkids <- sapply(links, function(x) x$links$protein_nuccore_mrna)
##Get the summary for the gi record
linkNuc <- entrez_summary(id = linkids, db = "nuccore")

df <- data.frame(ProtIDs = Prot_ids[rep(sapply(links, function(x) length(x$links$protein_nuccore_mrna)))], 
                 linkids, 
                 NucID=sapply(strsplit(sapply(linkNuc, "[[", "extra"), split = "\\|"), "[", 4))

#                 ProtIDs   linkids          NucID
#820968283 XP_012370245.1 820968283 XM_012514791.1
#861491027 XP_012370245.1 861491027 XM_004866381.2
#918634580 XP_012370245.1 918634580 XM_013504129.1

请制作一个可复制的示例。例如,
links2
从哪里来?你总是可以做
名称(links)哦,对不起,只是
链接
,应该是
lappy(links,function(x)x$links$protein\u nuccore\u mrna)
。我会修好的。谢谢这正是我想要的,非常感谢!
library(rentrez)
Prot_ids <- c("XP_012370245.1","XP_004866438.1","XP_013359583.1")
links <- entrez_link(dbfrom="protein", db="nuccore", id=Prot_ids, by_id = TRUE)
linkids <- sapply(links, function(x) x$links$protein_nuccore_mrna)
##Get the summary for the gi record
linkNuc <- entrez_summary(id = linkids, db = "nuccore")

df <- data.frame(ProtIDs = Prot_ids[rep(sapply(links, function(x) length(x$links$protein_nuccore_mrna)))], 
                 linkids, 
                 NucID=sapply(strsplit(sapply(linkNuc, "[[", "extra"), split = "\\|"), "[", 4))

#                 ProtIDs   linkids          NucID
#820968283 XP_012370245.1 820968283 XM_012514791.1
#861491027 XP_012370245.1 861491027 XM_004866381.2
#918634580 XP_012370245.1 918634580 XM_013504129.1