ropensci / rsnps

Wrapper to a number of SNP web APIs
https://docs.ropensci.org/rsnps
Other
52 stars 22 forks source link

fetch_genotypes #22

Closed jaynal83 closed 9 years ago

jaynal83 commented 9 years ago

I was trying to download genotype data from opensnp using fetch_genotypes function. But when I looked at internal code, it skips 15 line by default. Actually there are some files where there is not skips at all. For example: https://opensnp.org/data/6.23andme.5

Thanks

sckott commented 9 years ago

@jaynal83 thanks for this!

I wonder if things have changed, as I think all files used to require skipping 15 lines. Anyway, we'll get it fixed

jaynal83 commented 9 years ago

Thanks for your quick response. I am currently using readLines() to read the file as plain text and then search for # character and then skip automatically, later on converting it to data frame. This is working fine so far.

Here is the code snipped I am using:

y<-readLines("https://opensnp.org/data/1996.23andme.1182",n=-1) y<-y[-which(substr(y,1,1)=="#")] user1996 <- ldply(strsplit(y,"\t"))

sckott commented 9 years ago

Thanks for sharing your code

I updated fetch_genotypes() to be more general, reading the file whether or not there are comment lines at the top. Reinstall devtools::install_github("ropensci/rsnps") and try again, let me know if it works for you.

jaynal83 commented 9 years ago

Thanks for quick update. Yes, it is working.

sckott commented 9 years ago

Good.