2
1
Entering edit mode
3.4 years ago

I have a .ld.bin file produced by PLINK (cannot remember now how it was produced) which I want to plot. This .bin file is about 160Mbytes so I guess it could be really bigger if uncompressed as .ld (I have read that .ld format is just a table).

I cannot find any documentation in PLINK website about .bin file variant. However I found an R function which could help here:

ldMatrix <- readBin("myfile-chr25.ld.bin", what = "raw")


Although the function doesn't fail, generates an empty "what" object. The what parameter didn't worked for any of the supported types: int, numeric, character, etc. The UNIX file command just returns "data".

Any idea?

PLINK LD R • 1.5k views
0
Entering edit mode
3.4 years ago
zx8754 10k

First argument of readBin is con, connection object, not a filename string. Try:

myFile <- file("myfile-chr25.ld.bin", "rb")
ldMatrix <- readBin(myFile, what = "raw")
close(myFile)


Not sure about "raw" bit. Here is a good tutorial on how to read write files with column names.

0
Entering edit mode
20 months ago
lenore.pipes ▴ 20

I'm not sure why this isn't documented better. But this is what I tried. number_of_entries = p^2 for a p x p matrix

myFile <- file("myfile-chr25.ld.bin","rb")
close(myFile)

1
Entering edit mode

I have added a link under the .ld file format documentation to a sample readBin() call; let me know if this is still insufficient.