小编net*_*lak的帖子

用户定义的函数在 dplyr 管道中不起作用

我有一个带有蛋白质登录号的数据集 (DataGranulomeTidy)。我在 r 中编写了一个函数 (extractInfo) 来从 ncbi 网站上抓取这些蛋白质的一些信息。当我在一个简短的“for”循环中运行它时,该函数按预期工作。

DataGranulomeTidy <- tibble(GIaccessionNumber = c("29436380", "4504165", "17318569"))

extractInfo <- function(GInumber){
    tempPage <- readLines(paste("https://www.ncbi.nlm.nih.gov/sviewer/viewer.fcgi?id=", GInumber, "&db=protein&report=genpept&conwithfeat=on&withparts=on&show-cdd=on&retmode=html&withmarkup=on&tool=portal&log$=seqview&maxdownloadsize=1000000", sep = ""), skipNul = TRUE)
    tempPage  <- base::paste(tempPage, collapse = "")
    Accession <- str_extract(tempPage, "(?<=ACCESSION).{3,20}(?=VERSION)")
    Symbol    <- str_extract(tempPage, "(?<=gene=\").{1,20}(?=\")")
    GeneID    <- str_extract(tempPage, "(?<=gov/gene/).{1,20}(?=\">)")
    out       <- paste(Symbol, Accession, GeneID, sep = "---")
    return(out)
}


for(n in 1:3){
    print(extractInfo(GInumber = DataGranulomeTidy$GIaccessionNumber[n]))
}
 [1] "MYH9---   AAH49849---4627"
 [1] "GSN---   NP_000168---2934"
 [1] "KRT1---   NP_006112---3848"
Run Code Online (Sandbox Code Playgroud)

当我在 dplyr 管道中使用相同的功能时,我不起作用,我无法弄清楚为什么。

 > DataGranulomeTidy …
Run Code Online (Sandbox Code Playgroud)

r function bioinformatics ncbi dplyr

5
推荐指数
1
解决办法
121
查看次数

标签 统计

bioinformatics ×1

dplyr ×1

function ×1

ncbi ×1

r ×1