0
$\begingroup$

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!

$\endgroup$
  • 1
    $\begingroup$ A cluster may contain different types of data. Do you want the specific cells, expression for each cell, average expression, cluster markers, etc.? $\endgroup$ – burger Feb 18 '19 at 23:13
  • $\begingroup$ 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. $\endgroup$ – hua Feb 19 '19 at 3:23
  • 1
    $\begingroup$ I think that the Seurat tutorials had some information about this. Did you read them? Have you tried something? $\endgroup$ – llrs Feb 19 '19 at 10:12
1
$\begingroup$

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)
| improve this answer | |
$\endgroup$
  • $\begingroup$ 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? $\endgroup$ – hua Feb 22 '19 at 5:35
  • $\begingroup$ 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 $\endgroup$ – TimStuart Feb 22 '19 at 14:11
  • $\begingroup$ 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? $\endgroup$ – hua Feb 22 '19 at 16:25
  • $\begingroup$ library(methods); library(utils) $\endgroup$ – TimStuart Feb 22 '19 at 17:24
  • $\begingroup$ 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)"? $\endgroup$ – hua Oct 2 '19 at 22:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.