Answers.Body: <p>I've come across the same error which seems to be a common issue when using the <code>subset()</code> function with Seurat objects. Sometimes, I encountered the same error and couldn't figure out the reason behind it, checking the variable's names was not a remedy in my case as I specified the exact same name for subsetting as to what I could see in my object metadata. However, I found a workaround to subset cells in a Seurat object using a different approach.</p>
  <p>Instead of using <code>subset()</code>, you can try the following:</p>
  <pre><code>seurat_obj_subset &lt;- seurat_obj[, &lt;condition to be met&gt;]
  </code></pre>
  <p>For example, if you want to subset a Seurat object called 'pbmc' based on conditions like having more than 1000 features and more than 4000 counts, you can use the following code:</p>
  <pre><code>pbmc = pbmc[, pbmc<span class="math-container">$nFeature &gt; 1000 &amp; pbmc$</span>nCount &gt; 4000]
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-06-28T23:34:57.817Z
Answers.LastActivityDate: 2023-06-28T23:34:57.817Z
Answers.UserDisplayName: Hamid G
Answers.Body: <p>From the steps in the <a href="https://satijalab.org/seurat/archive/v3.0/pbmc3k_tutorial.html" rel="nofollow noreferrer">PBMC_3k tutorial</a>, it looks like you need to suffix the name with the assay as well, separated by an underscore (in this case, <code>RNA</code>):</p>
  <pre><code>pbmc &lt;- subset(pbmc, subset = (nFeature_RNA &gt; 1000) &amp; (nCount_RNA &gt; 4000))
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-08-13T11:08:38.133Z
Answers.LastActivityDate: 2022-08-13T11:08:38.133Z
Answers.UserDisplayName: gringer
Answers.Body: <blockquote>
  <p>&quot;Error in FetchData.Seurat(object = object, vars = unique(x = expr.char[vars.use]), :
  None of the requested variables were found:&quot;</p>
  </blockquote>
  <p>As the error is pointing out here, you should check your variable names that you have used here. It must match the variable names in the pbmc object that you want to subset.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-08-13T12:07:55.640Z
Answers.LastActivityDate: 2022-08-13T14:34:51.083Z
Answers.LastEditDate: 2022-08-13T14:34:51.083Z
Answers.UserDisplayName: Nitesh Shriwash
Body: <p>I was trying to do subsetting via:</p>
  <pre><code>pbmc = subset(pbmc, subset = nFeature &gt; 1000 &amp; nCount &gt; 4000)
  </code></pre>
  <p>R returns:</p>
  <pre><code>Error in FetchData.Seurat(object = object, vars = unique(x = expr.char[vars.use]), :
  None of the requested variables were found:
  </code></pre>
  <p>and then nothing, so it says cannot find requested variables and doesn't tell me what's missing...</p>
  <p>I'm very confused. Thank you so much for your help!</p>
  
Tags: <r><seurat><subset>
Title: Seurat: Error in FetchData.Seurat(object = object, vars = unique(x = expr.char[vars.use]), : None of the requested variables were found:
ThreadText: # Seurat: Error in FetchData.Seurat(object = object, vars = unique(x = expr.char[vars.use]), : None of the requested variables were found:
  
  (Asked by: username_0 on 2022-08-12)
  
  I was trying to do subsetting via:
  
  ```
  pbmc = subset(pbmc, subset = nFeature > 1000 & nCount > 4000)
  
  ```
  
  R returns:
  
  ```
  Error in FetchData.Seurat(object = object, vars = unique(x = expr.char[vars.use]), :
  None of the requested variables were found:
  
  ```
  
  and then nothing, so it says cannot find requested variables and doesn't tell me what's missing...
  
  I'm very confused. Thank you so much for your help!
  
  **Tags:** r, seurat, subset
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2023-06-28. Score: 1
  
  I've come across the same error which seems to be a common issue when using the `subset()` function with Seurat objects. Sometimes, I encountered the same error and couldn't figure out the reason behind it, checking the variable's names was not a remedy in my case as I specified the exact same name for subsetting as to what I could see in my object metadata. However, I found a workaround to subset cells in a Seurat object using a different approach.
  
  Instead of using `subset()`, you can try the following:
  
  ```
  seurat_obj_subset <- seurat_obj[, <condition to be met>]
  
  ```
  
  For example, if you want to subset a Seurat object called 'pbmc' based on conditions like having more than 1000 features and more than 4000 counts, you can use the following code:
  
  ```
  pbmc = pbmc[, pbmc$nFeature > 1000 & pbmc$nCount > 4000]
  
  ```
  
  
  ---
  
  ### Answer by username_2 on 2022-08-13. Score: 0
  
  From the steps in the [PBMC\_3k tutorial](https://satijalab.org/seurat/archive/v3.0/pbmc3k_tutorial.html), it looks like you need to suffix the name with the assay as well, separated by an underscore (in this case, `RNA`):
  
  ```
  pbmc <- subset(pbmc, subset = (nFeature_RNA > 1000) & (nCount_RNA > 4000))
  
  ```
  
  
  ---
  
  ### Answer by username_3 on 2022-08-13. Score: 0
  
  > "Error in FetchData.Seurat(object = object, vars = unique(x = expr.char[vars.use]), :
  > None of the requested variables were found:"
  
  As the error is pointing out here, you should check your variable names that you have used here. It must match the variable names in the pbmc object that you want to subset.
  
  
  ---
  
  