Matrix::readMM包報Dim_validate錯誤
在使用Matrix::readMM讀取10x的mtx文件的時候,出現(xiàn)一下報錯:
a=Matrix::readMM('matrix.mtx')
Error in isTRUE(r <- .Call(Dim_validate, object, "Matrix")) :
object 'Dim_validate' not found
在google上搜索各種問題,沒有找到相關(guān)解決方案,然后再集群的另外一個R中,缺正常讀取mtx文件,這樣看了,可能是版本兼容性的問題,查看另外一個Matrix包的版本:
#可用Matrix版本
packageVersion('Matrix')
#[1] ‘1.5.3’
#不可用Matrix版本:
packageVersion('Matrix')
#[1] ‘1.6.0’
解決問題
發(fā)現(xiàn)兩者版本不一樣,嘗試按照老版本的Matrix包,測試:
devtools::install_version("Matrix", version ='1.5.3')
a=Matrix::readMM('matrix.mtx')
a[1:3,1:5]
#3 x 5 sparse Matrix of class "dgTMatrix"
#
#[1,] . . . . .
#[2,] . . . . .
#[3,] . . . . .
終于解決問題,正常讀取mtx文件,通過此報錯,說明R包不一定最新的就合適,新的R包可能與其他的一些包存在一些兼容性問題。