Title: | Auxiliary Package for Package 'CollapsABEL' |
---|---|
Description: | Provides some low level functions for processing PLINK input and output files. |
Authors: | Kaiyin Zhong, Fan Liu |
Maintainer: | Kaiyin Zhong <[email protected]> |
License: | GPL-3 |
Version: | 1.0.5 |
Built: | 2024-11-20 06:33:15 UTC |
Source: | CRAN |
This package includes some low level functions for processing PLINK input and output files written in Java or C++. Normally you shouldn't need to directly use functions from this package.
Package: | collUtils |
Type: | Package |
Version: | 1.0 |
Date: | 2015-06-12 |
License: | GPL-3 |
Kaiyin Zhong Maintainer: Kaiyin Zhong <[email protected]>
To be updated.
## Not run: require(collUtils) rbed_obj = rBed("test.bed") geno = rbed_obj$readBed() geno = getJArray(geno) print(geno) fn = tempfile() f = file(fn, "wb") writeBin("a", f) writeBin("b", f) writeBin("c", f) close(f) file.info(fn)$size == 6 truncateEndOfFile(fn, 1) ## End(Not run)
## Not run: require(collUtils) rbed_obj = rBed("test.bed") geno = rbed_obj$readBed() geno = getJArray(geno) print(geno) fn = tempfile() f = file(fn, "wb") writeBin("a", f) writeBin("b", f) writeBin("c", f) close(f) file.info(fn)$size == 6 truncateEndOfFile(fn, 1) ## End(Not run)
Count the number of lines in a file
countlines(fn)
countlines(fn)
fn |
Input filepath |
A integer for the number of lines
A thin wrapper around rJava::.jevalArray
getJArray(mat_ref, na_vals = -9)
getJArray(mat_ref, na_vals = -9)
mat_ref |
Reference object of the Java array |
na_vals |
NA code. Default to -9. |
Kaiyin Zhong
Counts the number of columns of whitespace delimited file.
ncols(fn)
ncols(fn)
fn |
Input filepath |
A integer for the number of columns
Wrapper for constructor of Bed class
rBed(bed_path, bytes_snp = NULL, nindiv = NULL)
rBed(bed_path, bytes_snp = NULL, nindiv = NULL)
bed_path |
character. Path to bed file. |
bytes_snp |
integer. Bytes per SNP. |
nindiv |
integer. Number of individuals. |
jobjRef object.
Kaiyin Zhong
## do not run # rbed_obj = rBed("test.bed") # geno = rbed_obj$readBed() # geno = getJArray(geno) # print(geno)
## do not run # rbed_obj = rBed("test.bed") # geno = rbed_obj$readBed() # geno = getJArray(geno) # print(geno)
Read one column of a whitespace delimited text file
readcol(fileName, colNum, nSkip, maxRowNum)
readcol(fileName, colNum, nSkip, maxRowNum)
fileName |
Input filepath |
colNum |
An integer. The target column number |
nSkip |
An integer. Number of lines to skip in the beginning. |
maxRowNum |
An Integer. Maximum number of lines to read |
A vector of strings containing the target column
Read columns of a whitespace delimited text file
readcols(fn, colsel, nFirstSkipLines, nSkipUnit)
readcols(fn, colsel, nFirstSkipLines, nSkipUnit)
fn |
input filepath |
colsel |
a vector of target column numbers |
nFirstSkipLines |
Integer. Number of lines to skip in the beginning |
nSkipUnit |
Integer M. Let the function read one line out of every M |
A matrix of strings from selected columns
Truncate n bytes from end of file
truncateEndOfFile(filename, len)
truncateEndOfFile(filename, len)
filename |
character. Filename. |
len |
numeric. Number of bytes to truncate |
Kaiyin Zhong
## Not run: fn = tempfile() f = file(fn, "wb") writeBin("a", f) writeBin("b", f) writeBin("c", f) close(f) file.info(fn)$size == 6 truncateEndOfFile(fn, 1) file.info(fn)$size == 5 ## End(Not run)
## Not run: fn = tempfile() f = file(fn, "wb") writeBin("a", f) writeBin("b", f) writeBin("c", f) close(f) file.info(fn)$size == 6 truncateEndOfFile(fn, 1) file.info(fn)$size == 5 ## End(Not run)