biomaRt命名空间加载失败求助:R更新后无法加载biomaRt包
解决biomaRt加载时dbplyr相关报错问题
更新到R 4.2.3后安装biomaRt包,调用library("biomaRt")时触发如下报错:
Error in completeSubclasses(classDef2, class1, obj, where) : trying to get slot "subclasses" from an object of a basic class ("NULL") with no slots Error: caricamento pacchetto o namespace fallito per ‘biomaRt’: .onLoad fallito in loadNamespace() per 'dbplyr', dettagli: chiamata: setClass(cl, contains = c(prevClass, "VIRTUAL"), where = where) errore: errore nelle classi contenute ("character") per la classe “ident”; definizione di classe rimossa da ‘dbplyr’
已尝试重新安装biomaRt并更新dbplyr,但问题未解决,以下是sessionInfo信息:
> sessionInfo() R version 4.2.3 (2023-03-15 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 22621) Matrix products: default locale: [1] LC_COLLATE=Italian_Italy.utf8 LC_CTYPE=Italian_Italy.utf8 LC_MONETARY=Italian_Italy.utf8 LC_NUMERIC=C [5] LC_TIME=Italian_Italy.utf8 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] fgsea_1.24.0 colorspace_2.1-0 ggtree_3.6.2 gson_0.1.0 qvalue_2.30.0 [6] XVector_0.38.0 aplot_0.1.10 rstudioapi_0.14 farver_2.1.1 graphlayouts_0.8.4 [11] ggrepel_0.9.3 bit64_4.0.5 AnnotationDbi_1.60.2 fansi_1.0.4 scatterpie_0.1.8 [16] codetools_0.2-19 splines_4.2.3 cachem_1.0.7 GOSemSim_2.24.0 knitr_1.42 [21] polyclip_1.10-4 jsonlite_1.8.4 GO.db_3.16.0 png_0.1-8 ggforce_0.4.1 [26] BiocManager_1.30.20 compiler_4.2.3 httr_1.4.5 Matrix_1.5-3 fastmap_1.1.1 [31] lazyeval_0.2.2 cli_3.6.1 tweenr_2.0.2 htmltools_0.5.5 prettyunits_1.1.1 [36] tools_4.2.3 igraph_1.4.1 gtable_0.3.3 glue_1.6.2 GenomeInfoDbData_1.2.9 [41] reshape2_1.4.4 dplyr_1.1.1 fastmatch_1.1-3 Rcpp_1.0.10 enrichplot_1.18.4 [46] Biobase_2.58.0 vctrs_0.6.1 Biostrings_2.66.0 ape_5.7-1 nlme_3.1-162 [51] ggraph_2.1.0 xfun_0.38 stringr_1.5.0 lifecycle_1.0.3 clusterProfiler_4.6.2 [56] XML_3.99-0.14 DOSE_3.24.2 zlibbioc_1.44.0 MASS_7.3-58.2 scales_1.2.1 [61] tidygraph_1.2.3 hms_1.1.3 parallel_4.2.3 RColorBrewer_1.1-3 yaml_2.3.7 [66] memoise_2.0.1 gridExtra_2.3 ggplot2_3.4.2 downloader_0.4 ggfun_0.0.9 [71] HDO.db_0.99.1 yulab.utils_0.0.6 stringi_1.7.12 RSQLite_2.3.0 S4Vectors_0.36.2 [76] tidytree_0.4.2 BiocGenerics_0.44.0 BiocParallel_1.32.6 GenomeInfoDb_1.34.9 rlang_1.1.0 [81] pkgconfig_2.0.3 bitops_1.0-7 evaluate_0.20 lattice_0.20-45 purrr_1.0.1 [86] treeio_1.22.0 patchwork_1.1.2 cowplot_1.1.1 shadowtext_0.1.2 bit_4.0.5 [91] tidyselect_1.2.0 plyr_1.8.8 magrittr_2.0.3 R6_2.5.1 IRanges_2.32.0 [96] generics_0.1.3 DBI_1.1.3 pillar_1.9.0 withr_2.5.0 KEGGREST_1.38.0 [101] RCurl_1.98-1.12 tibble_3.2.1 crayon_1.5.2 utf8_1.2.3 rmarkdown_2.21 [106] viridis_0.6.2 progress_1.2.2 grid_4.2.3 data.table_1.14.8 blob_1.2.4 [111] digest_0.6.31 tidyr_1.3.0 gridGraphics_0.5-1 stats4_4.2.3 munsell_0.5.0 [116] viridisLite_0.4.1 ggplotify_0.1.0
解决方案
报错根源是dbplyr的类定义与当前环境中残留的旧版本文件或其他包冲突,导致命名空间加载失败,进而影响biomaRt的加载。可按以下步骤解决:
- 完全卸载并重装dbplyr:关闭所有R会话后执行,确保彻底清除旧版本文件
remove.packages("dbplyr") install.packages("dbplyr")
- 匹配Bioconductor版本安装biomaRt:你的R 4.2.3对应Bioconductor 3.16版本,需安装对应版本的biomaRt以保证依赖兼容
if (!require("BiocManager", quietly = TRUE)) install.packages("BiocManager") BiocManager::install("biomaRt", version = "3.16")
- 清理包缓存并重装依赖:缓存文件可能引发版本冲突,清理后重新安装相关包
# 清理用户库中的包缓存 unlink(file.path(Sys.getenv("R_LIBS_USER"), ".cache"), recursive = TRUE) # 强制重装biomaRt及所有依赖 BiocManager::install(c("biomaRt", "dbplyr"), dependencies = TRUE, force = TRUE)
- 启动干净R会话加载biomaRt:打开R/RStudio后不要加载任何其他包,直接执行
library("biomaRt"),避免其他包的命名空间干扰
内容的提问来源于stack exchange,提问作者Alessia
相关产品推荐
相关产品推荐

