Re: [R] cannot open file '--no-restore.matrix'
Thank you so much this indeed solved my issue! On Sat, Nov 23, 2019 at 3:05 PM Henrik Bengtsson wrote: > > Looking at the https://github.com/eleporcu/TWMR/blob/master/README.txt, > it looks like you should pass a single argument when you call the MR.R > script and it should be the name of a gene, e.g. 'ENSG0154803'. > You are passing two arguments and they look like filenames. > > Update the script, because it should really use commandArgs(TRUE), to: > > 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=".") > ... > > The call the script from the command line as: > > $ Rscript MR.R ENSG0154803 > > That should do it > > /Henrik > > > On Sat, Nov 23, 2019 at 12:24 PM Ana Marija > wrote: > > > > it is confusing because in documentation they say this is how you run > > the script: > > https://github.com/eleporcu/TWMR > > > > I tried changing this on the script: > > > > cmd_args=commandArgs(TRUE) > > print(cmd_args) > > gene<-cmd_args[3] > > 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=".") > > #file<-paste(gene,"matrix",sep=".") > > #filecluster<-read.table(file,header=T,sep=".",dec=" ") > > beta<-as.matrix(filecluster[,2:(length(filecluster[1,])-1)]) > > > > and I run it: > > Rscript< MR.R --no-save ENSG0154803.ld ENSG0154803.matrix > > Error: unexpected numeric constant in "1.000 0.089" > > Execution halted > > > > > > I also tried this: > > Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix > > [1] "ENSG0154803.ld" "ENSG0154803.matrix" > > Error: File not found: NA.matrix > > Execution halted > > > > > > Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix > > [1] "ENSG0154803.ld" "ENSG0154803.matrix" > > Error: File not found: NA.matrix > > Execution halted > > > > On Sat, Nov 23, 2019 at 2:08 PM Henrik Bengtsson > > wrote: > > > > > > Maybe it would help to add: > > > > > > file<-paste(gene,"matrix",sep=".") > > > if (!file.exists(file)) stop("File not found: ", file) > > > filecluster<-read.table(file,header=T,sep=" ",dec=".") > > > > > > /Henrik > > > > > > On Sat, Nov 23, 2019 at 11:55 AM Duncan Murdoch > > > wrote: > > > > > > > > On 23/11/2019 1:21 p.m., Ana Marija wrote: > > > > > Hi Duncan, > > > > > > > > > > thanks, I just did, > > > > > Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix > > > > > [1] "ENSG0154803.ld" "ENSG0154803.matrix" > > > > > Error in file(file, "rt") : cannot open the connection > > > > > Calls: read.table -> file > > > > > In addition: Warning message: > > > > > In file(file, "rt") : > > > > >cannot open file 'NA.matrix': No such file or directory > > > > > Execution halted > > > > > > > > > Your script works with the third element in the list of arguments, and > > > > there are only two. > > > > > > > > Duncan Murdoch > > > > > > > > > > > > > > Please advise > > > > > > > > > > On Sat, Nov 23, 2019 at 12:13 PM Duncan Murdoch > > > > > wrote: > > > > >> > > > > >> On 23/11/2019 11:05 a.m., Ana Marija wrote: > > > > >>> Hi Ben, > > > > >>> > > > > >>> I am not sure what you mean when you say to print, is it this? > > > > >>> > > > > cmd_args=commandArgs(TRUE) > > > > print(cmd_args) > > > > >>> character(0) > > > > cmd_args=commandArgs() > > > > print(cmd_args) > > > > >>> [1] > > > > >>> "/software/linux-el7-x86_64/compilers/r-3.6.1/lib64/R/bin/exec/R" > > > > >>> > > > > >>> I changed in the first line of this script: > > > > >>> https://github.com/eleporcu/TWMR/blob/master/MR.R > > > > >>> > > > > >>> cmd_args=commandArgs() to be cmd_args=commandArgs(TRUE) > > > > >>> > > > > >>> but again I get the same error: > > > > >>> > > > > >>> Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix > > > > >>> Error in file(file, "rt") : cannot open the connection > > > > >>> Calls: read.table -> file > > > > >>> In addition: Warning message: > > > > >>> In file(file, "rt") : > > > > >>> cannot open file 'NA.matrix': No such file or directory > > > > >>> Execution halted > > > > >> > > > > >> You didn't put the print(cmd_args) into the script. > > > > >> > > > > >> Duncan Murdoch > > > > >>> > > > > >>> > > > > >>> Please advise, > > > > >>> Ana > > > > >>> > > > > >>> On Sat, Nov 23, 2019 at 9:44 AM Duncan Murdoch > > > > >>> wrote: > > > > > > > > On 23/11/2019 10:26 a.m., Ana Marija wrote: > > > > > HI Ben, > > > > > > > > > > I tried it but it doesn't work: > > > >
Re: [R] cannot open file '--no-restore.matrix'
Looking at the https://github.com/eleporcu/TWMR/blob/master/README.txt, it looks like you should pass a single argument when you call the MR.R script and it should be the name of a gene, e.g. 'ENSG0154803'. You are passing two arguments and they look like filenames. Update the script, because it should really use commandArgs(TRUE), to: 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=".") ... The call the script from the command line as: $ Rscript MR.R ENSG0154803 That should do it /Henrik On Sat, Nov 23, 2019 at 12:24 PM Ana Marija wrote: > > it is confusing because in documentation they say this is how you run > the script: > https://github.com/eleporcu/TWMR > > I tried changing this on the script: > > cmd_args=commandArgs(TRUE) > print(cmd_args) > gene<-cmd_args[3] > 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=".") > #file<-paste(gene,"matrix",sep=".") > #filecluster<-read.table(file,header=T,sep=".",dec=" ") > beta<-as.matrix(filecluster[,2:(length(filecluster[1,])-1)]) > > and I run it: > Rscript< MR.R --no-save ENSG0154803.ld ENSG0154803.matrix > Error: unexpected numeric constant in "1.000 0.089" > Execution halted > > > I also tried this: > Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix > [1] "ENSG0154803.ld" "ENSG0154803.matrix" > Error: File not found: NA.matrix > Execution halted > > > Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix > [1] "ENSG0154803.ld" "ENSG0154803.matrix" > Error: File not found: NA.matrix > Execution halted > > On Sat, Nov 23, 2019 at 2:08 PM Henrik Bengtsson > wrote: > > > > Maybe it would help to add: > > > > file<-paste(gene,"matrix",sep=".") > > if (!file.exists(file)) stop("File not found: ", file) > > filecluster<-read.table(file,header=T,sep=" ",dec=".") > > > > /Henrik > > > > On Sat, Nov 23, 2019 at 11:55 AM Duncan Murdoch > > wrote: > > > > > > On 23/11/2019 1:21 p.m., Ana Marija wrote: > > > > Hi Duncan, > > > > > > > > thanks, I just did, > > > > Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix > > > > [1] "ENSG0154803.ld" "ENSG0154803.matrix" > > > > Error in file(file, "rt") : cannot open the connection > > > > Calls: read.table -> file > > > > In addition: Warning message: > > > > In file(file, "rt") : > > > >cannot open file 'NA.matrix': No such file or directory > > > > Execution halted > > > > > > > Your script works with the third element in the list of arguments, and > > > there are only two. > > > > > > Duncan Murdoch > > > > > > > > > > > Please advise > > > > > > > > On Sat, Nov 23, 2019 at 12:13 PM Duncan Murdoch > > > > wrote: > > > >> > > > >> On 23/11/2019 11:05 a.m., Ana Marija wrote: > > > >>> Hi Ben, > > > >>> > > > >>> I am not sure what you mean when you say to print, is it this? > > > >>> > > > cmd_args=commandArgs(TRUE) > > > print(cmd_args) > > > >>> character(0) > > > cmd_args=commandArgs() > > > print(cmd_args) > > > >>> [1] "/software/linux-el7-x86_64/compilers/r-3.6.1/lib64/R/bin/exec/R" > > > >>> > > > >>> I changed in the first line of this script: > > > >>> https://github.com/eleporcu/TWMR/blob/master/MR.R > > > >>> > > > >>> cmd_args=commandArgs() to be cmd_args=commandArgs(TRUE) > > > >>> > > > >>> but again I get the same error: > > > >>> > > > >>> Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix > > > >>> Error in file(file, "rt") : cannot open the connection > > > >>> Calls: read.table -> file > > > >>> In addition: Warning message: > > > >>> In file(file, "rt") : > > > >>> cannot open file 'NA.matrix': No such file or directory > > > >>> Execution halted > > > >> > > > >> You didn't put the print(cmd_args) into the script. > > > >> > > > >> Duncan Murdoch > > > >>> > > > >>> > > > >>> Please advise, > > > >>> Ana > > > >>> > > > >>> On Sat, Nov 23, 2019 at 9:44 AM Duncan Murdoch > > > >>> wrote: > > > > > > On 23/11/2019 10:26 a.m., Ana Marija wrote: > > > > HI Ben, > > > > > > > > I tried it but it doesn't work: > > > > > > > > Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix > > > > Error in file(file, "rt") : cannot open the connection > > > > Calls: read.table -> file > > > > In addition: Warning message: > > > > In file(file, "rt") : > > > > cannot open file '--no-restore.matrix': No such file or > > > > directory > > > > Execution halted > > > > > > > > > >
Re: [R] cannot open file '--no-restore.matrix'
it is confusing because in documentation they say this is how you run the script: https://github.com/eleporcu/TWMR I tried changing this on the script: cmd_args=commandArgs(TRUE) print(cmd_args) gene<-cmd_args[3] 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=".") #file<-paste(gene,"matrix",sep=".") #filecluster<-read.table(file,header=T,sep=".",dec=" ") beta<-as.matrix(filecluster[,2:(length(filecluster[1,])-1)]) and I run it: Rscript< MR.R --no-save ENSG0154803.ld ENSG0154803.matrix Error: unexpected numeric constant in "1.000 0.089" Execution halted I also tried this: Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix [1] "ENSG0154803.ld" "ENSG0154803.matrix" Error: File not found: NA.matrix Execution halted Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix [1] "ENSG0154803.ld" "ENSG0154803.matrix" Error: File not found: NA.matrix Execution halted On Sat, Nov 23, 2019 at 2:08 PM Henrik Bengtsson wrote: > > Maybe it would help to add: > > file<-paste(gene,"matrix",sep=".") > if (!file.exists(file)) stop("File not found: ", file) > filecluster<-read.table(file,header=T,sep=" ",dec=".") > > /Henrik > > On Sat, Nov 23, 2019 at 11:55 AM Duncan Murdoch > wrote: > > > > On 23/11/2019 1:21 p.m., Ana Marija wrote: > > > Hi Duncan, > > > > > > thanks, I just did, > > > Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix > > > [1] "ENSG0154803.ld" "ENSG0154803.matrix" > > > Error in file(file, "rt") : cannot open the connection > > > Calls: read.table -> file > > > In addition: Warning message: > > > In file(file, "rt") : > > >cannot open file 'NA.matrix': No such file or directory > > > Execution halted > > > > > Your script works with the third element in the list of arguments, and > > there are only two. > > > > Duncan Murdoch > > > > > > > > Please advise > > > > > > On Sat, Nov 23, 2019 at 12:13 PM Duncan Murdoch > > > wrote: > > >> > > >> On 23/11/2019 11:05 a.m., Ana Marija wrote: > > >>> Hi Ben, > > >>> > > >>> I am not sure what you mean when you say to print, is it this? > > >>> > > cmd_args=commandArgs(TRUE) > > print(cmd_args) > > >>> character(0) > > cmd_args=commandArgs() > > print(cmd_args) > > >>> [1] "/software/linux-el7-x86_64/compilers/r-3.6.1/lib64/R/bin/exec/R" > > >>> > > >>> I changed in the first line of this script: > > >>> https://github.com/eleporcu/TWMR/blob/master/MR.R > > >>> > > >>> cmd_args=commandArgs() to be cmd_args=commandArgs(TRUE) > > >>> > > >>> but again I get the same error: > > >>> > > >>> Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix > > >>> Error in file(file, "rt") : cannot open the connection > > >>> Calls: read.table -> file > > >>> In addition: Warning message: > > >>> In file(file, "rt") : > > >>> cannot open file 'NA.matrix': No such file or directory > > >>> Execution halted > > >> > > >> You didn't put the print(cmd_args) into the script. > > >> > > >> Duncan Murdoch > > >>> > > >>> > > >>> Please advise, > > >>> Ana > > >>> > > >>> On Sat, Nov 23, 2019 at 9:44 AM Duncan Murdoch > > >>> wrote: > > > > On 23/11/2019 10:26 a.m., Ana Marija wrote: > > > HI Ben, > > > > > > I tried it but it doesn't work: > > > > > > Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix > > > Error in file(file, "rt") : cannot open the connection > > > Calls: read.table -> file > > > In addition: Warning message: > > > In file(file, "rt") : > > > cannot open file '--no-restore.matrix': No such file or directory > > > Execution halted > > > > > > > You should print the cmd_args variable that is set on the first line of > > that script. When I run a script that prints it using your command > > line, this is what it looks like: > > > > $ Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix > > [1] "/Library/Frameworks/R.framework/Resources/bin/exec/R" > > [2] "--slave" > > [3] "--no-restore" > > [4] "--no-save" > > [5] "--file=MR.R" > > [6] "--args" > > [7] "ENSG0154803.ld" > > [8] "ENSG0154803.matrix" > > > > The next line > > > > gene <- cmd_args[3] > > > > is obviously wrong for my system, because it would set gene to > > "--no-restore". Your results will probably be somewhat different, but > > it might be clear what you should use instead of the third element. > > > > By the way, changing the first line > > > > cmd_args=commandArgs() > > > > to > > > > cmd_args <- commandArgs(TRUE) > > > > makes a lot of sense in most cases. I haven't read your whole script > > so > > I don't know it it makes sense for
Re: [R] cannot open file '--no-restore.matrix'
Maybe it would help to add: file<-paste(gene,"matrix",sep=".") if (!file.exists(file)) stop("File not found: ", file) filecluster<-read.table(file,header=T,sep=" ",dec=".") /Henrik On Sat, Nov 23, 2019 at 11:55 AM Duncan Murdoch wrote: > > On 23/11/2019 1:21 p.m., Ana Marija wrote: > > Hi Duncan, > > > > thanks, I just did, > > Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix > > [1] "ENSG0154803.ld" "ENSG0154803.matrix" > > Error in file(file, "rt") : cannot open the connection > > Calls: read.table -> file > > In addition: Warning message: > > In file(file, "rt") : > >cannot open file 'NA.matrix': No such file or directory > > Execution halted > > > Your script works with the third element in the list of arguments, and > there are only two. > > Duncan Murdoch > > > > > Please advise > > > > On Sat, Nov 23, 2019 at 12:13 PM Duncan Murdoch > > wrote: > >> > >> On 23/11/2019 11:05 a.m., Ana Marija wrote: > >>> Hi Ben, > >>> > >>> I am not sure what you mean when you say to print, is it this? > >>> > cmd_args=commandArgs(TRUE) > print(cmd_args) > >>> character(0) > cmd_args=commandArgs() > print(cmd_args) > >>> [1] "/software/linux-el7-x86_64/compilers/r-3.6.1/lib64/R/bin/exec/R" > >>> > >>> I changed in the first line of this script: > >>> https://github.com/eleporcu/TWMR/blob/master/MR.R > >>> > >>> cmd_args=commandArgs() to be cmd_args=commandArgs(TRUE) > >>> > >>> but again I get the same error: > >>> > >>> Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix > >>> Error in file(file, "rt") : cannot open the connection > >>> Calls: read.table -> file > >>> In addition: Warning message: > >>> In file(file, "rt") : > >>> cannot open file 'NA.matrix': No such file or directory > >>> Execution halted > >> > >> You didn't put the print(cmd_args) into the script. > >> > >> Duncan Murdoch > >>> > >>> > >>> Please advise, > >>> Ana > >>> > >>> On Sat, Nov 23, 2019 at 9:44 AM Duncan Murdoch > >>> wrote: > > On 23/11/2019 10:26 a.m., Ana Marija wrote: > > HI Ben, > > > > I tried it but it doesn't work: > > > > Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix > > Error in file(file, "rt") : cannot open the connection > > Calls: read.table -> file > > In addition: Warning message: > > In file(file, "rt") : > > cannot open file '--no-restore.matrix': No such file or directory > > Execution halted > > > > You should print the cmd_args variable that is set on the first line of > that script. When I run a script that prints it using your command > line, this is what it looks like: > > $ Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix > [1] "/Library/Frameworks/R.framework/Resources/bin/exec/R" > [2] "--slave" > [3] "--no-restore" > [4] "--no-save" > [5] "--file=MR.R" > [6] "--args" > [7] "ENSG0154803.ld" > [8] "ENSG0154803.matrix" > > The next line > > gene <- cmd_args[3] > > is obviously wrong for my system, because it would set gene to > "--no-restore". Your results will probably be somewhat different, but > it might be clear what you should use instead of the third element. > > By the way, changing the first line > > cmd_args=commandArgs() > > to > > cmd_args <- commandArgs(TRUE) > > makes a lot of sense in most cases. I haven't read your whole script so > I don't know it it makes sense for you. > > Duncan Murdoch > > > > Please advise, > > Ana > > > > On Sat, Nov 23, 2019 at 4:16 AM Ben Tupper wrote: > >> > >> Hi, > >> > >> I think you want this order... > >> > >> Rscript [options for R] script_file.R argument_1 argument_2 ... > >> > >> So, like this ... > >> > >> Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix > >> > >> Cheers, > >> Ben > >> > >> On Fri, Nov 22, 2019 at 8:59 PM Ana Marija > >> wrote: > >>> > >>> HI Ben, > >>> > >>> thank you so much , I did this: > >>> > >>> Rscript --no-save ENSG0154803.ld ENSG0154803.matrix MR.R > >>> Error: unexpected numeric constant in "1.000 0.089" > >>> Execution halted > >>> > >>> I made ENSG0154803.ld with: > >>> library(MASS) > >>> write.matrix(ENSG0154803.ld, file="ENSG0154803.ld") > >>> > >>> and it looks like this: > >>> > >>> 1.000 0.089 0.006 0.038 0.012 0.014 0.003 0.001 0.005 0.015 0.013 > >>> 0.000 0.000 0.000 0.001 0.003 0.000 > >>> 0.089 1.000 0.002 0.007 0.005 0.001 0.004 0.005 0.000 0.003 0.014 > >>> 0.001 0.012 0.005 0.000 0.004 0.004 > >>> 0.006 0.002 1.000 0.004 0.008 0.029 0.040 0.001 0.001 0.006 0.013 > >>> 0.054 0.006 0.002 0.010 0.001 0.000 > >>> 0.038 0.007 0.004 1.000 0.460 0.044
Re: [R] cannot open file '--no-restore.matrix'
On 23/11/2019 1:21 p.m., Ana Marija wrote: Hi Duncan, thanks, I just did, Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix [1] "ENSG0154803.ld" "ENSG0154803.matrix" Error in file(file, "rt") : cannot open the connection Calls: read.table -> file In addition: Warning message: In file(file, "rt") : cannot open file 'NA.matrix': No such file or directory Execution halted Your script works with the third element in the list of arguments, and there are only two. Duncan Murdoch Please advise On Sat, Nov 23, 2019 at 12:13 PM Duncan Murdoch wrote: On 23/11/2019 11:05 a.m., Ana Marija wrote: Hi Ben, I am not sure what you mean when you say to print, is it this? cmd_args=commandArgs(TRUE) print(cmd_args) character(0) cmd_args=commandArgs() print(cmd_args) [1] "/software/linux-el7-x86_64/compilers/r-3.6.1/lib64/R/bin/exec/R" I changed in the first line of this script: https://github.com/eleporcu/TWMR/blob/master/MR.R cmd_args=commandArgs() to be cmd_args=commandArgs(TRUE) but again I get the same error: Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix Error in file(file, "rt") : cannot open the connection Calls: read.table -> file In addition: Warning message: In file(file, "rt") : cannot open file 'NA.matrix': No such file or directory Execution halted You didn't put the print(cmd_args) into the script. Duncan Murdoch Please advise, Ana On Sat, Nov 23, 2019 at 9:44 AM Duncan Murdoch wrote: On 23/11/2019 10:26 a.m., Ana Marija wrote: HI Ben, I tried it but it doesn't work: Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix Error in file(file, "rt") : cannot open the connection Calls: read.table -> file In addition: Warning message: In file(file, "rt") : cannot open file '--no-restore.matrix': No such file or directory Execution halted You should print the cmd_args variable that is set on the first line of that script. When I run a script that prints it using your command line, this is what it looks like: $ Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix [1] "/Library/Frameworks/R.framework/Resources/bin/exec/R" [2] "--slave" [3] "--no-restore" [4] "--no-save" [5] "--file=MR.R" [6] "--args" [7] "ENSG0154803.ld" [8] "ENSG0154803.matrix" The next line gene <- cmd_args[3] is obviously wrong for my system, because it would set gene to "--no-restore". Your results will probably be somewhat different, but it might be clear what you should use instead of the third element. By the way, changing the first line cmd_args=commandArgs() to cmd_args <- commandArgs(TRUE) makes a lot of sense in most cases. I haven't read your whole script so I don't know it it makes sense for you. Duncan Murdoch Please advise, Ana On Sat, Nov 23, 2019 at 4:16 AM Ben Tupper wrote: Hi, I think you want this order... Rscript [options for R] script_file.R argument_1 argument_2 ... So, like this ... Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix Cheers, Ben On Fri, Nov 22, 2019 at 8:59 PM Ana Marija wrote: HI Ben, thank you so much , I did this: Rscript --no-save ENSG0154803.ld ENSG0154803.matrix MR.R Error: unexpected numeric constant in "1.000 0.089" Execution halted I made ENSG0154803.ld with: library(MASS) write.matrix(ENSG0154803.ld, file="ENSG0154803.ld") and it looks like this: 1.000 0.089 0.006 0.038 0.012 0.014 0.003 0.001 0.005 0.015 0.013 0.000 0.000 0.000 0.001 0.003 0.000 0.089 1.000 0.002 0.007 0.005 0.001 0.004 0.005 0.000 0.003 0.014 0.001 0.012 0.005 0.000 0.004 0.004 0.006 0.002 1.000 0.004 0.008 0.029 0.040 0.001 0.001 0.006 0.013 0.054 0.006 0.002 0.010 0.001 0.000 0.038 0.007 0.004 1.000 0.460 0.044 0.008 0.022 0.010 0.229 0.095 0.066 0.010 0.030 0.001 0.003 0.000 0.012 0.005 0.008 0.460 1.000 0.151 0.018 0.047 0.021 0.272 0.185 0.002 0.003 0.066 0.006 0.004 0.004 0.014 0.001 0.029 0.044 0.151 1.000 0.007 0.018 0.218 0.010 0.023 0.016 0.000 0.025 0.000 0.005 0.000 0.003 0.004 0.040 0.008 0.018 0.007 1.000 0.003 0.002 0.020 0.031 0.128 0.019 0.005 0.030 0.002 0.016 0.001 0.005 0.001 0.022 0.047 0.018 0.003 1.000 0.004 0.014 0.004 0.098 0.010 0.012 0.001 0.006 0.003 0.005 0.000 0.001 0.010 0.021 0.218 0.002 0.004 1.000 0.004 0.000 0.012 0.000 0.006 0.018 0.004 0.013 0.015 0.003 0.006 0.229 0.272 0.010 0.020 0.014 0.004 1.000 0.466 0.001 0.091 0.057 0.062 0.002 0.005 0.013 0.014 0.013 0.095 0.185 0.023 0.031 0.004 0.000 0.466 1.000 0.238 0.180 0.073 0.058 0.000 0.006 0.000 0.001 0.054 0.066 0.002 0.016 0.128 0.098 0.012 0.001 0.238 1.000 0.158 0.006 0.044 0.006 0.001 0.000 0.012 0.006 0.010 0.003 0.000 0.019 0.010 0.000 0.091 0.180 0.158 1.000 0.077 0.237 0.009 0.000 0.000 0.005 0.002 0.030 0.066 0.025 0.005 0.012 0.006 0.057 0.073 0.006 0.077 1.000 0.056 0.000 0.004 0.001 0.000 0.010 0.001 0.006 0.000 0.030 0.001 0.018 0.062 0.058 0.044 0.237 0.056 1.000 0.000 0.003 0.003 0.004 0.001 0.003 0.004 0.005 0.002 0.006 0.004 0.002
Re: [R] cannot open file '--no-restore.matrix'
Hi Duncan, thanks, I just did, Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix [1] "ENSG0154803.ld" "ENSG0154803.matrix" Error in file(file, "rt") : cannot open the connection Calls: read.table -> file In addition: Warning message: In file(file, "rt") : cannot open file 'NA.matrix': No such file or directory Execution halted Please advise On Sat, Nov 23, 2019 at 12:13 PM Duncan Murdoch wrote: > > On 23/11/2019 11:05 a.m., Ana Marija wrote: > > Hi Ben, > > > > I am not sure what you mean when you say to print, is it this? > > > >> cmd_args=commandArgs(TRUE) > >> print(cmd_args) > > character(0) > >> cmd_args=commandArgs() > >> print(cmd_args) > > [1] "/software/linux-el7-x86_64/compilers/r-3.6.1/lib64/R/bin/exec/R" > > > > I changed in the first line of this script: > > https://github.com/eleporcu/TWMR/blob/master/MR.R > > > > cmd_args=commandArgs() to be cmd_args=commandArgs(TRUE) > > > > but again I get the same error: > > > > Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix > > Error in file(file, "rt") : cannot open the connection > > Calls: read.table -> file > > In addition: Warning message: > > In file(file, "rt") : > >cannot open file 'NA.matrix': No such file or directory > > Execution halted > > You didn't put the print(cmd_args) into the script. > > Duncan Murdoch > > > > > > Please advise, > > Ana > > > > On Sat, Nov 23, 2019 at 9:44 AM Duncan Murdoch > > wrote: > >> > >> On 23/11/2019 10:26 a.m., Ana Marija wrote: > >>> HI Ben, > >>> > >>> I tried it but it doesn't work: > >>> > >>> Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix > >>> Error in file(file, "rt") : cannot open the connection > >>> Calls: read.table -> file > >>> In addition: Warning message: > >>> In file(file, "rt") : > >>> cannot open file '--no-restore.matrix': No such file or directory > >>> Execution halted > >>> > >> > >> You should print the cmd_args variable that is set on the first line of > >> that script. When I run a script that prints it using your command > >> line, this is what it looks like: > >> > >> $ Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix > >> [1] "/Library/Frameworks/R.framework/Resources/bin/exec/R" > >> [2] "--slave" > >> [3] "--no-restore" > >> [4] "--no-save" > >> [5] "--file=MR.R" > >> [6] "--args" > >> [7] "ENSG0154803.ld" > >> [8] "ENSG0154803.matrix" > >> > >> The next line > >> > >> gene <- cmd_args[3] > >> > >> is obviously wrong for my system, because it would set gene to > >> "--no-restore". Your results will probably be somewhat different, but > >> it might be clear what you should use instead of the third element. > >> > >> By the way, changing the first line > >> > >> cmd_args=commandArgs() > >> > >> to > >> > >> cmd_args <- commandArgs(TRUE) > >> > >> makes a lot of sense in most cases. I haven't read your whole script so > >> I don't know it it makes sense for you. > >> > >> Duncan Murdoch > >> > >> > >>> Please advise, > >>> Ana > >>> > >>> On Sat, Nov 23, 2019 at 4:16 AM Ben Tupper wrote: > > Hi, > > I think you want this order... > > Rscript [options for R] script_file.R argument_1 argument_2 ... > > So, like this ... > > Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix > > Cheers, > Ben > > On Fri, Nov 22, 2019 at 8:59 PM Ana Marija > wrote: > > > > HI Ben, > > > > thank you so much , I did this: > > > > Rscript --no-save ENSG0154803.ld ENSG0154803.matrix MR.R > > Error: unexpected numeric constant in "1.000 0.089" > > Execution halted > > > > I made ENSG0154803.ld with: > > library(MASS) > > write.matrix(ENSG0154803.ld, file="ENSG0154803.ld") > > > > and it looks like this: > > > > 1.000 0.089 0.006 0.038 0.012 0.014 0.003 0.001 0.005 0.015 0.013 > > 0.000 0.000 0.000 0.001 0.003 0.000 > > 0.089 1.000 0.002 0.007 0.005 0.001 0.004 0.005 0.000 0.003 0.014 > > 0.001 0.012 0.005 0.000 0.004 0.004 > > 0.006 0.002 1.000 0.004 0.008 0.029 0.040 0.001 0.001 0.006 0.013 > > 0.054 0.006 0.002 0.010 0.001 0.000 > > 0.038 0.007 0.004 1.000 0.460 0.044 0.008 0.022 0.010 0.229 0.095 > > 0.066 0.010 0.030 0.001 0.003 0.000 > > 0.012 0.005 0.008 0.460 1.000 0.151 0.018 0.047 0.021 0.272 0.185 > > 0.002 0.003 0.066 0.006 0.004 0.004 > > 0.014 0.001 0.029 0.044 0.151 1.000 0.007 0.018 0.218 0.010 0.023 > > 0.016 0.000 0.025 0.000 0.005 0.000 > > 0.003 0.004 0.040 0.008 0.018 0.007 1.000 0.003 0.002 0.020 0.031 > > 0.128 0.019 0.005 0.030 0.002 0.016 > > 0.001 0.005 0.001 0.022 0.047 0.018 0.003 1.000 0.004 0.014 0.004 > > 0.098 0.010 0.012 0.001 0.006 0.003 > > 0.005 0.000 0.001 0.010 0.021 0.218 0.002 0.004 1.000 0.004 0.000 > > 0.012 0.000 0.006 0.018 0.004 0.013 > > 0.015 0.003 0.006 0.229 0.272 0.010 0.020 0.014 0.004 1.000 0.466 >
Re: [R] cannot open file '--no-restore.matrix'
On 23/11/2019 11:05 a.m., Ana Marija wrote: Hi Ben, I am not sure what you mean when you say to print, is it this? cmd_args=commandArgs(TRUE) print(cmd_args) character(0) cmd_args=commandArgs() print(cmd_args) [1] "/software/linux-el7-x86_64/compilers/r-3.6.1/lib64/R/bin/exec/R" I changed in the first line of this script: https://github.com/eleporcu/TWMR/blob/master/MR.R cmd_args=commandArgs() to be cmd_args=commandArgs(TRUE) but again I get the same error: Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix Error in file(file, "rt") : cannot open the connection Calls: read.table -> file In addition: Warning message: In file(file, "rt") : cannot open file 'NA.matrix': No such file or directory Execution halted You didn't put the print(cmd_args) into the script. Duncan Murdoch Please advise, Ana On Sat, Nov 23, 2019 at 9:44 AM Duncan Murdoch wrote: On 23/11/2019 10:26 a.m., Ana Marija wrote: HI Ben, I tried it but it doesn't work: Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix Error in file(file, "rt") : cannot open the connection Calls: read.table -> file In addition: Warning message: In file(file, "rt") : cannot open file '--no-restore.matrix': No such file or directory Execution halted You should print the cmd_args variable that is set on the first line of that script. When I run a script that prints it using your command line, this is what it looks like: $ Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix [1] "/Library/Frameworks/R.framework/Resources/bin/exec/R" [2] "--slave" [3] "--no-restore" [4] "--no-save" [5] "--file=MR.R" [6] "--args" [7] "ENSG0154803.ld" [8] "ENSG0154803.matrix" The next line gene <- cmd_args[3] is obviously wrong for my system, because it would set gene to "--no-restore". Your results will probably be somewhat different, but it might be clear what you should use instead of the third element. By the way, changing the first line cmd_args=commandArgs() to cmd_args <- commandArgs(TRUE) makes a lot of sense in most cases. I haven't read your whole script so I don't know it it makes sense for you. Duncan Murdoch Please advise, Ana On Sat, Nov 23, 2019 at 4:16 AM Ben Tupper wrote: Hi, I think you want this order... Rscript [options for R] script_file.R argument_1 argument_2 ... So, like this ... Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix Cheers, Ben On Fri, Nov 22, 2019 at 8:59 PM Ana Marija wrote: HI Ben, thank you so much , I did this: Rscript --no-save ENSG0154803.ld ENSG0154803.matrix MR.R Error: unexpected numeric constant in "1.000 0.089" Execution halted I made ENSG0154803.ld with: library(MASS) write.matrix(ENSG0154803.ld, file="ENSG0154803.ld") and it looks like this: 1.000 0.089 0.006 0.038 0.012 0.014 0.003 0.001 0.005 0.015 0.013 0.000 0.000 0.000 0.001 0.003 0.000 0.089 1.000 0.002 0.007 0.005 0.001 0.004 0.005 0.000 0.003 0.014 0.001 0.012 0.005 0.000 0.004 0.004 0.006 0.002 1.000 0.004 0.008 0.029 0.040 0.001 0.001 0.006 0.013 0.054 0.006 0.002 0.010 0.001 0.000 0.038 0.007 0.004 1.000 0.460 0.044 0.008 0.022 0.010 0.229 0.095 0.066 0.010 0.030 0.001 0.003 0.000 0.012 0.005 0.008 0.460 1.000 0.151 0.018 0.047 0.021 0.272 0.185 0.002 0.003 0.066 0.006 0.004 0.004 0.014 0.001 0.029 0.044 0.151 1.000 0.007 0.018 0.218 0.010 0.023 0.016 0.000 0.025 0.000 0.005 0.000 0.003 0.004 0.040 0.008 0.018 0.007 1.000 0.003 0.002 0.020 0.031 0.128 0.019 0.005 0.030 0.002 0.016 0.001 0.005 0.001 0.022 0.047 0.018 0.003 1.000 0.004 0.014 0.004 0.098 0.010 0.012 0.001 0.006 0.003 0.005 0.000 0.001 0.010 0.021 0.218 0.002 0.004 1.000 0.004 0.000 0.012 0.000 0.006 0.018 0.004 0.013 0.015 0.003 0.006 0.229 0.272 0.010 0.020 0.014 0.004 1.000 0.466 0.001 0.091 0.057 0.062 0.002 0.005 0.013 0.014 0.013 0.095 0.185 0.023 0.031 0.004 0.000 0.466 1.000 0.238 0.180 0.073 0.058 0.000 0.006 0.000 0.001 0.054 0.066 0.002 0.016 0.128 0.098 0.012 0.001 0.238 1.000 0.158 0.006 0.044 0.006 0.001 0.000 0.012 0.006 0.010 0.003 0.000 0.019 0.010 0.000 0.091 0.180 0.158 1.000 0.077 0.237 0.009 0.000 0.000 0.005 0.002 0.030 0.066 0.025 0.005 0.012 0.006 0.057 0.073 0.006 0.077 1.000 0.056 0.000 0.004 0.001 0.000 0.010 0.001 0.006 0.000 0.030 0.001 0.018 0.062 0.058 0.044 0.237 0.056 1.000 0.000 0.003 0.003 0.004 0.001 0.003 0.004 0.005 0.002 0.006 0.004 0.002 0.000 0.006 0.009 0.000 0.000 1.000 0.002 0.000 0.004 0.000 0.000 0.004 0.000 0.016 0.003 0.013 0.005 0.006 0.001 0.000 0.004 0.003 0.002 1.000 the other file (ENSG0154803.matrix) looks like this: GENES ENSG0154803 BETA_GWAS rs12601631 -0.320577 -0.0160778 rs1708623 0.708706 0.0717719 rs1708628 -0.645996 -0.0973019 rs17804843 -0.78984 0.0059607 rs4078062 -0.340732 -0.0716837 rs4316813 -0.721137 -0.00502219 rs7217764 -0.61641 0.16997 rs7221842 -0.377727 -0.00184011 rs12602831 -0.397059 0.0154625 rs138437542 -0.590669 0.0145733 rs2174369 -0.167913 -0.0268728 rs242252 0.20184
[R] Why does `[<-.matrix` not exist in base R
Whenever going from working with a data.frame to a matrix, I get annoyed that I cannot assign and subset at the same time with matrices - like I can with data.frames. For example, if I want to add a new column to a data.frame, I can do something like `myDataFrame[, "newColumn"] <- NA`. However, with a matrix, this syntax does not work and I have to use a call to `cbind` and create a new object. For example, `mymatrix2 <- cbind(mymatrix, "newColumn" = NA)`. Is there a programming reason that base R does not have a matrix method for `[<-` or is it something that arguably should be added? -- David J. Disabato, Ph.D. Postdoctoral Research Scholar Kent State University ddisa...@gmail.com Email is not a secure form of communication as information and confidentiality cannot be guaranteed. Information provided in an email is not intended to be a professional service. In the case of a crisis or emergency situation, call 911. [[alternative HTML version deleted]] __ R-help@r-project.org 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.
Re: [R] cannot open file '--no-restore.matrix'
Hi Ben, I am not sure what you mean when you say to print, is it this? > cmd_args=commandArgs(TRUE) > print(cmd_args) character(0) > cmd_args=commandArgs() > print(cmd_args) [1] "/software/linux-el7-x86_64/compilers/r-3.6.1/lib64/R/bin/exec/R" I changed in the first line of this script: https://github.com/eleporcu/TWMR/blob/master/MR.R cmd_args=commandArgs() to be cmd_args=commandArgs(TRUE) but again I get the same error: Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix Error in file(file, "rt") : cannot open the connection Calls: read.table -> file In addition: Warning message: In file(file, "rt") : cannot open file 'NA.matrix': No such file or directory Execution halted Please advise, Ana On Sat, Nov 23, 2019 at 9:44 AM Duncan Murdoch wrote: > > On 23/11/2019 10:26 a.m., Ana Marija wrote: > > HI Ben, > > > > I tried it but it doesn't work: > > > > Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix > > Error in file(file, "rt") : cannot open the connection > > Calls: read.table -> file > > In addition: Warning message: > > In file(file, "rt") : > >cannot open file '--no-restore.matrix': No such file or directory > > Execution halted > > > > You should print the cmd_args variable that is set on the first line of > that script. When I run a script that prints it using your command > line, this is what it looks like: > > $ Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix > [1] "/Library/Frameworks/R.framework/Resources/bin/exec/R" > [2] "--slave" > [3] "--no-restore" > [4] "--no-save" > [5] "--file=MR.R" > [6] "--args" > [7] "ENSG0154803.ld" > [8] "ENSG0154803.matrix" > > The next line > > gene <- cmd_args[3] > > is obviously wrong for my system, because it would set gene to > "--no-restore". Your results will probably be somewhat different, but > it might be clear what you should use instead of the third element. > > By the way, changing the first line > > cmd_args=commandArgs() > > to > > cmd_args <- commandArgs(TRUE) > > makes a lot of sense in most cases. I haven't read your whole script so > I don't know it it makes sense for you. > > Duncan Murdoch > > > > Please advise, > > Ana > > > > On Sat, Nov 23, 2019 at 4:16 AM Ben Tupper wrote: > >> > >> Hi, > >> > >> I think you want this order... > >> > >> Rscript [options for R] script_file.R argument_1 argument_2 ... > >> > >> So, like this ... > >> > >> Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix > >> > >> Cheers, > >> Ben > >> > >> On Fri, Nov 22, 2019 at 8:59 PM Ana Marija > >> wrote: > >>> > >>> HI Ben, > >>> > >>> thank you so much , I did this: > >>> > >>> Rscript --no-save ENSG0154803.ld ENSG0154803.matrix MR.R > >>> Error: unexpected numeric constant in "1.000 0.089" > >>> Execution halted > >>> > >>> I made ENSG0154803.ld with: > >>> library(MASS) > >>> write.matrix(ENSG0154803.ld, file="ENSG0154803.ld") > >>> > >>> and it looks like this: > >>> > >>> 1.000 0.089 0.006 0.038 0.012 0.014 0.003 0.001 0.005 0.015 0.013 > >>> 0.000 0.000 0.000 0.001 0.003 0.000 > >>> 0.089 1.000 0.002 0.007 0.005 0.001 0.004 0.005 0.000 0.003 0.014 > >>> 0.001 0.012 0.005 0.000 0.004 0.004 > >>> 0.006 0.002 1.000 0.004 0.008 0.029 0.040 0.001 0.001 0.006 0.013 > >>> 0.054 0.006 0.002 0.010 0.001 0.000 > >>> 0.038 0.007 0.004 1.000 0.460 0.044 0.008 0.022 0.010 0.229 0.095 > >>> 0.066 0.010 0.030 0.001 0.003 0.000 > >>> 0.012 0.005 0.008 0.460 1.000 0.151 0.018 0.047 0.021 0.272 0.185 > >>> 0.002 0.003 0.066 0.006 0.004 0.004 > >>> 0.014 0.001 0.029 0.044 0.151 1.000 0.007 0.018 0.218 0.010 0.023 > >>> 0.016 0.000 0.025 0.000 0.005 0.000 > >>> 0.003 0.004 0.040 0.008 0.018 0.007 1.000 0.003 0.002 0.020 0.031 > >>> 0.128 0.019 0.005 0.030 0.002 0.016 > >>> 0.001 0.005 0.001 0.022 0.047 0.018 0.003 1.000 0.004 0.014 0.004 > >>> 0.098 0.010 0.012 0.001 0.006 0.003 > >>> 0.005 0.000 0.001 0.010 0.021 0.218 0.002 0.004 1.000 0.004 0.000 > >>> 0.012 0.000 0.006 0.018 0.004 0.013 > >>> 0.015 0.003 0.006 0.229 0.272 0.010 0.020 0.014 0.004 1.000 0.466 > >>> 0.001 0.091 0.057 0.062 0.002 0.005 > >>> 0.013 0.014 0.013 0.095 0.185 0.023 0.031 0.004 0.000 0.466 1.000 > >>> 0.238 0.180 0.073 0.058 0.000 0.006 > >>> 0.000 0.001 0.054 0.066 0.002 0.016 0.128 0.098 0.012 0.001 0.238 > >>> 1.000 0.158 0.006 0.044 0.006 0.001 > >>> 0.000 0.012 0.006 0.010 0.003 0.000 0.019 0.010 0.000 0.091 0.180 > >>> 0.158 1.000 0.077 0.237 0.009 0.000 > >>> 0.000 0.005 0.002 0.030 0.066 0.025 0.005 0.012 0.006 0.057 0.073 > >>> 0.006 0.077 1.000 0.056 0.000 0.004 > >>> 0.001 0.000 0.010 0.001 0.006 0.000 0.030 0.001 0.018 0.062 0.058 > >>> 0.044 0.237 0.056 1.000 0.000 0.003 > >>> 0.003 0.004 0.001 0.003 0.004 0.005 0.002 0.006 0.004 0.002 0.000 > >>> 0.006 0.009 0.000 0.000 1.000 0.002 > >>> 0.000 0.004 0.000 0.000 0.004 0.000 0.016 0.003 0.013 0.005 0.006 > >>> 0.001 0.000 0.004 0.003 0.002 1.000 > >>> > >>> the other file (ENSG0154803.matrix) looks like this: > >>> > >>> GENES
Re: [R] cannot open file '--no-restore.matrix'
On 23/11/2019 10:26 a.m., Ana Marija wrote: HI Ben, I tried it but it doesn't work: Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix Error in file(file, "rt") : cannot open the connection Calls: read.table -> file In addition: Warning message: In file(file, "rt") : cannot open file '--no-restore.matrix': No such file or directory Execution halted You should print the cmd_args variable that is set on the first line of that script. When I run a script that prints it using your command line, this is what it looks like: $ Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix [1] "/Library/Frameworks/R.framework/Resources/bin/exec/R" [2] "--slave" [3] "--no-restore" [4] "--no-save" [5] "--file=MR.R" [6] "--args" [7] "ENSG0154803.ld" [8] "ENSG0154803.matrix" The next line gene <- cmd_args[3] is obviously wrong for my system, because it would set gene to "--no-restore". Your results will probably be somewhat different, but it might be clear what you should use instead of the third element. By the way, changing the first line cmd_args=commandArgs() to cmd_args <- commandArgs(TRUE) makes a lot of sense in most cases. I haven't read your whole script so I don't know it it makes sense for you. Duncan Murdoch Please advise, Ana On Sat, Nov 23, 2019 at 4:16 AM Ben Tupper wrote: Hi, I think you want this order... Rscript [options for R] script_file.R argument_1 argument_2 ... So, like this ... Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix Cheers, Ben On Fri, Nov 22, 2019 at 8:59 PM Ana Marija wrote: HI Ben, thank you so much , I did this: Rscript --no-save ENSG0154803.ld ENSG0154803.matrix MR.R Error: unexpected numeric constant in "1.000 0.089" Execution halted I made ENSG0154803.ld with: library(MASS) write.matrix(ENSG0154803.ld, file="ENSG0154803.ld") and it looks like this: 1.000 0.089 0.006 0.038 0.012 0.014 0.003 0.001 0.005 0.015 0.013 0.000 0.000 0.000 0.001 0.003 0.000 0.089 1.000 0.002 0.007 0.005 0.001 0.004 0.005 0.000 0.003 0.014 0.001 0.012 0.005 0.000 0.004 0.004 0.006 0.002 1.000 0.004 0.008 0.029 0.040 0.001 0.001 0.006 0.013 0.054 0.006 0.002 0.010 0.001 0.000 0.038 0.007 0.004 1.000 0.460 0.044 0.008 0.022 0.010 0.229 0.095 0.066 0.010 0.030 0.001 0.003 0.000 0.012 0.005 0.008 0.460 1.000 0.151 0.018 0.047 0.021 0.272 0.185 0.002 0.003 0.066 0.006 0.004 0.004 0.014 0.001 0.029 0.044 0.151 1.000 0.007 0.018 0.218 0.010 0.023 0.016 0.000 0.025 0.000 0.005 0.000 0.003 0.004 0.040 0.008 0.018 0.007 1.000 0.003 0.002 0.020 0.031 0.128 0.019 0.005 0.030 0.002 0.016 0.001 0.005 0.001 0.022 0.047 0.018 0.003 1.000 0.004 0.014 0.004 0.098 0.010 0.012 0.001 0.006 0.003 0.005 0.000 0.001 0.010 0.021 0.218 0.002 0.004 1.000 0.004 0.000 0.012 0.000 0.006 0.018 0.004 0.013 0.015 0.003 0.006 0.229 0.272 0.010 0.020 0.014 0.004 1.000 0.466 0.001 0.091 0.057 0.062 0.002 0.005 0.013 0.014 0.013 0.095 0.185 0.023 0.031 0.004 0.000 0.466 1.000 0.238 0.180 0.073 0.058 0.000 0.006 0.000 0.001 0.054 0.066 0.002 0.016 0.128 0.098 0.012 0.001 0.238 1.000 0.158 0.006 0.044 0.006 0.001 0.000 0.012 0.006 0.010 0.003 0.000 0.019 0.010 0.000 0.091 0.180 0.158 1.000 0.077 0.237 0.009 0.000 0.000 0.005 0.002 0.030 0.066 0.025 0.005 0.012 0.006 0.057 0.073 0.006 0.077 1.000 0.056 0.000 0.004 0.001 0.000 0.010 0.001 0.006 0.000 0.030 0.001 0.018 0.062 0.058 0.044 0.237 0.056 1.000 0.000 0.003 0.003 0.004 0.001 0.003 0.004 0.005 0.002 0.006 0.004 0.002 0.000 0.006 0.009 0.000 0.000 1.000 0.002 0.000 0.004 0.000 0.000 0.004 0.000 0.016 0.003 0.013 0.005 0.006 0.001 0.000 0.004 0.003 0.002 1.000 the other file (ENSG0154803.matrix) looks like this: GENES ENSG0154803 BETA_GWAS rs12601631 -0.320577 -0.0160778 rs1708623 0.708706 0.0717719 rs1708628 -0.645996 -0.0973019 rs17804843 -0.78984 0.0059607 rs4078062 -0.340732 -0.0716837 rs4316813 -0.721137 -0.00502219 rs7217764 -0.61641 0.16997 rs7221842 -0.377727 -0.00184011 rs12602831 -0.397059 0.0154625 rs138437542 -0.590669 0.0145733 rs2174369 -0.167913 -0.0268728 rs242252 0.20184 0.0161709 rs34121330 0.328602 0.0753894 rs4792798 -0.303601 0.00227314 rs7222311 -0.367686 -0.0419168 rs74369938 0.687555 -0.223105 rs8075751 -0.261916 -0.0313484 On Fri, Nov 22, 2019 at 7:44 PM Ben Tupper wrote: Hi, You might check the order of your arguments. Options come before the script filename. See the details here... https://www.rdocumentation.org/packages/utils/versions/3.6.1/topics/Rscript Ben On Fri, Nov 22, 2019 at 8:17 PM Ana Marija wrote: Hello, I am trying to run this code: https://github.com/eleporcu/TWMR/blob/master/MR.R with r-3.6.1 via: Rscript MR.R --no-save ENSG0154803 in the current directory I have saved: ENSG0154803.ld and ENSG0154803.matrix as the software requires but I am getting this error: Error in file(file, "rt") : cannot open the connection Calls: read.table -> file In addition: Warning message: In file(file, "rt") :
Re: [R] cannot open file '--no-restore.matrix'
HI Ben, I tried it but it doesn't work: Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix Error in file(file, "rt") : cannot open the connection Calls: read.table -> file In addition: Warning message: In file(file, "rt") : cannot open file '--no-restore.matrix': No such file or directory Execution halted Please advise, Ana On Sat, Nov 23, 2019 at 4:16 AM Ben Tupper wrote: > > Hi, > > I think you want this order... > > Rscript [options for R] script_file.R argument_1 argument_2 ... > > So, like this ... > > Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix > > Cheers, > Ben > > On Fri, Nov 22, 2019 at 8:59 PM Ana Marija > wrote: > > > > HI Ben, > > > > thank you so much , I did this: > > > > Rscript --no-save ENSG0154803.ld ENSG0154803.matrix MR.R > > Error: unexpected numeric constant in "1.000 0.089" > > Execution halted > > > > I made ENSG0154803.ld with: > > library(MASS) > > write.matrix(ENSG0154803.ld, file="ENSG0154803.ld") > > > > and it looks like this: > > > > 1.000 0.089 0.006 0.038 0.012 0.014 0.003 0.001 0.005 0.015 0.013 > > 0.000 0.000 0.000 0.001 0.003 0.000 > > 0.089 1.000 0.002 0.007 0.005 0.001 0.004 0.005 0.000 0.003 0.014 > > 0.001 0.012 0.005 0.000 0.004 0.004 > > 0.006 0.002 1.000 0.004 0.008 0.029 0.040 0.001 0.001 0.006 0.013 > > 0.054 0.006 0.002 0.010 0.001 0.000 > > 0.038 0.007 0.004 1.000 0.460 0.044 0.008 0.022 0.010 0.229 0.095 > > 0.066 0.010 0.030 0.001 0.003 0.000 > > 0.012 0.005 0.008 0.460 1.000 0.151 0.018 0.047 0.021 0.272 0.185 > > 0.002 0.003 0.066 0.006 0.004 0.004 > > 0.014 0.001 0.029 0.044 0.151 1.000 0.007 0.018 0.218 0.010 0.023 > > 0.016 0.000 0.025 0.000 0.005 0.000 > > 0.003 0.004 0.040 0.008 0.018 0.007 1.000 0.003 0.002 0.020 0.031 > > 0.128 0.019 0.005 0.030 0.002 0.016 > > 0.001 0.005 0.001 0.022 0.047 0.018 0.003 1.000 0.004 0.014 0.004 > > 0.098 0.010 0.012 0.001 0.006 0.003 > > 0.005 0.000 0.001 0.010 0.021 0.218 0.002 0.004 1.000 0.004 0.000 > > 0.012 0.000 0.006 0.018 0.004 0.013 > > 0.015 0.003 0.006 0.229 0.272 0.010 0.020 0.014 0.004 1.000 0.466 > > 0.001 0.091 0.057 0.062 0.002 0.005 > > 0.013 0.014 0.013 0.095 0.185 0.023 0.031 0.004 0.000 0.466 1.000 > > 0.238 0.180 0.073 0.058 0.000 0.006 > > 0.000 0.001 0.054 0.066 0.002 0.016 0.128 0.098 0.012 0.001 0.238 > > 1.000 0.158 0.006 0.044 0.006 0.001 > > 0.000 0.012 0.006 0.010 0.003 0.000 0.019 0.010 0.000 0.091 0.180 > > 0.158 1.000 0.077 0.237 0.009 0.000 > > 0.000 0.005 0.002 0.030 0.066 0.025 0.005 0.012 0.006 0.057 0.073 > > 0.006 0.077 1.000 0.056 0.000 0.004 > > 0.001 0.000 0.010 0.001 0.006 0.000 0.030 0.001 0.018 0.062 0.058 > > 0.044 0.237 0.056 1.000 0.000 0.003 > > 0.003 0.004 0.001 0.003 0.004 0.005 0.002 0.006 0.004 0.002 0.000 > > 0.006 0.009 0.000 0.000 1.000 0.002 > > 0.000 0.004 0.000 0.000 0.004 0.000 0.016 0.003 0.013 0.005 0.006 > > 0.001 0.000 0.004 0.003 0.002 1.000 > > > > the other file (ENSG0154803.matrix) looks like this: > > > > GENES ENSG0154803 BETA_GWAS > > rs12601631 -0.320577 -0.0160778 > > rs1708623 0.708706 0.0717719 > > rs1708628 -0.645996 -0.0973019 > > rs17804843 -0.78984 0.0059607 > > rs4078062 -0.340732 -0.0716837 > > rs4316813 -0.721137 -0.00502219 > > rs7217764 -0.61641 0.16997 > > rs7221842 -0.377727 -0.00184011 > > rs12602831 -0.397059 0.0154625 > > rs138437542 -0.590669 0.0145733 > > rs2174369 -0.167913 -0.0268728 > > rs242252 0.20184 0.0161709 > > rs34121330 0.328602 0.0753894 > > rs4792798 -0.303601 0.00227314 > > rs7222311 -0.367686 -0.0419168 > > rs74369938 0.687555 -0.223105 > > rs8075751 -0.261916 -0.0313484 > > > > On Fri, Nov 22, 2019 at 7:44 PM Ben Tupper wrote: > > > > > > Hi, > > > > > > You might check the order of your arguments. Options come before the > > > script filename. See the details here... > > > > > > https://www.rdocumentation.org/packages/utils/versions/3.6.1/topics/Rscript > > > > > > Ben > > > > > > On Fri, Nov 22, 2019 at 8:17 PM Ana Marija > > > wrote: > > > > > > > > Hello, > > > > > > > > I am trying to run this code: > > > > https://github.com/eleporcu/TWMR/blob/master/MR.R > > > > > > > > with r-3.6.1 > > > > > > > > via: > > > > > > > > Rscript MR.R --no-save ENSG0154803 > > > > > > > > in the current directory I have saved: ENSG0154803.ld and > > > > ENSG0154803.matrix as the software requires > > > > > > > > but I am getting this error: > > > > > > > > Error in file(file, "rt") : cannot open the connection > > > > Calls: read.table -> file > > > > In addition: Warning message: > > > > In file(file, "rt") : > > > > cannot open file '--no-restore.matrix': No such file or directory > > > > Execution halted > > > > > > > > > > > > Please advise, > > > > > > > > Thanks > > > > Ana > > > > > > > > __ > > > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > > > https://stat.ethz.ch/mailman/listinfo/r-help > > > > PLEASE do read the posting guide > > > >
Re: [R-es] pawer law
Hola, Una forma de hacerlo es esta: #- > my_pol <- function( n = 100, grad_ini = 1, grad_end = 5) { + val_rnd <- rnorm(n) + df <- data.frame(c(0)) + for( i in grad_ini:grad_end) { +df_tmp <- as.data.frame(val_rnd^i) +df <- cbind(df, df_tmp) + } + df <- df[ , 2:ncol(df)] + names(df) <- paste("V_", grad_ini:grad_end, sep = "") + return(df) + } > > df_out <- my_pol(10, 3, 8) > head(df_out) V_3 V_4 V_5 V_6 V_7 V_8 1 -2.152566721 2.7793431004 -3.588622e+00 4.633543e+00 -5.982721e+00 7.724748e+00 2 -3.848810314 6.0316390414 -9.452445e+00 1.481334e+01 -2.321463e+01 3.638067e+01 3 0.681408379 0.5996207120 5.276498e-01 4.643174e-01 4.085866e-01 3.595450e-01 4 -0.003075413 0.0004472372 -6.503878e-05 9.458164e-06 -1.375439e-06 2.000211e-07 5 -0.620395129 0.5291244605 -4.512813e-01 3.848901e-01 -3.282662e-01 2.799727e-01 6 0.023210872 0.0066209750 1.888654e-03 5.387446e-04 1.536786e-04 4.383731e-05 #- "caret" tiene un par de funciones "SLC14_1()" y "SLC14_2" con las que puedes generar dataframes con diferentes variables correladas entre ellas, te sugiero que las veas por si además de esta función que te incluyo, te ayuda en otros posibles casos. Gracias, Carlos Ortega www.qualityexcellence.es El sáb., 23 nov. 2019 a las 12:11, Manuel Mendoza (< mmend...@fulbrightmail.org>) escribió: > Buenos días erreros, ¿sabe alguien cómo generar una df cuyas variables > sigan una ley de potencias? > Gracias > > [[alternative HTML version deleted]] > > ___ > R-help-es mailing list > R-help-es@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-help-es > -- Saludos, Carlos Ortega www.qualityexcellence.es [[alternative HTML version deleted]] ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es
[R] giving priority to stats package
library and require have new args in 3.6 giving additional control over conflicts. This seems very useful but I was wondering if there were some, preferabley simple, way to give existing loaded packages priority without knowing the actual conflicts in advance. For example library(dplyr, exclude = c("filter", "lag")) works to avoid masking those names in stats that would otherwise be masked by that package but I had to know in advance that filter and lag were the conflicting names. -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@r-project.org 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.
[R-es] pawer law
Buenos días erreros, ¿sabe alguien cómo generar una df cuyas variables sigan una ley de potencias? Gracias [[alternative HTML version deleted]] ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es
Re: [R] cannot open file '--no-restore.matrix'
Hi, I think you want this order... Rscript [options for R] script_file.R argument_1 argument_2 ... So, like this ... Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix Cheers, Ben On Fri, Nov 22, 2019 at 8:59 PM Ana Marija wrote: > > HI Ben, > > thank you so much , I did this: > > Rscript --no-save ENSG0154803.ld ENSG0154803.matrix MR.R > Error: unexpected numeric constant in "1.000 0.089" > Execution halted > > I made ENSG0154803.ld with: > library(MASS) > write.matrix(ENSG0154803.ld, file="ENSG0154803.ld") > > and it looks like this: > > 1.000 0.089 0.006 0.038 0.012 0.014 0.003 0.001 0.005 0.015 0.013 > 0.000 0.000 0.000 0.001 0.003 0.000 > 0.089 1.000 0.002 0.007 0.005 0.001 0.004 0.005 0.000 0.003 0.014 > 0.001 0.012 0.005 0.000 0.004 0.004 > 0.006 0.002 1.000 0.004 0.008 0.029 0.040 0.001 0.001 0.006 0.013 > 0.054 0.006 0.002 0.010 0.001 0.000 > 0.038 0.007 0.004 1.000 0.460 0.044 0.008 0.022 0.010 0.229 0.095 > 0.066 0.010 0.030 0.001 0.003 0.000 > 0.012 0.005 0.008 0.460 1.000 0.151 0.018 0.047 0.021 0.272 0.185 > 0.002 0.003 0.066 0.006 0.004 0.004 > 0.014 0.001 0.029 0.044 0.151 1.000 0.007 0.018 0.218 0.010 0.023 > 0.016 0.000 0.025 0.000 0.005 0.000 > 0.003 0.004 0.040 0.008 0.018 0.007 1.000 0.003 0.002 0.020 0.031 > 0.128 0.019 0.005 0.030 0.002 0.016 > 0.001 0.005 0.001 0.022 0.047 0.018 0.003 1.000 0.004 0.014 0.004 > 0.098 0.010 0.012 0.001 0.006 0.003 > 0.005 0.000 0.001 0.010 0.021 0.218 0.002 0.004 1.000 0.004 0.000 > 0.012 0.000 0.006 0.018 0.004 0.013 > 0.015 0.003 0.006 0.229 0.272 0.010 0.020 0.014 0.004 1.000 0.466 > 0.001 0.091 0.057 0.062 0.002 0.005 > 0.013 0.014 0.013 0.095 0.185 0.023 0.031 0.004 0.000 0.466 1.000 > 0.238 0.180 0.073 0.058 0.000 0.006 > 0.000 0.001 0.054 0.066 0.002 0.016 0.128 0.098 0.012 0.001 0.238 > 1.000 0.158 0.006 0.044 0.006 0.001 > 0.000 0.012 0.006 0.010 0.003 0.000 0.019 0.010 0.000 0.091 0.180 > 0.158 1.000 0.077 0.237 0.009 0.000 > 0.000 0.005 0.002 0.030 0.066 0.025 0.005 0.012 0.006 0.057 0.073 > 0.006 0.077 1.000 0.056 0.000 0.004 > 0.001 0.000 0.010 0.001 0.006 0.000 0.030 0.001 0.018 0.062 0.058 > 0.044 0.237 0.056 1.000 0.000 0.003 > 0.003 0.004 0.001 0.003 0.004 0.005 0.002 0.006 0.004 0.002 0.000 > 0.006 0.009 0.000 0.000 1.000 0.002 > 0.000 0.004 0.000 0.000 0.004 0.000 0.016 0.003 0.013 0.005 0.006 > 0.001 0.000 0.004 0.003 0.002 1.000 > > the other file (ENSG0154803.matrix) looks like this: > > GENES ENSG0154803 BETA_GWAS > rs12601631 -0.320577 -0.0160778 > rs1708623 0.708706 0.0717719 > rs1708628 -0.645996 -0.0973019 > rs17804843 -0.78984 0.0059607 > rs4078062 -0.340732 -0.0716837 > rs4316813 -0.721137 -0.00502219 > rs7217764 -0.61641 0.16997 > rs7221842 -0.377727 -0.00184011 > rs12602831 -0.397059 0.0154625 > rs138437542 -0.590669 0.0145733 > rs2174369 -0.167913 -0.0268728 > rs242252 0.20184 0.0161709 > rs34121330 0.328602 0.0753894 > rs4792798 -0.303601 0.00227314 > rs7222311 -0.367686 -0.0419168 > rs74369938 0.687555 -0.223105 > rs8075751 -0.261916 -0.0313484 > > On Fri, Nov 22, 2019 at 7:44 PM Ben Tupper wrote: > > > > Hi, > > > > You might check the order of your arguments. Options come before the > > script filename. See the details here... > > > > https://www.rdocumentation.org/packages/utils/versions/3.6.1/topics/Rscript > > > > Ben > > > > On Fri, Nov 22, 2019 at 8:17 PM Ana Marija > > wrote: > > > > > > Hello, > > > > > > I am trying to run this code: > > > https://github.com/eleporcu/TWMR/blob/master/MR.R > > > > > > with r-3.6.1 > > > > > > via: > > > > > > Rscript MR.R --no-save ENSG0154803 > > > > > > in the current directory I have saved: ENSG0154803.ld and > > > ENSG0154803.matrix as the software requires > > > > > > but I am getting this error: > > > > > > Error in file(file, "rt") : cannot open the connection > > > Calls: read.table -> file > > > In addition: Warning message: > > > In file(file, "rt") : > > > cannot open file '--no-restore.matrix': No such file or directory > > > Execution halted > > > > > > > > > Please advise, > > > > > > Thanks > > > Ana > > > > > > __ > > > R-help@r-project.org 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. > > > > > > > > -- > > Ben Tupper > > Bigelow Laboratory for Ocean Science > > West Boothbay Harbor, Maine > > http://www.bigelow.org/ > > https://eco.bigelow.org -- Ben Tupper Bigelow Laboratory for Ocean Science West Boothbay Harbor, Maine http://www.bigelow.org/ https://eco.bigelow.org __ R-help@r-project.org 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,
[R-es] Error in plot.new() : figure margins too large.
Olvidadlo, me había equivocado al hacer la matriz. [[alternative HTML version deleted]] ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es