You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法安装Matrix 1.6-1旧版本致函数报错,寻求解决方法

问题:安装Matrix 1.6-1失败导致quickCluster报错无法运行

问题背景

在SingleCellExperiment对象上运行quickCluster函数时出现报错:

Error in (function (A, nv = 5, nu = nv, maxit = 1000, work = nv + 7, reorth = TRUE, :
function 'as_cholmod_sparse' not provided by package 'Matrix'

查阅资料得知安装Matrix旧版本(1.6-1)可解决该问题,但安装过程中出现编译失败。

尝试的安装命令及报错

执行以下命令安装指定版本的Matrix:

install.packages("remotes")
remotes::install_version("Matrix", version = "1.6-1")

返回编译失败错误:

ld: warning: directory not found for option '-L/opt/gfortran/lib/gcc/aarch64-apple-darwin20.0/12.2.0' ld: warning: directory not found for option '-L/opt/gfortran/lib' ld: library not found for -lgfortran clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [Matrix.so] Error 1 ERROR: compilation failed for package ‘Matrix’

  • removing ‘/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/Matrix’
  • restoring previous ‘/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/Matrix’
    Warning message: In i.p(...) : installation of package ‘/var/folders/mx/spt7cbq57gn6ssxwq_yhzmqh0000gp/T//RtmpxuzZmQ/remotes2e406022dae6/Matrix’ had non-zero exit status

已尝试的无效操作

  • 卸载Matrix、irlba、Seurat后重新安装,问题未解决

Session信息

> sessionInfo()
R version 4.3.2 (2023-10-31)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.3.1

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/New_York
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base      

loaded via a namespace (and not attached):
 [1] SummarizedExperiment_1.32.0 gtable_0.3.4                beeswarm_0.4.0              ggplot2_3.4.4               
 [5] remotes_2.4.2.1             processx_3.8.3              ggrepel_0.9.5               Biobase_2.62.0              
 [9] lattice_0.22-5              callr_3.7.3                 ps_1.7.6                    vctrs_0.6.5                 
[13] tools_4.3.2                 bitops_1.0-7                generics_0.1.3              stats4_4.3.2                
[17] parallel_4.3.2              tibble_3.2.1                fansi_1.0.6                 pkgconfig_2.0.3             
[21] BiocNeighbors_1.20.2        Matrix_1.6-5                S4Vectors_0.40.2            sparseMatrixStats_1.14.0    
[25] lifecycle_1.0.4             GenomeInfoDbData_1.2.11     compiler_4.3.2              munsell_0.5.0               
[29] codetools_0.2-19            vipor_0.4.7                 GenomeInfoDb_1.38.5         RCurl_1.98-1.14             
[33] pillar_1.9.0                crayon_1.5.2                BiocParallel_1.36.0         SingleCellExperiment_1.24.0
[37] DelayedArray_0.28.0         viridis_0.6.5               abind_1.4-5                 tidyselect_1.2.0            
[41] rsvd_1.0.5                  BiocSingular_1.18.0         dplyr_1.1.4                 grid_4.3.2                  
[45] colorspace_2.1-0            cli_3.6.2                   SparseArray_1.2.3           scater_1.30.1               
[49] magrittr_2.0.3              S4Arrays_1.2.0              pkgbuild_1.4.3              utf8_1.2.4                  
[53] DelayedMatrixStats_1.24.0   scales_1.3.0                ggbeeswarm_0.7.2            XVector_0.42.0              
[57] matrixStats_1.2.0           gridExtra_2.3               reticulate_1.34.0           png_0.1-8                   
[61] ScaledMatrix_1.10.0         beachmat_2.18.0             GenomicRanges_1.54.1        IRanges_2.36.0              
[65] viridisLite_0.4.2           irlba_2.3.5.1               rlang_1.1.3                 Rcpp_1.0.12                 
[69] glue_1.7.0                  scuttle_1.12.0              BiocGenerics_0.48.1         rstudioapi_0.15.0           
[73] jsonlite_1.8.8              plyr_1.8.9                  R6_2.5.1                    MatrixGenerics_1.14.0       
[77] zlibbioc_1.48.0  

解决思路建议

  1. 修复gfortran依赖:报错核心是找不到libgfortran库,这是编译Matrix包的必需组件。在Apple Silicon Mac上,可通过Homebrew安装gcc(包含gfortran):

    brew install gcc
    

    安装完成后重新运行Matrix的安装命令。

  2. 安装预编译二进制包:跳过源码编译,使用pak包尝试安装适配系统的预编译版本:

    install.packages("pak")
    pak::pkg_install("Matrix@1.6-1")
    

    pak会自动寻找兼容的二进制包,降低编译失败概率。

  3. 适配新版Matrix:检查quickCluster所属的scran包是否有更新版本,确认是否已修复与Matrix 1.6-5的兼容问题,若有则直接升级scran:

    BiocManager::install("scran")
    
  4. 创建隔离R环境:使用renv搭建独立环境,在环境内安装指定版本的Matrix及依赖,避免干扰全局环境:

    install.packages("renv")
    renv::init()
    renv::install("Matrix@1.6-1")
    

内容的提问来源于stack exchange,提问作者Fernanda França

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 22:28:11