You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Could I please ask if you might be able to share an R code snippet for how to use the beachmat package to read this data into a sparse matrix (dgCMatrix)?
The text was updated successfully, but these errors were encountered:
beachmat provides an API for reading from (and writing to) R matrices from within C++ code inside R packages, typically via Rcpp. The intended application is that you already have your matrix or matrix-like object in R and you want to perform some computation on its columns or rows in C++. In this case, one would write C++ code that links to beachmat's headers in order to ensure that the C++ code works for any matrix representation, e.g., ordinary, sparse, file-backed, and so on.
beachmat is not directly designed for I/O between R and the file system. One might say that it operates between C++ and the file system, but that's only for file-backed matrices like HDF5Matrix objects. So, the technically correct answer to your question would be to create a DelayedArray backend that reads from the TSV file, which would then be used by beachmat to read rows (and columns, though that's much harder here) on demand in any C++ code that links to beachmat.
Probably the more useful answer to your question is to use scater::readSparseCounts to read it in as a sparse matrix. Note that dgCMatrix objects do not support more than .Machine$integer.max non-zero observations, so YMMV.
Suppose we have a matrix of single-cell RNA-seq data that looks like this:
Rows:
Columns:
Could I please ask if you might be able to share an R code snippet for how to use the beachmat package to read this data into a sparse matrix (
dgCMatrix
)?The text was updated successfully, but these errors were encountered: