<p>Is your memory usage low enough that you can initially read everything in and then filter later? If so you could read the Seurat object in like normal and then use <code>subset</code> against a vector of your gene names.</p>

<pre><code>subsample &lt;- subset(seurat_obj, features = my_genes)
</code></pre>

CC BY-SA 4.0
2019-11-15T15:02:41.757Z
2019-11-15T15:08:36.317Z
2019-11-15T15:08:36.317Z
TW93
<p>A different approach if you are using <code>Seurat3</code>, is <code>DietSeurat()</code>. It allows you to diet the object by removing the components that you don't need. For example you can keep the normalised/scaled matrix and remove the raw counts. This approach could reduce space and memory usage, while keeping all your genes in place.</p>

CC BY-SA 4.0
2019-11-19T08:25:59.550Z
2019-11-19T08:25:59.550Z
fra
<p>I'm working with some large Seurat objects (MOCA, MCA, Tabula Muris) studying gene coexpression, and I'm running into memory issues. </p>

<p>Is it possible to remove all genes in a Seurat object that are not in a specified gene array? Ideally I'd like to be working with a small R matrix with say, 250k rows (cells) and 10-50 columns (gene expression data) which will enable fast processing and comprehensive analysis using other packages.</p>

CC BY-SA 4.0
2019-11-19T08:43:27.760Z
There might be drawbakcs with this approach, for example if you end up with genes that are highly expressed in one cell type and lowly expressed in the other, these two sets of cells will look like expressing these genes at similar levels after normalization if normalization is performed with this limited number of specific genes. You might want to consider sampling your cells, you can decrease the number of cells instead of genes.
haci
<r><scrnaseq><seurat>
Trim Seurat object to contain expression info only for selected genes
# Trim Seurat object to contain expression info only for selected genes

(Asked by: username_0 on 2019-11-14)

I'm working with some large Seurat objects (MOCA, MCA, Tabula Muris) studying gene coexpression, and I'm running into memory issues.

Is it possible to remove all genes in a Seurat object that are not in a specified gene array? Ideally I'd like to be working with a small R matrix with say, 250k rows (cells) and 10-50 columns (gene expression data) which will enable fast processing and comprehensive analysis using other packages.

**Tags:** r, scrnaseq, seurat
> **Comments:**
> **username_1**: There might be drawbakcs with this approach, for example if you end up with genes that are highly expressed in one cell type and lowly expressed in the other, these two sets of cells will look like expressing these genes at similar levels after normalization if normalization is performed with this limited number of specific genes. You might want to consider sampling your cells, you can decrease the number of cells instead of genes.  

---

## 2 answers

### Answer by username_2 on 2019-11-15. Score: 1 | Accepted answer

Is your memory usage low enough that you can initially read everything in and then filter later? If so you could read the Seurat object in like normal and then use subset against a vector of your gene names.
subsample <- subset(seurat_obj, features = my_genes)


---

### Answer by username_3 on 2019-11-19. Score: 2

A different approach if you are using `Seurat3`, is `DietSeurat()`. It allows you to diet the object by removing the components that you don't need. For example you can keep the normalised/scaled matrix and remove the raw counts. This approach could reduce space and memory usage, while keeping all your genes in place.


---

