Answers.Body: <p>I use the DropletUtils package from Bioconductor. Getting counts begins like this:</p>
  
  <pre><code>library(DropletUtils)
  filePath &lt;- "path_to_data/raw_feature_bc_matrix/"
  singleCellExperiment &lt;- read10xCounts(filePath, col.names = TRUE)
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-25T20:29:43.870Z
Answers.LastActivityDate: 2019-09-25T20:29:43.870Z
Answers.UserDisplayName: jack_bioinf
Answers.Body: <p>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 <code>nlines</code> or <code>skip</code> of the <a href="https://www.rdocumentation.org/packages/base/versions/3.6.1/topics/scan" rel="nofollow noreferrer"><code>scan()</code></a> function. Also, this is suggested code by <a href="https://support.10xgenomics.com/single-cell-gene-expression/software/pipelines/latest/output/matrices" rel="nofollow noreferrer">10xgenomics</a>:</p>
  
  <pre><code>library(Matrix)
  matrix_dir = "/opt/sample345/outs/filtered_feature_bc_matrix/"
  barcode.path &lt;- paste0(matrix_dir, "barcodes.tsv.gz")
  features.path &lt;- paste0(matrix_dir, "features.tsv.gz")
  matrix.path &lt;- paste0(matrix_dir, "matrix.mtx.gz")
  mat &lt;- 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<span class="math-container">$V1
  rownames(mat) = feature.names$</span>V1
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-22T12:51:41.743Z
Answers.LastActivityDate: 2019-08-22T12:51:41.743Z
Answers.UserDisplayName: Mahdiar
Body: <p>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 <code>readMM</code> function, it gave me the following error: </p>
  
  <pre><code>Error: cannot allocate vector of size 185.1 Gb. 
  </code></pre>
  
  <p>This happens even when I run it as a job. How can I generate a combined csv file using R?</p>
  
  <p>Thank you.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-21T16:47:42.413Z
Comments.Text: 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.
Comments.UserDisplayName: terdon
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-21T16:52:35.180Z
Comments.Text: Please [edit] your question to add extra information. Comments are hard to read, easy to miss and can be deleted without warning.
Comments.UserDisplayName: terdon
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-21T18:10:27.950Z
Comments.Text: Also posted on biostars: https://www.biostars.org/p/395275/
Comments.UserDisplayName: Devon Ryan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-21T23:15:29.260Z
Comments.Text: 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. https://support.10xgenomics.com/single-cell-gene-expression/software/pipelines/latest/output/matrices.  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
Comments.UserDisplayName: Mack123456
Tags: <scrnaseq><seurat>
Title: how to generate an scRNA counts file
ThreadText: # how to generate an scRNA counts file
  
  (Asked by: username_0 on 2019-08-21)
  
  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.
  
  **Tags:** scrnaseq, seurat
  
  > **Comments:**
  > **username_1**: 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.  
  > **username_1**: Please [edit] your question to add extra information. Comments are hard to read, easy to miss and can be deleted without warning.  
  > **username_2**: Also posted on biostars: https://www.biostars.org/p/395275/  
  > **username_3**: 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. https://support.10xgenomics.com/single-cell-gene-expression/software/pipelines/latest/output/matrices.  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  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_4 on 2019-09-25. Score: 2
  
  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)
  
  ```
  
  
  ---
  
  ### Answer by username_5 on 2019-08-22. Score: 0
  
  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()`](https://www.rdocumentation.org/packages/base/versions/3.6.1/topics/scan) function. Also, this is suggested code by [10xgenomics](https://support.10xgenomics.com/single-cell-gene-expression/software/pipelines/latest/output/matrices):
  
  ```
  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
  
  ```
  
  
  ---
  
  