Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to resolve error "all assays must have the same nrow and ncol"? #4633

Closed
denvercal1234GitHub opened this issue Jun 15, 2021 · 22 comments
Closed
Labels
more-information-needed We need more information before this can be addressed

Comments

@denvercal1234GitHub
Copy link

denvercal1234GitHub commented Jun 15, 2021

Hi there,

I hope to convert my Seurat object to SingleCellExperiment object, but I encountered an error.

  1. Similar to unresolved issue Which Assay to use before converting Seurat object to other object classes? #4534, should I change the DefaultAssay() of my Seurat object to RNA or SCT before doing the conversion?

  2. How to solve the error of Error in method(object) : all assays must have the same nrow and ncol?

I checked ncol() and ncol() of my Seurat object when I set active assay to SCT and RNA, and they have the same values..., but the error is still there.

Thank you for your help!

@NathanKenny
Copy link

I am also having the same issue number 2 as above. I think I have the latest R/Seurat/SingleCellExperiment versions. I would be very interested if anyone has had any luck resolving this!

Thanks in advance!

sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.2 LTS

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
[1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_GB.UTF-8 LC_COLLATE=en_GB.UTF-8
[5] LC_MONETARY=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8
[7] LC_PAPER=en_GB.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] parallel stats4 stats graphics grDevices utils datasets
[8] methods base

other attached packages:
[1] SeuratObject_4.0.2 Seurat_4.0.3
[3] loomR_0.2.1.9000 hdf5r_1.3.3
[5] R6_2.5.0 scater_1.20.0
[7] ggplot2_3.3.3 scuttle_1.2.0
[9] SingleCellExperiment_1.14.1 SummarizedExperiment_1.22.0
[11] Biobase_2.52.0 GenomicRanges_1.44.0
[13] GenomeInfoDb_1.28.0 IRanges_2.26.0
[15] S4Vectors_0.30.0 BiocGenerics_0.38.0
[17] MatrixGenerics_1.4.0 matrixStats_0.59.0

@blc49
Copy link

blc49 commented Jun 16, 2021

Update: If helpful, I was able to convert my seurat object to a SCE after running DietSeurat and keeping only the umap graph in addition to the counts and data slots.

Seurat_Object_Diet <- DietSeurat(Seurat_Object, graphs = "umap")

Seurat_Object_Diet
An object of class Seurat
25377 features across 47175 samples within 1 assay
Active assay: RNA (25377 features, 2000 variable features)
1 dimensional reduction calculated: umap

SCE <- as.SingleCellExperiment(Seurat_Object_Diet)

SCE
class: SingleCellExperiment
dim: 25377 47175
metadata(0):
assays(2): counts logcounts
rownames(25377): AL627309.1 AL627309.3 ... CCT8L2 C21orf91-OT1
rowData names(0):
colnames(47175): AAACCCAAGATGCTGG-1_1 AAACCCACACCAAAGG-1_1 ... TTTGTTGAGCAGATAT-1_16 TTTGTTGAGCGAGTAC-1_16
colData names(15): orig.ident nCount_RNA ... Predicted_JakelID ident
reducedDimNames(1): UMAP
altExpNames(0):

I am also having the same issue when trying to convert my seurat object to a SCE. I am still able to create a SCE from the pbmc test data. Thanks!

SCE <- as.SingleCellExperiment(Seurat_Object)
Error in method(object) : all assays must have the same nrow and ncol

Seurat_Object
An object of class Seurat
25377 features across 47175 samples within 1 assay
Active assay: RNA (25377 features, 2000 variable features)
3 dimensional reductions calculated: pca, tsne, umap

pbmc_sce <- as.SingleCellExperiment(pbmc)

pbmc
An object of class Seurat
13714 features across 2638 samples within 1 assay
Active assay: RNA (13714 features, 1838 variable features)
2 dimensional reductions calculated: pca, tsne

sessionInfo()
R version 4.0.4 (2021-02-15)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 10.16

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] parallel stats4 stats graphics grDevices utils datasets methods base

other attached packages:
[1] SeuratObject_4.0.2 Seurat_4.0.3 SingleCellExperiment_1.12.0 SummarizedExperiment_1.20.0
[5] Biobase_2.50.0 GenomicRanges_1.42.0 GenomeInfoDb_1.26.7 IRanges_2.24.1
[9] S4Vectors_0.28.1 BiocGenerics_0.36.1 MatrixGenerics_1.2.1 matrixStats_0.59.0

@alexjacobsCDS
Copy link

We are having the same issue as of very recently.

This code used to work

seurat_object = readRDS('/path/to/our/object.rds')
SCE <- as.SingleCellExperiment(seurat_object)

But now we are getting an error

Error in method(object) : all assays must have the same nrow and ncol

I think recent changes in Seurat have introduced a bug here.

Our session info

> sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
[1] C

attached base packages:
[1] parallel  stats4    stats     graphics  grDevices utils     datasets 
[8] methods   base     

other attached packages:
 [1] celldex_1.2.0               ensembldb_2.16.0           
 [3] AnnotationFilter_1.16.0     GenomicFeatures_1.44.0     
 [5] AnnotationDbi_1.54.1        scran_1.20.1               
 [7] scuttle_1.2.0               pheatmap_1.0.12            
 [9] viridis_0.6.1               viridisLite_0.4.0          
[11] scRNAseq_2.6.1              SingleCellExperiment_1.14.1
[13] SeuratObject_4.0.2          Seurat_4.0.3               
[15] SingleR_1.6.1               SummarizedExperiment_1.22.0
[17] Biobase_2.52.0              GenomicRanges_1.44.0       
[19] GenomeInfoDb_1.28.0         IRanges_2.26.0             
[21] S4Vectors_0.30.0            BiocGenerics_0.38.0        
[23] MatrixGenerics_1.4.0        matrixStats_0.59.0         

loaded via a namespace (and not attached):
  [1] utf8_1.2.1                    reticulate_1.20              
  [3] tidyselect_1.1.1              RSQLite_2.2.7                
  [5] htmlwidgets_1.5.3             grid_4.1.0                   
  [7] BiocParallel_1.26.0           Rtsne_0.15                   
  [9] munsell_0.5.0                 ScaledMatrix_1.0.0           
 [11] codetools_0.2-18              ica_1.0-2                    
 [13] statmod_1.4.36                future_1.21.0                
 [15] miniUI_0.1.1.1                withr_2.4.2                  
 [17] colorspace_2.0-1              filelock_1.0.2               
 [19] ROCR_1.0-11                   tensor_1.5                   
 [21] listenv_0.8.0                 labeling_0.4.2               
 [23] GenomeInfoDbData_1.2.6        polyclip_1.10-0              
 [25] farver_2.1.0                  bit64_4.0.5                  
 [27] parallelly_1.26.0             vctrs_0.3.8                  
 [29] generics_0.1.0                BiocFileCache_2.0.0          
 [31] R6_2.5.0                      rsvd_1.0.5                   
 [33] locfit_1.5-9.4                bitops_1.0-7                 
 [35] spatstat.utils_2.2-0          cachem_1.0.5                 
 [37] DelayedArray_0.18.0           assertthat_0.2.1             
 [39] promises_1.2.0.1              BiocIO_1.2.0                 
 [41] scales_1.1.1                  gtable_0.3.0                 
 [43] beachmat_2.8.0                globals_0.14.0               
 [45] goftest_1.2-2                 rlang_0.4.11                 
 [47] splines_4.1.0                 rtracklayer_1.52.0           
 [49] lazyeval_0.2.2                spatstat.geom_2.2-0          
 [51] BiocManager_1.30.16           yaml_2.2.1                   
 [53] reshape2_1.4.4                abind_1.4-5                  
 [55] httpuv_1.6.1                  tools_4.1.0                  
 [57] ggplot2_3.3.4                 ellipsis_0.3.2               
 [59] spatstat.core_2.1-2           RColorBrewer_1.1-2           
 [61] ggridges_0.5.3                Rcpp_1.0.6                   
 [63] plyr_1.8.6                    sparseMatrixStats_1.4.0      
 [65] progress_1.2.2                zlibbioc_1.38.0              
 [67] purrr_0.3.4                   RCurl_1.98-1.3               
 [69] prettyunits_1.1.1             rpart_4.1-15                 
 [71] deldir_0.2-10                 pbapply_1.4-3                
 [73] cowplot_1.1.1                 zoo_1.8-9                    
 [75] ggrepel_0.9.1                 cluster_2.1.2                
 [77] magrittr_2.0.1                data.table_1.14.0            
 [79] scattermore_0.7               lmtest_0.9-38                
 [81] RANN_2.6.1                    ProtGenerics_1.24.0          
 [83] fitdistrplus_1.1-5            hms_1.1.0                    
 [85] patchwork_1.1.1               mime_0.10                    
 [87] xtable_1.8-4                  XML_3.99-0.6                 
 [89] gridExtra_2.3                 compiler_4.1.0               
 [91] biomaRt_2.48.1                tibble_3.1.2                 
 [93] KernSmooth_2.23-20            crayon_1.4.1                 
 [95] htmltools_0.5.1.1             mgcv_1.8-36                  
 [97] later_1.2.0                   tidyr_1.1.3                  
 [99] DBI_1.1.1                     ExperimentHub_2.0.0          
[101] dbplyr_2.1.1                  MASS_7.3-54                  
[103] rappdirs_0.3.3                Matrix_1.3-4                 
[105] metapod_1.0.0                 igraph_1.2.6                 
[107] pkgconfig_2.0.3               GenomicAlignments_1.28.0     
[109] plotly_4.9.4                  spatstat.sparse_2.0-0        
[111] xml2_1.3.2                    dqrng_0.3.0                  
[113] XVector_0.32.0                stringr_1.4.0                
[115] digest_0.6.27                 sctransform_0.3.2            
[117] RcppAnnoy_0.0.18              spatstat.data_2.1-0          
[119] Biostrings_2.60.1             leiden_0.3.8                 
[121] edgeR_3.34.0                  uwot_0.1.10                  
[123] DelayedMatrixStats_1.14.0     restfulr_0.0.13              
[125] curl_4.3.1                    shiny_1.6.0                  
[127] Rsamtools_2.8.0               rjson_0.2.20                 
[129] lifecycle_1.0.0               nlme_3.1-152                 
[131] jsonlite_1.7.2                BiocNeighbors_1.10.0         
[133] limma_3.48.0                  fansi_0.5.0                  
[135] pillar_1.6.1                  lattice_0.20-44              
[137] KEGGREST_1.32.0               fastmap_1.1.0                
[139] httr_1.4.2                    survival_3.2-11              
[141] interactiveDisplayBase_1.30.0 glue_1.4.2                   
[143] png_0.1-7                     bluster_1.2.1                
[145] BiocVersion_3.13.1            bit_4.0.4                    
[147] stringi_1.6.2                 blob_1.2.1                   
[149] BiocSingular_1.8.1            AnnotationHub_3.0.0          
[151] memoise_2.0.0                 dplyr_1.0.6                  
[153] irlba_2.3.3                   future.apply_1.7.0  

We were able to get around this issue by following the advice of @blc49 and using DietSeurat

Seurat_Object_Diet <- DietSeurat(seurat_object, graphs = "pca")
SCE <- as.SingleCellExperiment(Seurat_Object_Diet)

@NathanKenny
Copy link

Dear @alexjacobsCDS

Many thanks, that seems to have done the trick!

Thanks again,

Nathan

@torkencz
Copy link
Collaborator

Hi can someone share an object (or a subsampled / dummy version that reproduces the issue) with us at [email protected] so we can fix this issue?

@torkencz torkencz added the more-information-needed We need more information before this can be addressed label Jun 25, 2021
@NathanKenny
Copy link

Dear @torkencz - I have sent through a link for you!

Many thanks,

Nathan

@ryeking2010
Copy link

Can confirm as well:
SCE <- as.SingleCellExperiment(Seurat_Obj)
was stable in 4.0.2, but breaks on 4.0.3.
SCE <- as.SingleCellExperiment(DietSeurat(Seurat_Obj))
Works without specifying graphs

@ksaunders73
Copy link

I tried to convert my seurat object to a singlecellexperiment (SCE) object after running SCTransform (making two assays, SCT and RNA, which I guess is what is causing the issue) and got this same issue. (Sorry for the longer example)

# Loading Raw Data into RStudio ---------------------------------- 

filePaths = getGEOSuppFiles("GSE110686") 
tarF <- list.files(path = "./GSE110686/", pattern = "*.tar", full.names = TRUE) 
untar(tarF, exdir = "./GSE110686/") 
gzipF <- list.files(path = "./GSE110686/", pattern = "*.gz", full.names = TRUE) 
ldply(.data = gzipF, .fun = gunzip) 

list.files(path = "./GSE110686/", pattern = "\\.mtx$",full.names = TRUE)
list.files(path = "./GSE110686/", pattern = "*.genes.tsv$", full.names = TRUE) 
list.files(path = "./GSE110686/", pattern = "*.barcodes.tsv$", full.names = TRUE) 



# Tumor Infiltrating Lymphocytes 20 Channel 1 ----------------------------------------------------------

matrix20_1 <- readMM(file = './GSE110686//GSM3011853_tils20_channel1_matrix.mtx')
matrix20_1 <- as.matrix(matrix20_1)

genes20_1 <- read.table(file = './GSE110686//GSM3011853_tils20_channel1_genes.tsv', 
                      sep = '\t', header = FALSE, stringsAsFactors = FALSE)
rownames(matrix20_1) <- genes20_1[,2]


barcodes20_1 <- read.table(file = './GSE110686//GSM3011853_tils20_channel1_barcodes.tsv', 
                         sep = '\t', header = FALSE, stringsAsFactors = FALSE)
colnames(matrix20_1) <- barcodes20_1[,1]

colnames(matrix20_1) <- paste(colnames(matrix20_1), "TIL20_1", sep = "_")
pdat20_1 <- data.frame("samples" = colnames(matrix20_1), "treatment" = "TIL20", "batch" = "20_1")


# Tumor Infiltrating Lymphocytes 20 Channel 2 ----------------------------------------------------------

matrix20_2 <- readMM(file = './GSE110686//GSM3011853_tils20_channel2_matrix.mtx')
matrix20_2 <- as.matrix(matrix20_2)

genes20_2 <- read.table(file = './GSE110686//GSM3011853_tils20_channel2_genes.tsv', 
                        sep = '\t', header = FALSE, stringsAsFactors = FALSE)
rownames(matrix20_2) <- genes20_2[,2]

barcodes20_2 <- read.table(file = './GSE110686//GSM3011853_tils20_channel2_barcodes.tsv', 
                           sep = '\t', header = FALSE, stringsAsFactors = FALSE)
colnames(matrix20_2) <- barcodes20_2[,1]

colnames(matrix20_2) <- paste(colnames(matrix20_2), "TIL20_2", sep = "_")
pdat20_2 <- data.frame("samples" = colnames(matrix20_2), "treatment" = "TIL20", "batch" = "20_2")


# Tumor Infiltrating Lymphocytes 32 ----------------------------------------------------------

matrix32 <- readMM(file = './GSE110686//GSM3011854_tils32_matrix.mtx')
matrix32 <- as.matrix(matrix32)

genes32 <- read.table(file = './GSE110686//GSM3011854_tils32_genes.tsv', 
                      sep = '\t', header = FALSE, stringsAsFactors = FALSE)
rownames(matrix32) <- genes32[,2]


barcodes32 <- read.table(file = './GSE110686//GSM3011854_tils32_barcodes.tsv', 
                         sep = '\t', header = FALSE, stringsAsFactors = FALSE)
colnames(matrix32) <- barcodes32[,1]

colnames(matrix32) <- paste(colnames(matrix32), "TIL32", sep = "_")
pdat32 <- data.frame("samples" = colnames(matrix32), "treatment" = "TIL32", "batch" = "32_1")



# Joined Matrices ----------------------------------------------------------

joined <- cbind(matrix20_1, matrix20_2, matrix32)
pdat_joined <- rbind(pdat20_1, pdat20_2, pdat32)

#take all gene lists and binds them into one matrix
whole_gene_list <- rbind(genes2032, genes20_1, genes20_2, genes32)
genelist <- whole_gene_list[!duplicated(whole_gene_list$V1), ]

#_________________________________________________________________
rownames(pdat_joined) <- pdat_joined$samples
fdat_joined <- toupper(as.matrix(genelist))
#_________________________________________________________________
rownames(fdat_joined) <- fdat_joined[,2]
fdat_joined <- data.frame(fdat_joined)
common_colnames <- c("ensembl_id", "gene_short_name")
colnames(fdat_joined) <- common_colnames
rownames(joined) <- rownames(fdat_joined)
#_________________________________________________________________
sobj_pre <- CreateSeuratObject(counts = joined)
sobj_pre <-AddMetaData(sobj_pre,metadata=pdat_joined)
head([email protected])
#_________________________________________________________________
sobj_pre[["RNA"]]@meta.features<-fdat_joined
head(sobj_pre[["RNA"]]@meta.features)
slotNames(sobj_pre[["RNA"]])

sobj <- sobj_pre



#SCTransform-------------------------------------------------------------

sobj <- PercentageFeatureSet(sobj, pattern = "^MT\\.", col.name = "percent.mt")
sobj <- SCTransform(sobj, vars.to.regress = "percent.mt", verbose = TRUE)


Then trying to convert it to an SCE object with and without specifying the assay:

sobjSCE <- as.SingleCellExperiment(sobj)
> Error in method(object) : all assays must have the same nrow and ncol

sobjSCE <- as.SingleCellExperiment(sobj, assay = "SCT")
> Error in method(object) : all assays must have the same nrow and ncol

sobjSCE <- as.SingleCellExperiment(DietSeurat(sobj)) works for me as well, but I am not sure if I lost the SCTransform in doing so (the SCT and RNA assays are listed but not under the "assays" slot - I am very new to SCE objects so I could just be confused here):

image

image

@torkencz
Copy link
Collaborator

torkencz commented Jul 1, 2021

@NathanKenny thank you for your object. I found what was happening. In the in line 1187 in as.SingleCellExperiment
scaledata = GetAssayData(object = x, assay = assayn, slot = "scale.data")) breaks things if you have less than all features as variable. I will try to fix it and see if it needs to be removed or not. Diet Seurat fixes that for now.

@no-response
Copy link

no-response bot commented Jul 9, 2021

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

@no-response no-response bot closed this as completed Jul 9, 2021
@andrewwbutler
Copy link
Collaborator

Hi all,

This bug should be resolved now on the develop branch. Please try installing (instructions here) to fix the issue.

@NathanKenny
Copy link

NathanKenny commented Jul 12, 2021 via email

@Lopo358
Copy link

Lopo358 commented Jul 13, 2021

I just installed the develop branch and still get the "Error in method(object) : all assays must have the same nrow and ncol"

@andrewwbutler
Copy link
Collaborator

Can you post your sessionInfo() @Lopo358 ?

@Lopo358
Copy link

Lopo358 commented Jul 13, 2021

@andrewwbutler

R version 4.0.1 (2020-06-06) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 18.04.3 LTS Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1 LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1 locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 [4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C [10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] grid stats4 parallel stats graphics grDevices utils datasets methods base other attached packages: [1] monocle3_1.0.0 SeuratWrappers_0.3.0 metacell_0.3.6 [4] limma_3.46.0 corrplot_0.90 SCopeLoomR_0.11.0 [7] autospill_0.2.0 devtools_2.4.2 usethis_2.0.1 [10] uwot_0.1.10 Matrix_1.3-4 ComplexHeatmap_2.6.2 [13] ConsensusClusterPlus_1.54.0 FlowSOM_1.22.0 CATALYST_1.14.1 [16] HDCytoData_1.10.0 flowCore_2.2.0 ExperimentHub_1.16.1 [19] readxl_1.3.1 installr_0.23.2 ggstatsplot_0.8.0 [22] here_1.0.1 BgeeCall_1.6.2 gmodels_2.18.1 [25] igraph_1.2.6 gatepoints_0.1.4 circlize_0.4.13 [28] ensembldb_2.14.1 AnnotationFilter_1.14.0 GenomicFeatures_1.42.3 [31] AnnotationDbi_1.52.0 AnnotationHub_2.22.1 BiocFileCache_1.14.0 [34] dbplyr_2.1.1 ggrepel_0.9.1 scales_1.1.1 [37] plyr_1.8.6 loomR_0.2.1.9000 itertools_0.1-3 [40] iterators_1.0.13 hdf5r_1.3.3 R6_2.5.0 [43] biomaRt_2.46.3 forcats_0.5.1 stringr_1.4.0 [46] dplyr_1.0.7 purrr_0.3.4 readr_1.4.0 [49] tidyr_1.1.3 tibble_3.1.2 tidyverse_1.3.1 [52] cowplot_1.1.1 scater_1.18.6 SingleCellExperiment_1.12.0 [55] SummarizedExperiment_1.20.0 GenomicRanges_1.42.0 GenomeInfoDb_1.26.7 [58] IRanges_2.24.1 S4Vectors_0.28.1 MatrixGenerics_1.2.1 [61] matrixStats_0.59.0 metap_1.4 multtest_2.46.0 [64] Biobase_2.50.0 BiocGenerics_0.36.1 MetaDE_2.2.3 [67] patchwork_1.1.1 ggplot2_3.3.5 SeuratDisk_0.0.0.9019 [70] SeuratObject_4.0.2 Seurat_4.0.3.9009 loaded via a namespace (and not attached): [1] PMCMRplus_1.9.0 tinytex_0.32 pbapply_1.4-3 [4] lattice_0.20-41 haven_2.4.1 vctrs_0.3.8 [7] mgcv_1.8-31 gmp_0.6-2 blob_1.2.1 [10] survival_3.2-3 RBGL_1.66.0 tgconfig_0.1.2 [13] spatstat.data_2.1-0 later_1.2.0 R.utils_2.10.1 [16] DBI_1.1.1 rappdirs_0.3.3 jpeg_0.1-8.1 [19] zlibbioc_1.36.0 MatrixModels_0.5-0 htmlwidgets_1.5.3 [22] mvtnorm_1.1-2 GlobalOptions_0.1.2 future_1.21.0 [25] leiden_0.3.8 pairwiseComparisons_3.1.6 irlba_2.3.3 [28] Rcpp_1.0.7 KernSmooth_2.23-17 promises_1.2.0.1 [31] kSamples_1.2-9 gdata_2.18.0 DelayedArray_0.16.3 [34] dbscan_1.1-8 pkgload_1.2.1 statsExpressions_1.1.0 [37] graph_1.68.0 RcppParallel_5.1.4 RSpectra_0.16-0 [40] fs_1.5.0 mnormt_2.0.2 digest_0.6.27 [43] png_0.1-7 sctransform_0.3.2.9007 pkgconfig_2.0.3 [46] DelayedMatrixStats_1.12.3 ggbeeswarm_0.6.0 nnls_1.4 [49] reticulate_1.20 spam_2.7-0 beeswarm_0.4.0 [52] GetoptLong_1.0.5 xfun_0.24 zoo_1.8-9 [55] tidyselect_1.1.1 performance_0.7.2 reshape2_1.4.4 [58] ica_1.0-2 viridisLite_0.4.0 rtracklayer_1.50.0 [61] pkgbuild_1.2.0 rlang_0.4.11 hexbin_1.28.2 [64] Rmpfr_0.8-4 glue_1.4.2 RColorBrewer_1.1-2 [67] modelr_0.1.8 umap_0.2.7.0 multcompView_0.1-8 [70] fields_12.5 RProtoBufLib_2.2.0 ggsignif_0.6.2 [73] bayestestR_0.10.0 DESeq2_1.30.1 labeling_0.4.2 [76] mutoss_0.1-12 httpuv_1.6.1 BiocNeighbors_1.8.2 [79] TH.data_1.0-10 annotate_1.68.0 jsonlite_1.7.2 [82] XVector_0.30.0 tmvnsim_1.0-2 bit_4.0.4 [85] shinyFiles_0.9.0 mime_0.11 gridExtra_2.3 [88] Rsamtools_2.6.0 stringi_1.6.2 processx_3.5.2 [91] insight_0.14.2 BWStest_0.2.2 spatstat.sparse_2.0-0 [94] scattermore_0.7 rbibutils_2.2.1 bitops_1.0-7 [97] cli_3.0.0 Rdpack_2.1.2 rhdf5filters_1.2.1 [100] maps_3.3.0 RSQLite_2.2.7 data.table_1.14.0 [103] correlation_0.6.1 rstudioapi_0.13 ggcyto_1.18.0 [106] GenomicAlignments_1.26.0 nlme_3.1-148 locfit_1.5-9.4 [109] listenv_0.8.0 samr_3.0 miniUI_0.1.1.1 [112] leidenbase_0.1.3 R.oo_1.24.0 sessioninfo_1.1.1 [115] lifecycle_1.0.0 munsell_0.5.0 cellranger_1.1.0 [118] R.methodsS3_1.8.1 moments_0.14 codetools_0.2-16 [121] coda_0.19-4 vipor_0.4.5 lmtest_0.9-38 [124] flowWorkspace_4.2.0 xtable_1.8-4 ROCR_1.0-11 [127] BiocManager_1.30.16 abind_1.4-5 farver_2.1.0 [130] parallelly_1.26.1 RANN_2.6.1 askpass_1.1 [133] SuppDists_1.1-9.5 RcppAnnoy_0.0.18 goftest_1.2-2 [136] cluster_2.1.0 drc_3.0-1 future.apply_1.7.0 [139] zeallot_0.1.0 ellipsis_0.3.2 prettyunits_1.1.1 [142] lubridate_1.7.10 ggridges_0.5.3 reprex_2.0.0 [145] tgstat_2.3.16 remotes_2.4.0 TFisher_0.2.0 [148] paletteer_1.3.0 parameters_0.14.0 testthat_3.0.4 [151] spatstat.utils_2.2-0 mc2d_0.1-21 htmltools_0.5.1.1 [154] yaml_2.2.1 ipmisc_6.0.2 utf8_1.2.1 [157] plotly_4.9.4.1 interactiveDisplayBase_1.28.0 XML_3.99-0.6 [160] aws.s3_0.3.21 foreign_0.8-80 withr_2.4.2 [163] scuttle_1.0.4 fitdistrplus_1.1-5 BiocParallel_1.24.1 [166] BayesFactor_0.9.12-4.2 bit64_4.0.5 effectsize_0.4.5 [169] multcomp_1.4-17 ProtGenerics_1.22.0 GSA_1.03.1 [172] Biostrings_2.58.0 spatstat.core_2.2-0 combinat_0.0-8 [175] cytolib_2.2.1 rsvd_1.0.5 memoise_2.0.0 [178] rio_0.5.27 callr_3.7.0 geneplotter_1.68.0 [181] ps_1.6.0 curl_4.3.2 fansi_0.5.0 [184] tensor_1.5 edgeR_3.32.1 cachem_1.0.5 [187] desc_1.3.0 deldir_0.2-10 impute_1.64.0 [190] rjson_0.2.20 openxlsx_4.2.4 tgutil_0.1.6 [193] clue_0.3-59 rprojroot_2.0.2 tools_4.0.1 [196] sandwich_3.0-1 magrittr_2.0.1 proxy_0.4-26 [199] RCurl_1.98-1.3 car_3.0-11 aws.signature_0.6.0 [202] xml2_1.3.2 httr_1.4.2 assertthat_0.2.1 [205] globals_0.14.0 Rhdf5lib_1.12.1 rslurm_0.6.0 [208] progress_1.2.2 tximport_1.18.0 genefilter_1.72.1 [211] gtools_3.9.2 shape_1.4.6 beachmat_2.6.4 [214] BiocVersion_3.12.0 rematch2_2.1.2 BiocSingular_1.6.0 [217] rhdf5_2.34.0 splines_4.0.1 carData_3.0-4 [220] colorspace_2.0-2 generics_0.1.0 base64enc_0.1-3 [223] ncdfFlow_2.36.0 CytoML_2.2.2 pillar_1.6.1 [226] sn_2.0.0 Rgraphviz_2.34.0 sp_1.4-5 [229] WRS2_1.1-2 GenomeInfoDbData_1.2.4 dotCall64_1.0-1 [232] pdist_1.2 gtable_0.3.0 rvest_1.0.0 [235] zip_2.2.0 lpSolveAPI_5.5.2.0-17.7 knitr_1.33 [238] latticeExtra_0.6-29 fastmap_1.1.0 Cairo_1.5-13 [241] broom_0.7.8 openssl_1.4.4 backports_1.2.1 [244] plotrix_3.8-1 tripack_1.3-9.1 hms_1.1.0 [247] Rtsne_0.15 shiny_1.6.0 polyclip_1.10-0 [250] numDeriv_2016.8-1.1 mathjaxr_1.4-0 lazyeval_0.2.2 [253] tsne_0.1-3 crayon_1.4.1 MASS_7.3-51.6 [256] sparseMatrixStats_1.2.1 viridis_0.6.1 reshape_0.8.8 [259] rpart_4.1-15 compiler_4.0.1 spatstat.geom_2.2-2

 

| >

@andrewwbutler
Copy link
Collaborator

Hmm, are you able to share the object (or downsampled version of the object) to reproduce the issue (email is [email protected] if you don't want to post here)?

@gAleryani
Copy link

gAleryani commented Jul 14, 2021

Hi Andrew,

Just thought to chime in as I had the same issue. Updating to the latest dev version did fix the issue however it appears there are sitll some other bugs. For example, it doesn't transfer the dimensional reduced data (PCA, UMAP, etc).

class: SingleCellExperiment 
dim: 45189 17438 
metadata(0):
assays(2): counts logcounts
rownames(45189): MIR1302-2HG FAM138A ... mm10---Oaz1 mm10---Rpl23a
rowData names(0):
colnames(17438): 4513_AAACCCAAGGTTAAAC 4513_AAACCCATCCTTCAGC ... 4660_4664_4676_TTTGTTGAGACGTCCC 4660_4664_4676_TTTGTTGCAGCTACCG
colData names(143): orig.ident nCount_RNA ... Figure_label ident
reducedDimNames(0):
altExpNames(2): RNA ADT

sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale:
[1] LC_COLLATE=English_Australia.1252 LC_CTYPE=English_Australia.1252 LC_MONETARY=English_Australia.1252 LC_NUMERIC=C LC_TIME=English_Australia.1252

attached base packages:
[1] parallel stats4 stats graphics grDevices utils datasets methods base

other attached packages:
[1] scater_1.18.6 ggplot2_3.3.3 SingleCellExperiment_1.12.0 SummarizedExperiment_1.20.0 Biobase_2.50.0 GenomicRanges_1.42.0
[7] GenomeInfoDb_1.26.7 IRanges_2.24.1 S4Vectors_0.28.1 BiocGenerics_0.36.1 MatrixGenerics_1.2.1 matrixStats_0.59.0
[13] SeuratObject_4.0.2 Seurat_4.0.3.9006

loaded via a namespace (and not attached):
[1] ggbeeswarm_0.6.0 Rtsne_0.15 colorspace_2.0-1 deldir_0.2-10 ellipsis_0.3.2 ggridges_0.5.3
[7] scuttle_1.0.4 XVector_0.30.0 BiocNeighbors_1.6.0 spatstat.data_2.1-0 leiden_0.3.8 listenv_0.8.0
[13] ggrepel_0.9.1 fansi_0.5.0 sparseMatrixStats_1.2.1 codetools_0.2-16 splines_4.0.3 polyclip_1.10-0
[19] jsonlite_1.7.2 ica_1.0-2 cluster_2.1.0 png_0.1-7 uwot_0.1.10.9000 pheatmap_1.0.12
[25] shiny_1.6.0 sctransform_0.3.2 spatstat.sparse_2.0-0 BiocManager_1.30.15 compiler_4.0.3 httr_1.4.2
[31] assertthat_0.2.1 Matrix_1.3-4 fastmap_1.0.1 lazyeval_0.2.2 BiocSingular_1.4.0 later_1.2.0
[37] htmltools_0.5.1.1 tools_4.0.3 rsvd_1.0.3 igraph_1.2.6 gtable_0.3.0 glue_1.4.2
[43] GenomeInfoDbData_1.2.4 RANN_2.6.1 reshape2_1.4.4 dplyr_1.0.6 Rcpp_1.0.6 scattermore_0.7
[49] vctrs_0.3.8 nlme_3.1-149 DelayedMatrixStats_1.12.3 lmtest_0.9-38 stringr_1.4.0 globals_0.14.0
[55] beachmat_2.6.4 mime_0.10 miniUI_0.1.1.1 lifecycle_1.0.0 irlba_2.3.3 goftest_1.2-2
[61] future_1.21.0 zlibbioc_1.36.0 MASS_7.3-53 zoo_1.8-9 scales_1.1.1 spatstat.core_2.1-2
[67] promises_1.2.0.1 spatstat.utils_2.1-0 RColorBrewer_1.1-2 reticulate_1.20 pbapply_1.4-3 gridExtra_2.3
[73] rpart_4.1-15 stringi_1.5.3 BiocParallel_1.24.1 rlang_0.4.11 pkgconfig_2.0.3 bitops_1.0-7
[79] lattice_0.20-41 tensor_1.5 ROCR_1.0-11 purrr_0.3.4 patchwork_1.1.1 htmlwidgets_1.5.3
[85] cowplot_1.1.1 tidyselect_1.1.1 parallelly_1.25.0 RcppAnnoy_0.0.18 plyr_1.8.6 magrittr_2.0.1
[91] R6_2.5.0 generics_0.1.0 DelayedArray_0.16.3 DBI_1.1.0 withr_2.4.2 mgcv_1.8-33
[97] pillar_1.6.1 fitdistrplus_1.1-5 survival_3.2-7 abind_1.4-5 RCurl_1.98-1.3 tibble_3.1.2
[103] future.apply_1.7.0 crayon_1.4.1 KernSmooth_2.23-17 utf8_1.2.1 spatstat.geom_2.1-0 dittoSeq_1.5.1
[109] plotly_4.9.4 viridis_0.6.1 grid_4.0.3 data.table_1.14.0 digest_0.6.27 xtable_1.8-4
[115] tidyr_1.1.3 httpuv_1.6.1 munsell_0.5.0 beeswarm_0.2.3 viridisLite_0.4.0 vipor_0.4.5

Thank you for all the work going to support interoperability!

@andrewwbutler
Copy link
Collaborator

Hi @gAleryani ,

Could you provide an example object? It seems DimReducs convert properly on my end.

library(Seurat)
#> Attaching SeuratObject
library(SeuratData)
#> Registered S3 method overwritten by 'cli':
#>   method     from         
#>   print.boxx spatstat.geom
#> ── Installed datasets ───────────────────────────────────── SeuratData v0.2.1 ──
#> ✓ pbmc3k   3.1.4                        ✓ stxBrain 0.1.1
#> ────────────────────────────────────── Key ─────────────────────────────────────
#> ✓ Dataset loaded successfully
#> > Dataset built with a newer version of Seurat than installed
#> ❓ Unknown version of Seurat installed
pbmc3k.final
#> An object of class Seurat 
#> 13714 features across 2638 samples within 1 assay 
#> Active assay: RNA (13714 features, 2000 variable features)
#>  2 dimensional reductions calculated: pca, umap
as.SingleCellExperiment(pbmc3k.final)
#> class: SingleCellExperiment 
#> dim: 13714 2638 
#> metadata(0):
#> assays(3): counts logcounts scaledata
#> rownames(13714): AL627309.1 AP006222.2 ... PNRC2.1 SRSF10.1
#> rowData names(0):
#> colnames(2638): AAACATACAACCAC AAACATTGAGCTAC ... TTTGCATGAGAGGC
#>   TTTGCATGCCTCAC
#> colData names(8): orig.ident nCount_RNA ... seurat_clusters ident
#> reducedDimNames(2): PCA UMAP
#> mainExpName: RNA
#> altExpNames(0):

Created on 2021-07-14 by the reprex package (v2.0.0)

@gAleryani
Copy link

gAleryani commented Jul 15, 2021

Hi @andrewwbutler,
Thanks for the quick reply, using the data you guys generated it does work as you can see below, and under further investigation, I now find that it doesn't work on reduced dim data calculated prior to integration or to some other proclivities that I can't explain.
Further below, I show an example where I re-run PCA on my integrated object, it took the rerun PCA info but not the ones calculated prior to integration when I converted to SCE obj.


`> library(Seurat)
Attaching SeuratObject
> library(SeuratData)
Registered S3 method overwritten by 'cli':
  method     from         
  print.boxx spatstat.geom
-- Installed datasets ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- SeuratData v0.2.1 --
v cbmc         3.1.4                                                                                                               v pbmcMultiome 0.1.0
v pbmc3k       3.1.4                                                                                                               

--------------------------------------------------------------------------------------------------------------------------------- Key ---------------------------------------------------------------------------------------------------------------------------------
v Dataset loaded successfully
> Dataset built with a newer version of Seurat than installed
(?) Unknown version of Seurat installed

There were 12 warnings (use warnings() to see them)
> pbmc3k.final
An object of class Seurat 
13714 features across 2638 samples within 1 assay 
Active assay: RNA (13714 features, 2000 variable features)
 2 dimensional reductions calculated: pca, umap
> sce <- as.SingleCellExperiment(pbmc3k.final)
> sce
class: SingleCellExperiment 
dim: 13714 2638 
metadata(0):
assays(3): counts logcounts scaledata
rownames(13714): AL627309.1 AP006222.2 ... PNRC2.1 SRSF10.1
rowData names(0):
colnames(2638): AAACATACAACCAC AAACATTGAGCTAC ... TTTGCATGAGAGGC TTTGCATGCCTCAC
colData names(8): orig.ident nCount_RNA ... seurat_clusters ident
reducedDimNames(2): PCA UMAP
altExpNames(0):`

########################################


`seurat_obj <- readRDS("sobj_processed.rds")
DefaultAssay(seurat_obj) <- "RNA"
seurat_obj <- NormalizeData(seurat_obj) %>% FindVariableFeatures() %>% ScaleData()
seurat_obj <- RunPCA(seurat_obj, reduction.name = "rerunPCA")
seurat_obj

> An object of class Seurat 
> 75334 features across 17438 samples within 4 assays 
> Active assay: RNA (45189 features, 2000 variable features)
>  4 other assays present: ADT, SCT, RNA, integratedRNA
>  5 dimensional reductions calculated: irpca, irna.umap, intwnn.umap, pca, rerunPCA

sce <- as.SingleCellExperiment(seurat_obj)
sce

> class: SingleCellExperiment 
> dim: 45189 17438 
> metadata(0):
> assays(2): counts logcounts
> rownames(45189): MIR1302-2HG FAM138A ... mm10---Oaz1 mm10---Rpl23a
> rowData names(0):
> colnames(17438): 4513_AAACCCAAGGTTAAAC 4513_AAACCCATCCTTCAGC ... 4660_4664_4676_TTTGTTGAGACGTCCC 4660_4664_4676_TTTGTTGCAGCTACCG
> colData names(144): orig.ident nCount_RNA ... Figure_cluster_label_final ident
> reducedDimNames(1): RERUNPCA
> altExpNames(4): RNA ADT SCT integratedRNA 
`

Thanks again for the help, and I understand if this is a low priority investigation :)

@andrewwbutler
Copy link
Collaborator

I believe this is because SingleCellExperiment associates the reducedDims with the experiment. If you swap the main and alternative Experiments (assuming you are using the latest version of SingleCellExperiment), you should then see the other reducedDims printed out.

@Lopo358
Copy link

Lopo358 commented Jul 16, 2021

@gAleryani

Thanks for the quick reply, using the data you guys generated it does work as you can see below, and u

Exactly, my seurat object was clustered and the dataset was merged, not integrated

@gAleryani
Copy link

You were right on point with this one @andrewwbutler, thanks for solving this one for me, I should have dug deeper on how SingleCellExperiment objects are structured, my bad!

Thanks again! :)

@Lopo358 Does using one of the datasets provided by SeuratDisk, such as the 'pbmc3k' example provided above, work for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
more-information-needed We need more information before this can be addressed
Projects
None yet
Development

No branches or pull requests

10 participants