raymondlouie / MiniMarS

4 stars 2 forks source link

Error: object 'seurat_data' not found #11

Closed anglixue closed 1 year ago

anglixue commented 1 year ago

Hi Ray, I still encounter this error after installing the latest package.

> seurat_in = processInputFormat(sc_object=sc_object,
+                                verbose=TRUE)
Seurat input.
The default Seurat assay used will be `RNA`. Please change the default assay if this is not correct. 
Error in processInputFormat(sc_object = sc_object, verbose = TRUE) : 
  object 'seurat_data' not found

Did you meet such an error using other datasets? or it's just the same data?

raymondlouie commented 1 year ago

This is strange, I just checked the code, in both main and dev, and the object seurat_data is not there, except in the initial comments (describing the function), which I have now updated to seurat_slot. This shouldn't of affected anything though.

In the previous version, I did incorrectly put seurat_data as an object, but this is now all changed to seurat_slot. Not sure why this is happening..

anglixue commented 1 year ago

@raymondlouie There is a chunk of code in the wrapperProcessData.R mentioning 'seurat_data'


        if (is.null(seurat_data)) {
            seurat_data= "data"
            sc_matrix <- t(as.matrix(Seurat::GetAssayData(sc_object, assay = seurat_assay, slot = seurat_data)))
            cat(paste0("The default Seurat slot used will be `", seurat_data, "`. Please provide an alternative slot input if this is not correct."),'\n')
        } else{
            seurat_data= "data"
            sc_matrix <- t(as.matrix(Seurat::GetAssayData(sc_object, assay = seurat_assay, slot = seurat_data)))
        }

Does it seem the code run in if condition and else condition are the same? So no matter 'seurat_data' is null or not, it will create sc_matrix from sc_object.

anglixue commented 1 year ago

I noticed that in Dev branch you have update these lines from seurat_dat to seurat_slot.

However, when I installed the package using devtools::install_github("raymondlouie/ClusterMarkers", ref = "Dev")

The processInputFormat() function is still the old.

Maybe you can just merge the current Dev branch to the main one so we can reinstall it.

raymondlouie commented 1 year ago

This is strange. I just checked, and seurat_data is not in either the dev or main. It is updated to seurat_slot. Does anyone else (@Felixillion @dhrutiparikh @HsiaoChiLiao ) have this issue? (i.e., in the processInputFormat function in the wrapperProcess.R script, do you see the code Angli posted above?)

I have just merged Dev into main though as you asked, but if we continue doing edits in Dev, not sure that will solve the issue.

anglixue commented 1 year ago

I have install the latest update but still got this error Please see my code

library(ClusterMarkers)
library(dplyr)
library(SingleCellExperiment)
data(sce)
input_matrix = t(sce@assays@data$counts)
clusters = sce$cell_type

sce_in = processInputFormat(sc_object=sce,
                            sce_cluster="cell_type",
                            verbose=TRUE)

SCE input. The counts assay is used. Feature matrix dimension: 192 x 1000 . Cluster annotation vector length: 1000

manual_in = processInputFormat(sc_object=input_matrix,
                               clusters_all=clusters,
                               verbose=TRUE)         

Matrix input.

Feature matrix dimension: 1000 x 192 . Cluster annotation vector length: 1000

Seurat input example.

library(Seurat)
sc_object = CreateSeuratObject(input_matrix)

Warning: Feature names cannot have underscores ('_'), replacing with dashes ('-')

Idents(object = sc_object) <- clusters
seurat_in = processInputFormat(sc_object=sc_object,
                               verbose=TRUE)

Seurat input. The default Seurat assay used will be RNA. Please change the default assay if this is not correct. Error in processInputFormat(sc_object = sc_object, verbose = TRUE) : object 'seurat_data' not found`

anglixue commented 1 year ago

I have installed the latest Dev version and the error is gone. Thanks!