kimpenn / VisCello

Viscello for Visualization of Single Cell Data
21 stars 9 forks source link

Convert Seurat object to Expression set #5

Closed Gregory94 closed 3 years ago

Gregory94 commented 3 years ago

Dear Qinzhu,

I want to convert a seurat object to an expression data set using the code you provide in the readme, but I get the following error:

Error in validObject(.Object) :
  invalid class “ExpressionSet” object: 1: feature numbers differ between assayData and featureData
invalid class “ExpressionSet” object: 2: featureNames differ between assayData and featureData

This appears with the following code (R v4.0.4 and Seurat v4.0.1):

library(Seurat)
library(Biobase)
library(Matrix)
library(irlba)
library(VisCello)

#LOAD DATA
seurat <- readRDS(file='path/nonhematopoietic.rds')

#PREPARE EXPRESSION DATASET FROM SEURAT OBJECT
fmeta <- data.frame(symbol = rownames(seurat))
rownames(fmeta) <- fmeta$symbol
eset <- new("ExpressionSet",
            assayData = assayDataNew("environment", exprs=seurat@assays$RNA@counts,
                                     norm_exprs = seurat@assays$RNA@data),
            phenoData =  new("AnnotatedDataFrame", data = seurat@meta.data),
            featureData = new("AnnotatedDataFrame", data = fmeta))

I have checked the seurat object according to a similar issue I found in another thread and the seurat@assays$RNA@counts and seurat@assays$RNA@data entries have the same size and the order of the features are the same.

Do you have an idea how I could solve this issue?

Thanks in advance for your support!

Best, Gregory