cellcall icon indicating copy to clipboard operation
cellcall copied to clipboard

Issue with CreateObject_fromSeurat

Open sidrahmaryam-cyber opened this issue 1 year ago • 1 comments

Hello, I have been using this tool for some time now. And it has really given good results. However, right now I was running the same script I always have had to a new data, and while using CreateObject_fromSeurat,

ctr <- CreateObject_fromSeurat(Seurat.object=s2, 
 slot="counts", 
  cell_type="cell_type_original",
 data_source="UMI",
scale.factor = 10^6, 
Org = "Homo sapiens")

I get this error : Error: 'RNA' is not an assay

I know the assay name is not RNA here, but originalexp, however I have been using it previously with such name, and it worked smooth. Can you please suggest why it gave this issue now.

Thank you!

sidrahmaryam-cyber avatar Apr 20 '23 08:04 sidrahmaryam-cyber

seuratObj@assays$RNA@counts is a structure of Seurat Object. Maybe your use some methods such like harmony etc., store the data in another slot, but not RNA. Actually, the function CreateObject_fromSeurat() is designed just to get expression data and cell label.

You can use code followed exchange one code data <- as.matrix(Seurat::GetAssayData(object = Seurat.object, slot = slot, assay = "RNA")):

data <- as.matrix(Seurat::GetAssayData(object = Seurat.object, slot = slot, assay = 'RNA'))

  myCelltype <- as.character([email protected][,cell_type])
  
  data <- as.data.frame(data)
  colnames(data) <- paste(1:length(myCelltype), myCelltype, sep = "_")
  
  mt <- CreateNichConObject(data=data, min.feature = 0,
                            names.field = 2,
                            names.delim = "_",
                            source = your_source, # "fullLength", "UMI", "TPM"
                            scale.factor = scale.factor,
                            Org = Org,
                            project = "Microenvironment")

I am just a beginner in scientific research, and I recognize that the R package I developed has various shortcomings. I am very grateful for any feedback and suggestions for improvement that everyone provides.

Best wishes!

ShellyCoder avatar May 11 '23 01:05 ShellyCoder