Description Usage Arguments Details Examples
Write a binary file.
Input: cell/variable matrix.
Output: binary file (.dat) with nrows (integer), ncols (integer) and row by row data (double).
1 | Write_binary_file(matrix, path.to.bin.file)
|
matrix |
Matrix; Where rows are individuals/cells and columns are genes/variables/features |
path.to.bin.file |
Character: The path to save the output binary file (see Details) |
If the matrix is sparce, it should work (at least with "dgCMatrix").
The path to the save the output file (path.to.bin.file) must be of the form "Documents/MyProject/Matrix.dat". "Documents/MyProject" must exist, while "Matrix.dat" is the name of the file to be created and thefore should not exist.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (matrix, path.to.bin.file)
{
connection = file(path.to.bin.file, "wb")
rownames(matrix) = NULL
colnames(matrix) = NULL
writeBin(as.integer(dim(matrix)), connection)
for (i in 1:nrow(matrix)) {
writeBin(as.double(matrix[i, ]), connection)
}
close(connection)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.