[R] Lapack routine dgesv: system is exactly singular

Ana Marija @okov|c@@n@m@r|j@ @end|ng |rom gm@||@com
Wed Dec 4 23:30:50 CET 2019


Hello,

I am sorry for posting this question related to TWMR but it seems I
can nto proceed with this. Hopefully this post now will make sense.

So I am running this code:
https://github.com/eleporcu/TWMR/blob/master/MR.R

I made this change in code so that I can run it like this:
Rscript MR.R ENSG00000154803

the change of the beginning of code is this:
cmd_args <- commandArgs(TRUE)
if (length(cmd_args) == 0L) stop("No arguments specified.")
print(cmd_args)
gene<-cmd_args[length(cmd_args)]   ## Last argument is the 'gene'
Ngwas<-239087
N_eQTLs<-32000
out<-c("gene","alpha","SE","P","Nsnps","Ngene")

file<-paste(gene,"matrix",sep=".")
if (!file.exists(file)) stop("File not found: ", file)
filecluster<-read.table(file,header=T,sep=" ",dec=".")
beta<-as.matrix(filecluster[,2:(length(filecluster[1,])-1)])

The error I am getting when I run the code with my data is:
[1] "ENSG00000154803"
Error in solve.default(C) :
  Lapack routine dgesv: system is exactly singular: U[15,15] = 0
Calls: solve -> solve.default
Execution halted


I loaded my ENSG00000154803.ld file in R as matrix (a) and:

library(matrixcalc)
is.singular.matrix(a, tol = 1e-08)
TRUE

Seems that my matrix is singular. What do you advice in this case?

Thanks
Ana



More information about the R-help mailing list