sritchie73 / liftOverPlink

A wrapper for liftOver for converting plink genotype data between different genome reference builds
GNU General Public License v2.0
48 stars 22 forks source link

ValueError: too many values to unpack #7

Closed privefl closed 5 years ago

privefl commented 5 years ago

To reproduce in R:

download.file("https://raw.githubusercontent.com/sritchie73/liftOverPlink/master/liftOverPlink.py",
              destfile = (liftOverPlink <- tempfile(fileext = ".py")))
Sys.chmod(liftOverPlink, mode = (file.info(liftOverPlink)$mode | "111"))
system(liftOverPlink)

download.file("ftp://hgdownload.cse.ucsc.edu/goldenPath/hg19/liftOver/hg19ToHg18.over.chain.gz", 
              destfile = (chain <- tempfile(fileext = ".over.chain.gz")))

download.file("http://hgdownload.cse.ucsc.edu/admin/exe/linux.x86_64/liftOver",
              destfile = (liftOver <- tempfile()))
Sys.chmod(liftOver, mode = (file.info(liftOver)$mode | "111"))
system(liftOver)

download.file("https://raw.githubusercontent.com/gabraham/flashpca/master/HapMap3/data.bim",
              destfile = (map <- tempfile(fileext = ".map")))

system(glue::glue(
  "python {liftOverPlink} --map {map} --out lifted --chain {chain} --bin {liftOver}"))
# Converting MAP file to UCSC BED file...
# Traceback (most recent call last):
#   File "/tmp/RtmpvNn7Lv/file64416daa6283.py", line 160, in <module>
#     makesure(map2bed(args.mapFile, oldBed),
#   File "/tmp/RtmpvNn7Lv/file64416daa6283.py", line 42, in map2bed
#     chrom, rs, mdist, pos = ln.split()
# ValueError: too many values to unpack

system("python --version")
# Python 2.7.5
privefl commented 5 years ago

I'm not used to PLINK ped/map files. Apparently, there are only 4 columns in .map files as compared to 6 in .bim files, so doing:

download.file("https://raw.githubusercontent.com/gabraham/flashpca/master/HapMap3/data.bim",
              destfile = (bim <- tempfile(fileext = ".bim")))
bigreadr::fwrite2(bigreadr::fread2(bim, select = 1:4), col.names = FALSE, sep = "\t",
                  file = (map <- tempfile(fileext = ".map")))

solved this problem.