0
$\begingroup$

I have barcodes.tsv, genes.tsv and matrix.mtx file from my RNA seq data and I want to generate a scRNA counts files using R. When I tried using the readMM function, it gave me the following error:

Error: cannot allocate vector of size 185.1 Gb. 

This happens even when I run it as a job. How can I generate a combined csv file using R?

Thank you.

$\endgroup$
4
  • 1
    $\begingroup$ Hi and welcome to the site! It is very hard to help without a concrete example to work on. Could you show us a few lines of a couple of your input files and then the output you require from those example lines? That way we can understand what you need better and we can also make sure any solutions we come up with actually work for your data. $\endgroup$
    – terdon
    Aug 21 '19 at 16:47
  • $\begingroup$ Please edit your question to add extra information. Comments are hard to read, easy to miss and can be deleted without warning. $\endgroup$
    – terdon
    Aug 21 '19 at 16:52
  • $\begingroup$ Also posted on biostars: biostars.org/p/395275 $\endgroup$
    – Devon Ryan
    Aug 21 '19 at 18:10
  • 1
    $\begingroup$ Most likely you tried other things with these files and you are not reading a sparse matrix anymore. a good place to start is usually the documentation associated with the software. For cell ranger v3.0 you can find this here. support.10xgenomics.com/single-cell-gene-expression/software/…. If you scroll down you will see a section on how to generate a csv file. Restart with the zipped output of the filtered_feature_bc matrix. If you still get error update your post with code + error $\endgroup$
    – Mack123456
    Aug 21 '19 at 23:15
2
$\begingroup$

I use the DropletUtils package from Bioconductor. Getting counts begins like this:

library(DropletUtils)
filePath <- "path_to_data/raw_feature_bc_matrix/"
singleCellExperiment <- read10xCounts(filePath, col.names = TRUE)
$\endgroup$
0
$\begingroup$

You probably need to load the matrices part by part in order to avoid loading a large size vector. One way is to use features like nlines or skip of the scan() function. Also, this is suggested code by 10xgenomics:

library(Matrix)
matrix_dir = "/opt/sample345/outs/filtered_feature_bc_matrix/"
barcode.path <- paste0(matrix_dir, "barcodes.tsv.gz")
features.path <- paste0(matrix_dir, "features.tsv.gz")
matrix.path <- paste0(matrix_dir, "matrix.mtx.gz")
mat <- readMM(file = matrix.path)
feature.names = read.delim(features.path, 
                           header = FALSE,
                           stringsAsFactors = FALSE)
barcode.names = read.delim(barcode.path, 
                           header = FALSE,
                           stringsAsFactors = FALSE)
colnames(mat) = barcode.names$V1
rownames(mat) = feature.names$V1
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.