| Title: | Read BCOR Files into R |
|---|---|
| Description: | Reads binary correlation (BCOR) files generated by LDStore into R's sparse matrix format. BCOR files store linkage disequilibrium correlation matrices in a compressed binary format. |
| Authors: | Masahiro Kanai [aut, cre] |
| Maintainer: | Masahiro Kanai <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.0.0 |
| Built: | 2026-06-04 07:29:03 UTC |
| Source: | https://github.com/mkanai/rbcor |
Print bcor Object
## S3 method for class 'bcor' print(x, ...)## S3 method for class 'bcor' print(x, ...)
x |
A bcor object |
... |
Additional arguments (ignored) |
Opens a BCOR (binary correlation) file and returns a bcor object. Supports both standard BCOR format (magic: "bcor1.1") and extended format (magic: "bcor1.x") which stores diagonal values explicitly.
read_bcor(filename, read_header = TRUE, packed_threshold = 1000)read_bcor(filename, read_header = TRUE, packed_threshold = 1000)
filename |
Path to the BCOR file |
read_header |
Whether to read the header and metadata immediately (default: TRUE) |
packed_threshold |
Size threshold for using packed symmetric matrices (default: 1000) |
A bcor object containing:
ptr: External pointer to the C++ bcor object
filename: Path to the BCOR file
nSNPs: Number of SNPs in the file
nSamples: Number of samples used to compute correlations
is_extended: Whether the file uses extended format with diagonal values
## Not run: bcor <- read_bcor("path/to/file.bcor") # Access metadata meta <- bcor$get_meta() # Read full correlation matrix corr_full <- bcor$read_corr() # Read subset of correlations corr_subset <- bcor$read_corr(snps = c(1, 10, 20)) # Read rectangular submatrix corr_rect <- bcor$read_corr(snps = 1:10, snps2 = 11:20) # Read sparse matrix with threshold corr_sparse <- bcor$read_corr(snps = 1:100, sparse = TRUE, threshold = 0.1) # Read packed symmetric matrix (memory efficient for large matrices) corr_packed <- bcor$read_corr(packed = TRUE) # Get diagonal values (useful for extended format files) diag_vals <- bcor$get_diagonal() ## End(Not run)## Not run: bcor <- read_bcor("path/to/file.bcor") # Access metadata meta <- bcor$get_meta() # Read full correlation matrix corr_full <- bcor$read_corr() # Read subset of correlations corr_subset <- bcor$read_corr(snps = c(1, 10, 20)) # Read rectangular submatrix corr_rect <- bcor$read_corr(snps = 1:10, snps2 = 11:20) # Read sparse matrix with threshold corr_sparse <- bcor$read_corr(snps = 1:100, sparse = TRUE, threshold = 0.1) # Read packed symmetric matrix (memory efficient for large matrices) corr_packed <- bcor$read_corr(packed = TRUE) # Get diagonal values (useful for extended format files) diag_vals <- bcor$get_diagonal() ## End(Not run)