Answers.Body: <p>You can access data within the Seurat object using <code>GetAssayData</code>, and extract a list of cell names for the cluster you're interested in using <code>WhichCells</code>:</p>
  
  <pre><code>library(Seurat)
  
  cells.use &lt;- WhichCells(object = pbmc_small, ident = 1)
  expr &lt;- GetAssayData(object = pbmc_small, assay.type = "RNA", slot = "data")[, cells.use]
  expr &lt;- as(Class = 'matrix', object = expr)
  write.csv(x = expr, file = "expression_cluster1.csv", quote = FALSE)
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-22T05:35:58.760Z
Answers.Text: Hi TimStuart, thank you for your advice, and it works well in the RStudio. But when I use this script in cypress it shows the error "Error in as(Class = "matrix", object = expr), could not find function "as"
  Execution halted". Do you know how to solve this problem?
Answers.UserDisplayName: hua
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-22T14:11:16.937Z
Answers.Text: I don't know what cypress is, but if you're running it in a script you'll need to load the methods and utils libraries
Answers.UserDisplayName: TimStuart
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-22T16:25:20.543Z
Answers.Text: Hi TimStuart, thank you for your reply, and if it is possible could you please tell my what kind of the utils libraries that I should load?
Answers.UserDisplayName: hua
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-22T17:24:52.367Z
Answers.Text: `library(methods); library(utils)`
Answers.UserDisplayName: TimStuart
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-02T22:16:19.413Z
Answers.Text: Hi TimStuart, nowadays thank you for the Seurat's update, we can analysis several samples together. And I would like to know whether we can obtain the specific sample's specific cluster gene expression profile by using the same code "cells.use <- WhichCells(object = pbmc_small, ident = 1)
  expr <- GetAssayData(object = pbmc_small, assay.type = "RNA", slot = "data")[, cells.use]
  expr <- as(Class = 'matrix', object = expr)
  write.csv(x = expr, file = "expression_cluster1.csv", quote = FALSE)"?
Answers.UserDisplayName: hua
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-19T14:50:51.793Z
Answers.LastActivityDate: 2019-02-19T14:50:51.793Z
Answers.UserDisplayName: TimStuart
Body: <p>I was using Seurat to analysis single-cell RNA Seq. And I was interested in only one cluster by using the Seurat. Does anyone know how to achieve the cluster's data(.csv file) by using Seurat or any other method that can do this function? Thank you!</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-02-18T23:13:17.230Z
Comments.Text: A cluster may contain different types of data. Do you want the specific cells, expression for each cell, average expression, cluster markers, etc.?
Comments.UserDisplayName: burger
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-02-19T03:23:13.307Z
Comments.Text: Yes even a cluster contain different types of data. I still  want to obtain that cluster's data including its each cell and gene expression for further analysis.
Comments.UserDisplayName: hua
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-02-19T10:12:19.633Z
Comments.Text: I think that the Seurat tutorials had some information about this. Did you read them? Have you tried something?
Comments.UserDisplayName: llrs
Tags: <seurat><single-cell>
Title: how to obtain only one cluster's data (.csv file) in Seurat
ThreadText: # how to obtain only one cluster's data (.csv file) in Seurat
  
  (Asked by: username_0 on 2019-02-18)
  
  I was using Seurat to analysis single-cell RNA Seq. And I was interested in only one cluster by using the Seurat. Does anyone know how to achieve the cluster's data(.csv file) by using Seurat or any other method that can do this function? Thank you!
  
  **Tags:** seurat, single-cell
  
  > **Comments:**
  > **username_1**: A cluster may contain different types of data. Do you want the specific cells, expression for each cell, average expression, cluster markers, etc.?  
  > **username_0**: Yes even a cluster contain different types of data. I still  want to obtain that cluster's data including its each cell and gene expression for further analysis.  
  > **username_2**: I think that the Seurat tutorials had some information about this. Did you read them? Have you tried something?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2019-02-19. Score: 1 | Accepted answer
  
  You can access data within the Seurat object using `GetAssayData`, and extract a list of cell names for the cluster you're interested in using `WhichCells`:
  
  ```
  library(Seurat)
  
  cells.use <- WhichCells(object = pbmc_small, ident = 1)
  expr <- GetAssayData(object = pbmc_small, assay.type = "RNA", slot = "data")[, cells.use]
  expr <- as(Class = 'matrix', object = expr)
  write.csv(x = expr, file = "expression_cluster1.csv", quote = FALSE)
  
  ```
  
  > **Comments:**
  > **username_0**: Hi username_3, thank you for your advice, and it works well in the RStudio. But when I use this script in cypress it shows the error "Error in as(Class = "matrix", object = expr), could not find function "as" Execution halted". Do you know how to solve this problem?  
  > **username_3**: I don't know what cypress is, but if you're running it in a script you'll need to load the methods and utils libraries  
  > **username_0**: Hi username_3, thank you for your reply, and if it is possible could you please tell my what kind of the utils libraries that I should load?  
  > **username_3**: `library(methods); library(utils)`  
  > **username_0**: Hi username_3, nowadays thank you for the Seurat's update, we can analysis several samples together. And I would like to know whether we can obtain the specific sample's specific cluster gene expression profile by using the same code "cells.use <- WhichCells(object = pbmc_small, ident = 1) expr <- GetAssayData(object = pbmc_small, assay.type = "RNA", slot = "data")[, cells.use] expr <- as(Class = 'matrix', object = expr) write.csv(x = expr, file = "expression_cluster1.csv", quote = FALSE)"?  
  
  ---
  
  