How to change a character variable into vector within a DataFrame

I am working on SingleCellExperiment and am preparing the metadata to colData for DESeq2 analysis.
DataFrame with 41082 rows and 30 columns
orig.ident nCount_RNA nFeature_RNA

stim1_ 14762 4657

My question is how to change the "orig.ident" from into ?
Script as below

Create single cell experiment object

sce <- SingleCellExperiment(assays = list(counts = counts),
colData = metadata)
colData(sce)$orig.ident <- factor(colData@orig.ident)

Can someone please help me with the last commend?
my console error message:

Error in factor(colData@seq_folder) :
no slot of name "orig.ident" for this object of class "standardGeneric"

Thank you!

I can't tell exactly what you are trying to do.

Are you trying to convert colData(sce)$orig.ident into a factor?

In that case you probably want:

colData(sce)$orig.ident <- as.factor(colData(sce)$orig.intent)

You can get a better answer if you post a reprex (FAQ: What's a reproducible example (`reprex`) and how do I do one?)

I see now that's now what you are trying to do. But without seeing the underlying data a little, I don't think I can be helpful.

Thank you so much for replying. Is it possible to share the screen or snapshot (screenshot) here ?

I'm not certain that will help. Are you unable to make a reproducible example? If so, I am sure you could get the answers you need.

Disclosure I am unfamiliar with the SingleCellExperiment but at first glance this doesn't look quite right:

colData() appears to be an accessor function which returns a data.frame object. Should it instead be something like this,

colData(sce)$orig.ident <- factor(colData(sce)$orig.ident)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.