This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Create a seurat object from a DESeqDataSet

I am working with some data in R using and I want to create a Seurat object as well to be able to run the FindMarkers function but I haven't been able to figure out how. I have attached a short sample of the code I am using and error report. the data objects are organized like this:

countData

  • ID-REF___SAMPLE1___SAMPLE2___SAMPLE3______......
  • GENE1______145________820_______461________.......
  • GENE2______36_________119_______16__________......
  • ..........

metaData

  • Sample___Sample#____Tissue_____Disease.State
  • SAMPLE1______1_______Retina_______Control
  • SAMPLE2______2_______Retina_______Control
  • SAMPLE3______3_______Retina_______Disease
  • ..........

I am trying to use the CreateSeuratObject function but get this error:

Error in h(simpleError(msg, call)) : 
  error in evaluating the argument 'x' in selecting a method for function 'head': Cannot find the following identities in the object: 1

Code:

count_seurat <- CreateSeuratObject(countData, project = "SeuratProject", assay = "RNA",
                   min.cells = 0, min.features = 0, names.field = 1,
                   names.delim = "_", meta.data = metaData)

head(FindMarkers(count_seurat, ident.1 = 1, min.pct = 0.5))

I am also using DESeq2 and have the data in a 'Large DESeqDataSet' format as well if that is easier.

seurat r deseq2

What do the rows in your count data represent? Is it cells or samples?

Updated it to more clearly represent the data. I did not accurately copy it over. Cols are samples and rows are counts. Thanks!

1 answer

The object is being created just fine, though as rpolicastro hints at, you likely want to transpose your count matrix first. Seurat expects cells as columns and features as rows. It's not really clear if your count matrix is organized in that fashion or not. Naming samples as GENE is confusing at best, so if that is actually how you have chosen to name your samples, I'd reconsider.

The actual error stems from your FindMarkers call, as you are setting ident.1 = 1 before actually setting the identities for each sample. You probably want to utilize the group.by parameter in your FindMarkers call to set whatever metadata variable as your grouping parameter as necessary. See the function documentation for examples and details.

Log in to answer this question.