<pre><code>WhichCells(seurat_object made by this matrix, slot = 'counts', expression = PTPRC &gt; 0 )
</code></pre>
<p>By Seurat R package this is possible</p>

CC BY-SA 4.0
2021-06-30T14:30:37.147Z
Please accept one answer if either of them solved your problem. Thank you.
user438383
CC BY-SA 4.0
2021-07-01T08:04:08.830Z
Hi there, it would be nice to write more details and an actual working code.
Kamil S Jaron
CC BY-SA 4.0
2021-06-30T13:19:02.697Z
2021-06-30T13:19:02.697Z
user6517
<p>This is basic R subsetting operation. Most subset operations give you a subset of rows based on a column, while you're doing the opposite here - but the logic is the same.</p>
<p>This gives you a subset of rows when the expression is based on a column</p>
<pre><code>df[logical_expression_that_subsets_rows,]
</code></pre>
<p>Why not try this - it should give you a subset of columns based on a row value. (Untested, but you should be able to build on this):</p>
<pre><code>df[, logical_expression_that_subsets_columns]
</code></pre>
<p>The logical expression for the first could be <code>df$cell1 &lt; 0.5</code> (or the equivalent <code>df[,&quot;cell1&quot;] &lt; 0.5</code>. You should be able to get a logical expression for the second based on this.</p>

CC BY-SA 4.0
2021-06-29T14:29:37.633Z
2021-06-29T14:29:37.633Z
Ram RS
<p>I have a big single-cell RNA seq data</p>
<pre><code>&gt; dput(head(new.dat[,1:10]))
structure(list(cell1 = c(0.793763840992639, 0, 1.96843530982957, 
0.461736429639991, 0.717968540649498, 0), cell2 = c(3.61741696702738, 
0.231662370550224, 0, 0, 0, 0), cell3 = c(4.14348883366621, 0.118161316317251, 
0.08074552209482, 2.27968429766934, 0.0470313356296409, 0), cell4 = c(1.34783143327084, 
0.0094666040612932, 1.14392942941128, 0.652535826921119, 0.357542816432864, 
0.149587369334621), cell5 = c(1.27104023273899, 1.55185229643731, 
0, 0, 0, 0.0117525723115277), cell6 = c(1.92307653575663, 0, 
0, 0.319156642478379, 0, 0), cell7 = c(3.9343015424917, 0.132824589520901, 
0.119679885703561, 0.772516422897241, 0.0236884909844904, 0), 
    cell8 = c(3.74969491678643, 0.103404975609384, 0.0354753982873036, 
    0, 0, 0), cell9 = c(1.19084857532713, 3.9213265721495, 0, 
    0.0341973245272891, 0.0419122921627454, 0), cell10 = c(4.1224255501566, 
    0.301871669274068, 0.0633536200981225, 0.389959552469879, 
    0, 0.0405296102106492)), row.names = c(&quot;PTPRC&quot;, &quot;MHC-II&quot;, 
&quot;ITGAM&quot;, &quot;Ly6C&quot;, &quot;Ly6G&quot;, &quot;EMR1&quot;), class = &quot;data.frame&quot;)
&gt; 

&gt; dim(new.dat)
[1]     33 263086
&gt; 
</code></pre>
<p>How I <code>remove every columns</code> which are <code>zero</code> for one gene, let's say <code>PTPRC</code>?</p>

<r><scrnaseq><10x-genomics>
Removing cells zero for a gene from a scRNA-seq data
# Removing cells zero for a gene from a scRNA-seq data

(Asked by: username_0 on 2021-06-29)

I have a big single-cell RNA seq data
> dput(head(new.dat[,1:10]))
structure(list(cell1 = c(0.793763840992639, 0, 1.96843530982957, 
0.461736429639991, 0.717968540649498, 0), cell2 = c(3.61741696702738, 
0.231662370550224, 0, 0, 0, 0), cell3 = c(4.14348883366621, 0.118161316317251, 
0.08074552209482, 2.27968429766934, 0.0470313356296409, 0), cell4 = c(1.34783143327084, 
0.0094666040612932, 1.14392942941128, 0.652535826921119, 0.357542816432864, 
0.149587369334621), cell5 = c(1.27104023273899, 1.55185229643731, 
0, 0, 0, 0.0117525723115277), cell6 = c(1.92307653575663, 0, 
0, 0.319156642478379, 0, 0), cell7 = c(3.9343015424917, 0.132824589520901, 
0.119679885703561, 0.772516422897241, 0.0236884909844904, 0), 
    cell8 = c(3.74969491678643, 0.103404975609384, 0.0354753982873036, 
    0, 0, 0), cell9 = c(1.19084857532713, 3.9213265721495, 0, 
    0.0341973245272891, 0.0419122921627454, 0), cell10 = c(4.1224255501566, 
    0.301871669274068, 0.0633536200981225, 0.389959552469879, 
    0, 0.0405296102106492)), row.names = c("PTPRC", "MHC-II", 
"ITGAM", "Ly6C", "Ly6G", "EMR1"), class = "data.frame")
> 

> dim(new.dat)
[1]     33 263086
> 

How I remove every columns which are zero for one gene, let's say PTPRC?

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

---

## 2 answers

### Answer by username_0 on 2021-06-30. Score: -3 | Accepted answer

WhichCells(seurat_object made by this matrix, slot = 'counts', expression = PTPRC > 0 )

By Seurat R package this is possible

> **Comments:**
> **username_1**: Please accept one answer if either of them solved your problem. Thank you.  
> **username_2**: Hi there, it would be nice to write more details and an actual working code.  

---

### Answer by username_3 on 2021-06-29. Score: 0

This is basic R subsetting operation. Most subset operations give you a subset of rows based on a column, while you're doing the opposite here - but the logic is the same.
This gives you a subset of rows when the expression is based on a column
df[logical_expression_that_subsets_rows,]

Why not try this - it should give you a subset of columns based on a row value. (Untested, but you should be able to build on this):
df[, logical_expression_that_subsets_columns]

The logical expression for the first could be df$cell1 < 0.5 (or the equivalent df[,"cell1"] < 0.5. You should be able to get a logical expression for the second based on this.


---

