ZikunY / CARMA

GWAS genetics Fine-mapping method
GNU General Public License v3.0
20 stars 7 forks source link

no method or default for coercing “matrix” to “dMatrix” #7

Closed Hiuyu closed 1 year ago

Hiuyu commented 1 year ago

Hi Zikun, I met an error when following CARMA_dome.pdf as follows.

> CARMA.results<-CARMA_fixed_sigma(z.list,ld.list,lambda.list=lambda.list, outlier.switch=F)`
Error in as(matrix(0, nrow = nrow(x), ncol = p), "dMatrix") : 
  no method or default for coercing “matrix” to “dMatrix”

After traceback to the "CARMA.R" file, I supposed the error arise from the lack of a method to convert 'matrix' to 'dMatrix'.

index.fun.inner<-function(x){
      m<-as(as(as(matrix(0,nrow=nrow(x),ncol=p), "dMatrix"), "generalMatrix"), "TsparseMatrix")
      m@i<-as.integer(rep(1:nrow(x)-1,each=ncol(x)))
      m@j<-as.integer(c(t(x))-1)
      m@x=rep(1,nrow(x)*ncol(x))
      m<-as(m,"CsparseMatrix")
      return(m)
    }

Could you please provide some suggestions?

ZikunY commented 1 year ago

@Hiuyu This is due to the update of Matrix package, where the expression of as(,"dgTMatrix") has been deprecated. Please try R/4.2.2, it should fix the problem. But please do let me know if the error remains. Thank you!