Re: [R] How to loop over two files ...

2020-06-22 Thread Ana Marija
Thank you so much as.character(r) indeed resolved the issue! On Sat, Jun 20, 2020 at 3:47 AM Ivan Krylov wrote: > > On Fri, 19 Jun 2020 19:36:41 -0500 > Ana Marija wrote: > > > Error in cat(x, file = file, sep = c(rep.int(sep, ncolumns - 1), > > "\n"), : argument 1 (type 'list') cannot be

Re: [R] How to loop over two files ...

2020-06-20 Thread Rasmus Liland
On 2020-06-20 07:29 -0700, Bert Gunter wrote: > On Fri, Jun 19, 2020 at 11:17 PM Rasmus Liland wrote: > > On 2020-06-19 18:33 -0700, Bert Gunter wrote: > > > Why aren't you posting on the > > > Bioconductor Help forum instead > > > > Perhaps r-sig-genetics@ or r-sig-phylo@? > > genetics is not

Re: [R] How to loop over two files ...

2020-06-20 Thread Bert Gunter
genetics is not genomics. Nor are phylogenies. I still believe Bioc is the right resource. Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Fri, Jun 19, 2020 at

Re: [R] How to loop over two files ...

2020-06-20 Thread Ivan Krylov
On Fri, 19 Jun 2020 19:36:41 -0500 Ana Marija wrote: > Error in cat(x, file = file, sep = c(rep.int(sep, ncolumns - 1), > "\n"), : argument 1 (type 'list') cannot be handled by 'cat' It might be a good idea to try to solve problems like this yourself instead of waiting for hours for someone to

Re: [R] How to loop over two files ...

2020-06-20 Thread Rasmus Liland
Dear Bert, On 2020-06-19 18:33 -0700, Bert Gunter wrote: > All of your torrent of requests for help to > have others do your work for you are about > genomics issues. I am a bioinformatician, I am supposed should know all of these things, GWAS, Le ggplot, etc. ... > Why aren't you posting

Re: [R] How to loop over two files ...

2020-06-19 Thread Bert Gunter
All of your torrent of requests for help to have others do your work for you are about genomics issues. Why aren't you posting on the Bioconductor Help forum instead, where both the expertise and tools for such matters exist? I would characterize your posts here as being largely inappropriate for

Re: [R] How to loop over two files ...

2020-06-19 Thread Ana Marija
unfortunately it complains again: > f1 <- read_tsv("1g", col_names=F) Parsed with column specification: cols( X1 = col_character() ) > f2 <- read_tsv("1n", col_names=F) Parsed with column specification: cols( X1 = col_character() ) > for ( a in rownames(f1) ) { + +for ( b in rownames(f2)

Re: [R] How to loop over two files ...

2020-06-19 Thread Ana Marija
Hi Rasmus, I got those SNPs from two GWAS-es which I run with different phenotypes and I would like to compare weather the top SNPs in both of them are in LD. So 1n.txt and 1g.txt are just top SNPs from those two GWAS-es. Unfortunately https://ldlink.nci.nih.gov/?tab=ldpair works for only two

Re: [R] How to loop over two files ...

2020-06-19 Thread Rasmus Liland
On 2020-06-19 14:34 -0500, Ana Marija wrote: > > I have two files (each has 300 lines)like this: The example looks quite similar to the R example in https://rest.ensembl.org/documentation/info/ld_pairwise_get#ra ... The question becomes: how did you query the 600 variant names in 1g.txt and

Re: [R] How to loop over two files ...

2020-06-19 Thread cpolwart
Sorry - its been a long week! there is a foreach package but I try to avoid extras make your for statements: for ( a in rownames(f1) ) { # a will now be a row number rather than the value, so replace ' a ' in the paste0 with: f1[ a, 1] so ext <- paste0( "/ld/human/pairwise/",

Re: [R] How to loop over two files ...

2020-06-19 Thread Rasmus Liland
Dear other list readers, On 2020-06-19 23:31 +0200, Rasmus Liland wrote: > I have attached my rds here. only Ana recieved this because of a Mailman attachment policy, which also is why my signature was bad ... Best, Rasmus signature.asc Description: PGP signature

Re: [R] How to loop over two files ...

2020-06-19 Thread Ana Marija
I tried it: > library(httr) > library(jsonlite) > library(xml2) > library(readr) > server <- "http://rest.ensembl.org; > f1 <- read_tsv("1g", col_names=F) Parsed with column specification: cols( X1 = col_character() ) > f2 <- read_tsv("1n", col_names=F) Parsed with column specification: cols(

Re: [R] How to loop over two files ...

2020-06-19 Thread cpolwart
Oh - read.text isn't in base! Not sure where is came from (my head mostly!) You may have something that adds it but better to use something that works. So try using: library(readr) f1 <- read_tsv("1g.txt", col.names=F) This will give you a tibble with f1$X1 with the file in it then loop

Re: [R] How to loop over two files ...

2020-06-19 Thread Rasmus Liland
On 2020-06-19 16:07 -0500, Ana Marija wrote: > HI Rasmus, > > I tried it: > > library(base) > > > r <- readRDS(paste0(population.name, ".rds")) > Error in gzfile(file, "rb") : cannot open the connection > In addition: Warning message: > In gzfile(file, "rb") : > cannot open compressed file

Re: [R] How to loop over two files ...

2020-06-19 Thread Ana Marija
HI Rasmus, I tried it: library(base) files <- c("1g.txt", "1n.txt") files <- lapply(files, readLines) server <- "http://rest.ensembl.org; population.name <- "1000GENOMES:phase_3:KHV" ext <- apply(expand.grid(files), 1, function(x) {

Re: [R] How to loop over two files ...

2020-06-19 Thread Ana Marija
Hi, thanks for getting back to me, it is just for my job :) so I tried it: library(httr) library(jsonlite) library(xml2) library(SparkR, lib.loc = c(file.path(Sys.getenv("SPARK_HOME"), "R", "lib"))) sparkR.session(master = "local[*]", sparkConfig = list(spark.driver.memory = "2g")) server <-

Re: [R] How to loop over two files ...

2020-06-19 Thread Rasmus Liland
On 2020-06-19 14:34 -0500, Ana Marija wrote: > > server <- "http://rest.ensembl.org; > ext <- > "/ld/human/pairwise/rs6792369/rs1042779?population_name=1000GENOMES:phase_3:KHV" > > r <- GET(paste(server, ext, sep = ""), content_type("application/json")) > > stop_for_status(r) >

Re: [R] How to loop over two files ...

2020-06-19 Thread cpolwart
so (untested) if you did something like f1 <- read.text("1g.txt") f2 <- read.text("1n.txt") for ( a in as.list(f1) ) { for ( b in as.list(f2) ) { ext <- paste0( "/ld/human/pairwise/", a, "/", b,