undefined columns selected

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

undefined columns selected

anikaM
Hello,

I am trying to run this software:

https://github.com/eleporcu/TWMR

and I have my input files in my current directory: ENSG00000154803.matrix,
ENSG00000154803.ld

but when I try to run it:

Rscript MR.R ENSG00000154803

[1] "ENSG00000154803"
Error in `[.data.frame`(C, , 1:length(C[, 1])) :
  undefined columns selected
Calls: as.matrix -> [ -> [.data.frame
Execution halted

I should mention that I was able to run this script before with the same
command when I had input like:
https://github.com/eleporcu/TWMR/blob/master/ENSG00000000971.matrix

and I also, per suggestion changed the beginning of the code to be:
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)])

now my input is like this:

https://github.com/eleporcu/TWMR/blob/master/ENSG00000000419.matrix

so 4 columns instead of 3 like it was before and when I run it I get that
error above.

Please advise,
Ana

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: undefined columns selected

Bert Gunter-2
Basically no clue, but note that C[, 1:length(C[ ,1])] looks suspect -- you
are selecting the number of columns equal to the number of rows in C. Is
that really what you want to do?

Bert

On Tue, Dec 3, 2019, 2:36 PM Ana Marija <[hidden email]> wrote:

> Hello,
>
> I am trying to run this software:
>
> https://github.com/eleporcu/TWMR
>
> and I have my input files in my current directory: ENSG00000154803.matrix,
> ENSG00000154803.ld
>
> but when I try to run it:
>
> Rscript MR.R ENSG00000154803
>
> [1] "ENSG00000154803"
> Error in `[.data.frame`(C, , 1:length(C[, 1])) :
>   undefined columns selected
> Calls: as.matrix -> [ -> [.data.frame
> Execution halted
>
> I should mention that I was able to run this script before with the same
> command when I had input like:
> https://github.com/eleporcu/TWMR/blob/master/ENSG00000000971.matrix
>
> and I also, per suggestion changed the beginning of the code to be:
> 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)])
>
> now my input is like this:
>
> https://github.com/eleporcu/TWMR/blob/master/ENSG00000000419.matrix
>
> so 4 columns instead of 3 like it was before and when I run it I get that
> error above.
>
> Please advise,
> Ana
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.