ShellyCoder / cellcall

inferring cell-cell communication from scRNA-seq of ligand-receptor
73 stars 20 forks source link

Issue with CreateObject_fromSeurat #41

Open sidrahmaryam-cyber opened 1 year ago

sidrahmaryam-cyber commented 1 year ago

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!

ShellyCoder commented 1 year ago

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(Seurat.object@meta.data[,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!