Question: How to read a ".ld.bin" file produced by PLINK
1
gravatar for andreagarcia871
21 months ago by
andreagarcia87160 wrote:

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?

ld plink R • 704 views
ADD COMMENTlink modified 12 days ago by lenore.pipes20 • written 21 months ago by andreagarcia87160
0
gravatar for zx8754
21 months ago by
zx87549.0k
London
zx87549.0k wrote:

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.

ADD COMMENTlink modified 21 months ago • written 21 months ago by zx87549.0k
0
gravatar for lenore.pipes
12 days ago by
lenore.pipes20
UC-Berkeley
lenore.pipes20 wrote:

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")
ldMatrix <- readBin(myFile,what="double",endian="little",size=8,n=number_of_entries)
close(myFile)
ADD COMMENTlink written 12 days ago by lenore.pipes20
1

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

ADD REPLYlink written 12 days ago by chrchang5236.5k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1502 users visited in the last hour