gustaveroussy / CFS

R package using ICA based method for spatial transcriptomics analysis (Visium/Slide-seq/CosMX/MERSCOPE)
6 stars 2 forks source link

Error when running function ICASpatial #1

Open inaciomdrs opened 7 months ago

inaciomdrs commented 7 months ago

Environment

R version 4.3.1 (2023-06-16) CFS Version: 0.9.7.2

Code I am using to run CFS


library(future)
library(Seurat)
library(enrichR)
library(CFS)
library(moments)
library(dplyr)
library(purrr)

sample_path <- "path/to/sample"

data <- Load10X_Spatial(
  sample_path,
  filename = "filtered_feature_bc_matrix.h5",
  assay = "Spatial",
  slice = "slice1",
  filter.matrix = TRUE,
  to.upper = FALSE,
  image = NULL,
)

data[["percent.mt"]] <- PercentageFeatureSet(data, pattern = "^MT-")

data <- subset(data, subset = nFeature_Spatial >= 5500 & percent.mt <= 15)

data <- PrepNormData(data=data,organism="Hs",variable_features=2000)

data <- ICASpatial(data=data,ncis=100,maxit=600,method="icafast",kurtosis = 3,sd=3)

Error message

Error in validObject(.Object): invalid class “DimReduc” object: rownames must be present in 'cell.embeddings'
Traceback:

1. ICASpatial(data = data, ncis = 100, maxit = 600, method = "icafast", 
 .     kurtosis = 3, sd = 3)
2. RunICA(data, verbose = TRUE, nics = ncis, maxit = maxit, ica.function = method)
3. RunICA.Seurat(data, verbose = TRUE, nics = ncis, maxit = maxit, 
 .     ica.function = method)
4. RunICA(object = object[[assay]], assay = assay, features = features, 
 .     nics = nics, rev.ica = rev.ica, ica.function = ica.function, 
 .     verbose = verbose, ndims.print = ndims.print, nfeatures.print = nfeatures.print, 
 .     reduction.key = reduction.key, seed.use = seed.use, ...)
5. RunICA.Assay(object = object[[assay]], assay = assay, features = features, 
 .     nics = nics, rev.ica = rev.ica, ica.function = ica.function, 
 .     verbose = verbose, ndims.print = ndims.print, nfeatures.print = nfeatures.print, 
 .     reduction.key = reduction.key, seed.use = seed.use, ...)
6. RunICA(object = data.use, assay = assay, nics = nics, rev.ica = rev.ica, 
 .     ica.function = ica.function, verbose = verbose, ndims.print = ndims.print, 
 .     nfeatures.print = nfeatures.print, reduction.key = reduction.key, 
 .     seed.use = seed.use, ...)
7. RunICA.default(object = data.use, assay = assay, nics = nics, 
 .     rev.ica = rev.ica, ica.function = ica.function, verbose = verbose, 
 .     ndims.print = ndims.print, nfeatures.print = nfeatures.print, 
 .     reduction.key = reduction.key, seed.use = seed.use, ...)
8. CreateDimReducObject(embeddings = cell.embeddings, loadings = feature.loadings, 
 .     assay = assay, key = reduction.key)
9. new(Class = "DimReduc", cell.embeddings = embeddings, feature.loadings = loadings, 
 .     feature.loadings.projected = projected, assay.used = assay, 
 .     global = global, stdev = stdev, key = key, jackstraw = jackstraw, 
 .     misc = misc)
10. initialize(value, ...)
11. initialize(value, ...)
12. validObject(.Object)
13. stop(msg, ": ", errors, domain = NA)

What can I be doing wrong?

inaciomdrs commented 7 months ago

UPDATE: even when I load just Seurat and CFS, I get the same error.

c-thuil commented 7 months ago

Hi @inaciomdrs,

Thank you for using CFS and sorry for the sligthly delayed answer. I have been trying to replicate the error on my side without success. Considering the error, I assume the problem comes from the Seurat output format. Could you tell me which version of Seurat you are using? Also, are your cell names correctly displayed in your object?

Let me know, also if you have any additional questions or problems.

inaciomdrs commented 7 months ago

Hi @c-thuil ,

The version of Seurat I'm using is 5.0.1. Yes, the cell names correctly displayed in the object.

nrosewick commented 4 months ago

Hi @c-thuil

I've the same issue. I use Seurat 5.0.0 . Any idea how to solve this ?

Thanks

c-thuil commented 4 months ago

Hi @nrosewick

The issue should have been resolved on the development version of CFS. The main branch will be updated soon. You can install it by replacing the "main" in the installation command with "development"

devtools::install_github("c-thuil/CFS"
                         ,ref="development")

Let me know if this works for you,

nrosewick commented 4 months ago

Hi @c-thuil

Thank you for the prompt answer. I tried with the development version but it still do not work. I checked Seurat's RunICA function and apparently they have issues with their new v5.0 version : https://github.com/satijalab/seurat/issues/8376

I can maybe contact directly Seurat's team.

Thanks

c-thuil commented 4 months ago

Hi @nrosewick

Yes, I believe the problem comes from the RunICA function from Seurat. In the meantime, I have already updated the development version of CFS to work without the RunICA function from Seurat. Can you see if this works for you now?