Write_binary_file: Write a binary file from cell/variable matrix used as input...

Description Usage Arguments Details Examples

Description

Write a binary file.
Input: cell/variable matrix.
Output: binary file (.dat) with nrows (integer), ncols (integer) and row by row data (double).

Usage

1
Write_binary_file(matrix, path.to.bin.file)

Arguments

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)

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.

Examples

 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)
  }

schwikowskilab/rNetSNE documentation built on May 4, 2019, 6:40 p.m.