我正在尝试在我自己的软件包中包含一个来自Bioconductor软件包"simpIntLists“的函数。将"import(simpIntLists)“添加到名称空间文件。但是,该函数会导致错误
do_xy <- function(organism, IDType){
network <- simpIntLists::findInteractionList(organism, IDType)
}
do_xy("human", "EntrezId")
#Error message
data set ‘HumanBioGRIDInteractionEntrezId’ not foundError in get("HumanBioGRIDInteractionEntrezId") :
object 'HumanBioGRIDInteractionEntrezId' not found
# results in the same error (outside of the function)
simpIntLists::findInteractionList(organism, IDType)当连接了simpIntLists时,它工作正常
# works
library(simpIntLists)
network <- simpIntLists::findInteractionList(organism, IDType)发布于 2021-11-04 13:24:51
我在这里看到了代码(https://bioconductor.org/packages/release/data/experiment/html/simpIntLists.html)。这段代码似乎没有考虑到在没有安装的情况下使用包的情况。
供您参考,此错误的相关部分位于第52行附近。
else if (organism == 'human'){
if (idType == 'EntrezId'){
data(HumanBioGRIDInteractionEntrezId);
interactionList <- get("HumanBioGRIDInteractionEntrezId");
}它会尝试将数据获取到名称空间,但如果还没有通过library导入包,则会失败。这只会生成一个警告。然后,当它尝试使用该数据时就会出现错误,因为该数据在命名空间中不存在。
一种解决方法是在代码中显式导入数据。然后您可以使用如下所示的函数。请注意,由于嵌入的包代码,该警告仍然存在。如果警告令人讨厌,请使用suppressWarnings。
data(HumanBioGRIDInteractionEntrezId, package="simpIntLists")
simpIntLists::findInteractionList("human", "EntrezId")https://stackoverflow.com/questions/69838164
复制相似问题