<p>Seurat has <a href="https://satijalab.org/seurat/v3.1/merge_vignette.html" rel="nofollow noreferrer">a vignette specifically for combining multiple 10x libraries</a>.</p>

CC BY-SA 4.0
2020-02-23T15:27:39.807Z
Yes, I know. But I'm wondering if there is a way to merge all counts before creating a Seurat object. I'd like to just create one Seurat object with all the counts.
mmpp
CC BY-SA 4.0
2020-02-24T02:05:58.620Z
You don't have to keep the intermediate Seurat objects.
burger
CC BY-SA 4.0
2020-02-24T10:24:54.580Z
To merge all counts before creating individual Seurat objects, you will need to give a prefix or a suffix to cell names. I would however advise to create individual Seurat objects with `apply()` or `mclapply()` and then `reduce()` these with Seurat's `merge()`, this will give you a single Seurat object with all your samples.
haci
CC BY-SA 4.0
2020-02-24T17:54:07.633Z
@haci How do I give a prefix or suffix?
mmpp
CC BY-SA 4.0
2020-02-28T22:37:15.873Z
Note that a month later, they put out a new vignette about merging data sets which is more complex:  https://satijalab.org/seurat/pancreas_integration_label_transfer.html
swbarnes2
CC BY-SA 4.0
2020-02-29T23:10:01.620Z
That vignette is over a year old. Also, it is for integration (batch correction), not simple merging of data sets.
burger
CC BY-SA 4.0
2020-03-01T15:16:23.567Z
That's not what I'm looking for. Is there not a way to merge the counts from a directory and then create just one Seurat object?
mmpp
CC BY-SA 4.0
2020-03-01T21:23:50.470Z
See previous comment by @haci. However, there are many benefits of creating separate Seurat objects for each library, such as performing per-library QC.
burger
CC BY-SA 4.0
2020-02-23T06:18:15.340Z
2020-02-23T06:18:15.340Z
burger
<p>I have multiple single cell samples to analyze and I'm following the instructions in Satija Lab's website. I want to merge all the count files from all the samples at once, and associate the metadata to each sample. </p>

<p>For the <code>Read10x</code> command, is there a way to read multiple files at once, such as merging all the filter_featire_bc_matrix files?</p>

<p>I have all the samples saved in a directory on my desktop, is it possible to call the directory within the script for it to read all the raw counts?</p>

<p>This is what I have thus far:</p>

<pre><code># load the required libraries
library(dplyr)
library(Seurat) 
library(ggplot2)

-----------------------------------------------

# set up the working directory

wd = ("~/Seurat") setwd(wd)

# read all metadata

metadata = read.table("metadata_Jan2020.csv", sep=';', header=T, stringsAsFactors=F)
rownames(metadata) = metadata$LibraryID

#metadata
#mf = metadata

mf = metadata %&gt;% filter(Type %in% c("PDAC", "NORMAL"))
mf = mf %&gt;% filter(!(ID %in% c("PDAC-HTB2854")))`
</code></pre>

<r><scrnaseq><seurat><10x-genomics>
Reading multiple raw files in Seurat
# Reading multiple raw files in Seurat

(Asked by: username_0 on 2020-02-23)

I have multiple single cell samples to analyze and I'm following the instructions in Satija Lab's website. I want to merge all the count files from all the samples at once, and associate the metadata to each sample. 
For the Read10x command, is there a way to read multiple files at once, such as merging all the filter_featire_bc_matrix files?
I have all the samples saved in a directory on my desktop, is it possible to call the directory within the script for it to read all the raw counts?
This is what I have thus far:
# load the required libraries
library(dplyr)
library(Seurat) 
library(ggplot2)

-----------------------------------------------

# set up the working directory

wd = ("~/Seurat") setwd(wd)

# read all metadata

metadata = read.table("metadata_Jan2020.csv", sep=';', header=T, stringsAsFactors=F)
rownames(metadata) = metadata$LibraryID

#metadata
#mf = metadata

mf = metadata %>% filter(Type %in% c("PDAC", "NORMAL"))
mf = mf %>% filter(!(ID %in% c("PDAC-HTB2854")))`

**Tags:** r, scrnaseq, seurat, 10x-genomics

---

## 1 answers

### Answer by username_1 on 2020-02-23. Score: 2

Seurat has [a vignette specifically for combining multiple 10x libraries](https://satijalab.org/seurat/v3.1/merge_vignette.html).

> **Comments:**
> **username_0**: Yes, I know. But I'm wondering if there is a way to merge all counts before creating a Seurat object. I'd like to just create one Seurat object with all the counts.  
> **username_1**: You don't have to keep the intermediate Seurat objects.  
> **username_2**: To merge all counts before creating individual Seurat objects, you will need to give a prefix or a suffix to cell names. I would however advise to create individual Seurat objects with `apply()` or `mclapply()` and then `reduce()` these with Seurat's `merge()`, this will give you a single Seurat object with all your samples.  
> **username_0**: @haci How do I give a prefix or suffix?  
> **username_3**: Note that a month later, they put out a new vignette about merging data sets which is more complex:  https://satijalab.org/seurat/pancreas_integration_label_transfer.html  
> **username_1**: That vignette is over a year old. Also, it is for integration (batch correction), not simple merging of data sets.  
> **username_0**: That's not what I'm looking for. Is there not a way to merge the counts from a directory and then create just one Seurat object?  
> **username_1**: See previous comment by @haci. However, there are many benefits of creating separate Seurat objects for each library, such as performing per-library QC.  

---

