satijalab / seurat-object Goto Github PK
View Code? Open in Web Editor NEWHome Page: https://satijalab.github.io/seurat-object/
License: Other
Home Page: https://satijalab.github.io/seurat-object/
License: Other
Hi,
I am having some trouble in merging individual v5 objects into a single one using merge() using Seurat v 5.0.1. The merged object gets created but I have multiple layers for counts (counts.1, counts.2, counts.3 etc) which is causing trouble in downstream analyses. Is there a way to avoid this from happening and have just a single counts layer for my merged object? Thanks.
After updating my R Studio to version 4.3.2, and the package "Matrix" to version 1.6-1.1, I have problems reading rds files with readRDS().
I am using the developer Seurat version 5.0.0.
I am accessing the rds file via synapser, with synGet(object), reading the file with readRDS(object$path).
After this I get a message to run UpdateSeuratObject(), after which I receive this error:
object<-UpdateSeuratObject(object)
Validating object structure
Updating object slots
Ensuring keys are in the proper structure
Updating matrix keys for DimReduc ‘pca’
Updating matrix keys for DimReduc ‘umap’
Updating matrix keys for DimReduc ‘harmony’
Updating matrix keys for DimReduc ‘umapharmony’
Warning: Assay RNA changing from Assay to Assay
Error in [[<-:
! Cannot add new cells with [[<-
Run rlang::last_trace() to see where the error occurred.
rlang::last_trace()
<error/rlang_error>
Error in [[<-:
! Cannot add new cells with [[<-
Backtrace:
▆
└─SeuratObject::UpdateSeuratObject(object)
├─base::suppressWarnings(...)
│ └─base::withCallingHandlers(...)
├─methods (local) [[<-(tmp, obj, value = <Assay[,24025]>)
└─SeuratObject (local) [[<-(tmp, obj, value = <Assay[,24025]>)
Run rlang::last_trace(drop = FALSE) to see 1 hidden frame.
Hello,
I have a suggestion to add an NA-excluding function such as which()
in line 18 of the function CellsByIdentities, to produce more sensible output for the edge case when Idents(seur)
contains NAs.
from:
cells.idents <- sapply(X = idents, FUN = function(i) {
return(cells[as.vector(x = Idents(object = object)[cells]) == i])
}, simplify = FALSE, USE.NAMES = TRUE)
to:
cells.idents <- sapply(X = idents, FUN = function(i) {
return(cells[which(as.vector(x = Idents(object = object)[cells]) == i)])
}, simplify = FALSE, USE.NAMES = TRUE)
..so that cells.idents
will contain only barcodes (and no NAs) even if the currently set Ident of the Seurat object contains NAs.
An example where the NA-ridden output currently causes an issue is in lines 25-28 of Seurat::DotPlot:
cells <- unlist(x = CellsByIdentities(object = object, cells = colnames(object[[assay]]),
idents = idents))
data.features <- FetchData(object = object, vars = features,
cells = cells)
which gives the following error:
Error in `.rowNamesDF<-`(x, value = value) :
duplicate 'row.names' are not allowed
In addition: Warning message:
non-unique values when setting 'row.names':
since cells
contains multiple NA's.
The output in question of CellsByIdentities can be examined with:
seur$orig.ident[1:10] = NA
Idents(seur) <- 'orig.ident'
cells <- CellsByIdentities(cells)
str(cells)
And the error in DotPlot it causes can be produced with one further line:
DotPlot(seur, features, group.by = 'seurat_clusters')
SeuratObject 4.1.1, 4.1.0, and 4.0.4 installs (did not test earlier than that) all fail with a segfault.
Have 4.0.4 currently installed.
R version 4.1.3 (newest version available from RHEL repos)
RHEL 8
gcc -m64 -I"/usr/include/R" -DNDEBUG -I'/home/MYUSER/R/x86_64-redhat-linux-gnu-library/4.1/Rcpp/include' -I'/home/MYUSER/R/x86_64-redhat-linux-gnu-library/4.1/RcppEigen/include' -I/usr/local/include -fpic -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -c valid_pointer.c -o valid_pointer.o
g++ -m64 -std=gnu++14 -shared -L/usr/lib64/R/lib -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -o SeuratObject.so RcppExports.o data_manipulation.o valid_pointer.o -L/usr/lib64/R/lib -lR
installing to /home/MYUSER/R/x86_64-redhat-linux-gnu-library/4.1/00LOCK-SeuratObject/00new/SeuratObject/libs
** R
** data
*** moving datasets to lazyload DB
** byte-compile and prepare package for lazy loading
sh: line 1: 1719819 Segmentation fault (core dumped) R_TESTS= '/usr/lib64/R/bin/R' --no-save --no-restore --no-echo 2>&1 < '/tmp/RtmpwB0npY/file1a3df21daa0c36'
*** caught segfault ***
address 0xffffffffffffffff, cause 'memory not mapped'
An irrecoverable exception occurred. R is aborting now ...
ERROR: lazy loading failed for package 'SeuratObject'
Hello,
for atlas-size analyses, memory consumption is a limiting factor.
Is there any plan to port DelayedArray to Seurat?
https://bioconductor.org/packages/release/bioc/html/DelayedArray.html
https://petehaitch.github.io/BioC2020_DelayedArray_workshop/articles/Effectively_using_the_DelayedArray_framework_for_users.html
Hello,
I try to make pca on merged data.
The two datasets are individually normalized by SCT, then merged by merge() function.
Usually, the HVG drop and I replace them thanks to genes list of scale.data, but now the scale.data slot droped too (empty matrix).
But if I manually load the function merge.Seurat() with its dependant functions, that's work and I have got scale.data slot.
Have you any issue for that?
Thank you!
Seurat version: 4.0.1
SeuratObject version: 4.0.0
Hello, first thank you for developing such great tools
I am Ruba PhD student in Germany and I am doing scRNAseq analysis for my data, I wanted to check the velocity and so I generated the loom files by velacyto, I wanted to continue with Seurat with .r but unfortunately am facing some errors, I looked many published errors, tried to downgrade the Matrix Package (where Seurat didn't work anymore) I had to upgrade it again, the error am facing is | | 0%Error in validObject(.Object) :
invalid class “LogMap” object: Duplicate rownames not allowed
taking into account there's no duplicated rownames could somebody kindly look into it and give an advice if something could be done so I can go through the velocity analysis in the end.
thank you in advance
Kind regards!
library(Seurat)
library(SeuratWrappers)
library(velocyto.R)
library(Matrix)
ldat <- ReadVelocity(file = "E11.5.possorted_genome_bam_BX5BE.loom")
Seurat::bm <- as.Seurat(x= ldat)
output
| | 0%Error in validObject(.Object) :
invalid class “LogMap” object: Duplicate rownames not allowed
any(duplicated(rownames(ldat)))
[1] FALSE
> class(ldat)
[1] "list"
> str(ldat)
List of 3
$ spliced :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
.. ..@ i : int [1:12963443] 100 110 111 177 263 376 461 467 472 500 ...
.. ..@ p : int [1:14699] 0 679 1555 2345 3484 3870 5098 6066 7591 8934 ...
.. ..@ Dim : int [1:2] 32285 14698
.. ..@ Dimnames:List of 2
.. .. ..$ : chr [1:32285] "AC125149.3" "AC125149.5" "AC125149.2" "AC125149.1" ...
.. .. ..$ : chr [1:14698] "possorted_genome_bam_BX5BE:AAAGCAACAGGTCGTCx" "possorted_genome_bam_BX5BE:AAAGCAATCTGCGTAAx" "possorted_genome_bam_BX5BE:AAACGGGCAGATGAGCx" "possorted_genome_bam_BX5BE:AAAGCAAGTACAGTTCx" ...
.. ..@ x : num [1:12963443] 1 2 1 1 1 1 1 1 2 1 ...
.. ..@ factors : list()
$ unspliced:Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
.. ..@ i : int [1:7903683] 195 411 501 526 548 586 615 723 851 985 ...
.. ..@ p : int [1:14699] 0 309 579 864 1999 2017 2490 2712 4181 4807 ...
.. ..@ Dim : int [1:2] 32285 14698
.. ..@ Dimnames:List of 2
.. .. ..$ : chr [1:32285] "AC125149.3" "AC125149.5" "AC125149.2" "AC125149.1" ...
.. .. ..$ : chr [1:14698] "possorted_genome_bam_BX5BE:AAAGCAACAGGTCGTCx" "possorted_genome_bam_BX5BE:AAAGCAATCTGCGTAAx" "possorted_genome_bam_BX5BE:AAACGGGCAGATGAGCx" "possorted_genome_bam_BX5BE:AAAGCAAGTACAGTTCx" ...
.. ..@ x : num [1:7903683] 2 3 2 1 1 1 3 1 1 1 ...
.. ..@ factors : list()
$ ambiguous:Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
.. ..@ i : int [1:1881126] 214 274 615 738 783 867 1469 2097 2828 2954 ...
.. ..@ p : int [1:14699] 0 85 160 245 453 481 617 714 1038 1231 ...
.. ..@ Dim : int [1:2] 32285 14698
.. ..@ Dimnames:List of 2
.. .. ..$ : chr [1:32285] "AC125149.3" "AC125149.5" "AC125149.2" "AC125149.1" ...
.. .. ..$ : chr [1:14698] "possorted_genome_bam_BX5BE:AAAGCAACAGGTCGTCx" "possorted_genome_bam_BX5BE:AAAGCAATCTGCGTAAx" "possorted_genome_bam_BX5BE:AAACGGGCAGATGAGCx" "possorted_genome_bam_BX5BE:AAAGCAAGTACAGTTCx" ...
.. ..@ x : num [1:1881126] 1 1 1 1 1 2 1 1 1 1 ...
.. ..@ factors : list()
> sessionInfo()
R version 4.3.2 (2023-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 22621)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C LC_TIME=English_United States.utf8
time zone: Europe/Berlin
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] velocyto.R_0.6 Matrix_1.6-4 SeuratWrappers_0.3.2 Seurat_5.0.1 SeuratObject_5.0.1 sp_2.1-2
loaded via a namespace (and not attached):
[1] RColorBrewer_1.1-3 rstudioapi_0.15.0 jsonlite_1.8.8 magrittr_2.0.3 spatstat.utils_3.0-4 fs_1.6.3
[7] vctrs_0.6.4 ROCR_1.0-11 memoise_2.0.1 spatstat.explore_3.2-5 htmltools_0.5.7 usethis_2.2.2
[13] sctransform_0.4.1 parallelly_1.36.0 KernSmooth_2.23-22 htmlwidgets_1.6.4 ica_1.0-3 plyr_1.8.9
[19] plotly_4.10.3 zoo_1.8-12 cachem_1.0.8 igraph_1.6.0 mime_0.12 lifecycle_1.0.4
[25] pkgconfig_2.0.3 rsvd_1.0.5 R6_2.5.1 fastmap_1.1.1 fitdistrplus_1.1-11 future_1.33.1
[31] shiny_1.8.0 digest_0.6.33 pcaMethods_1.92.0 colorspace_2.1-0 patchwork_1.2.0 tensor_1.5
[37] RSpectra_0.16-1 irlba_2.3.5.1 pkgload_1.3.3 progressr_0.14.0 fansi_1.0.6 spatstat.sparse_3.0-3
[43] httr_1.4.7 polyclip_1.10-6 abind_1.4-5 mgcv_1.9-0 compiler_4.3.2 remotes_2.4.2.1
[49] bit64_4.0.5 fastDummies_1.7.3 pkgbuild_1.4.3 R.utils_2.12.3 MASS_7.3-60 sessioninfo_1.2.2
[55] tools_4.3.2 lmtest_0.9-40 httpuv_1.6.12 future.apply_1.11.1 goftest_1.2-3 R.oo_1.25.0
[61] glue_1.6.2 nlme_3.1-163 promises_1.2.1 grid_4.3.2 Rtsne_0.17 cluster_2.1.4
[67] reshape2_1.4.4 generics_0.1.3 hdf5r_1.3.8 gtable_0.3.4 spatstat.data_3.0-3 R.methodsS3_1.8.2
[73] tidyr_1.3.0 data.table_1.14.10 utf8_1.2.4 BiocGenerics_0.48.1 spatstat.geom_3.2-7 RcppAnnoy_0.0.21
[79] ggrepel_0.9.5 RANN_2.6.1 pillar_1.9.0 stringr_1.5.1 spam_2.10-0 RcppHNSW_0.5.0
[85] later_1.3.1 splines_4.3.2 dplyr_1.1.4 lattice_0.21-9 bit_4.0.5 survival_3.5-7
[91] deldir_2.0-2 tidyselect_1.2.0 miniUI_0.1.1.1 pbapply_1.7-2 gridExtra_2.3 scattermore_1.2
[97] Biobase_2.62.0 devtools_2.4.5 matrixStats_1.2.0 stringi_1.8.3 lazyeval_0.2.2 codetools_0.2-19
[103] tibble_3.2.1 BiocManager_1.30.22 cli_3.6.1 uwot_0.1.16 xtable_1.8-4 reticulate_1.34.0
[109] munsell_0.5.0 Rcpp_1.0.11 globals_0.16.2 spatstat.random_3.2-2 png_0.1-8 parallel_4.3.2
[115] ellipsis_0.3.2 ggplot2_3.4.4 dotCall64_1.1-1 profvis_0.3.8 urlchecker_1.0.1 listenv_0.9.0
[121] viridisLite_0.4.2 scales_1.3.0 ggridges_0.5.5 leiden_0.4.3.1 purrr_1.0.2 rlang_1.1.2
[127] cowplot_1.1.2
Dear Seurat Team,
I used FetchData(object = obj, vars = "UMAP_1")
to retrieve UMAP coordinates in Seurat.utils::AutoNumber.by.UMAP()
.
This worked until Seurat v5. After Seurat v5 it still executed without a warning, but the coordinates returned did not correspond to the umap plotted.
UMAP_1
got renamed to umap_1
, in @reductions$umap
FetchData
now silently returns UMAP_1
from obj@reductions$ref.umap
instead from obj@reductions$umap
.ref.umap
, and getting values from it is very unexpected when asking for a umap coordinate. I needed to look through 2MB of "str(obj)" output to get this info.FetchData
, bc I rather break the code then get meaningless values to figure out much later.break early
.?FetchData
to use as: pc1 <- FetchData(object = pbmc_small, vars = 'PC_1')
, bc apparently you would need to specify the PCA
slot to be sure what to get.Seurat
, where sth is returned without message/warning/error, so this is also a general request to increase prudency. See example: NA values in DiscretePalette
needed to be handled by quick and dirty Seurat.utils::DiscretePaletteSafe()
.Thank you for your time sharing and maintaining the code.
Abel
I am trying to merge several large Seurat object iteratively using the following code:
while(length(counts) > 0) {
obj <- merge(obj, counts[[1]])
counts[[1]] <- NULL
pb$tick(tokens = list(ncells=as.character(ncol(obj))))
}
where I iterate over counts
and not use the merge
feature that accepts a list of objects so to understand at what point it fails. It fails with the following error:
Merging groups to single object - 303107 in object 2/9 [====>-----------------] 22% in 16m. ETA 1h
Error in RowMergeMatricesList(mat_list = all.mat, mat_rownames = all.rownames, :
vector::reserve
Calls: subset.cell.type ... merge.Assay -> RowMergeSparseMatrices -> RowMergeMatricesList
Execution halted
where the first line is printed by the progress_bar
library. It shows that it crashes once I try to merge the third object into the first+second. All these objects have a similar number of samples and features - so it crashes when trying to create an object of about 450k samples (over I assume about 35-40k features). At the end there are over one million samples to merge between those 9 objects.
What should I do?
Hello,
I assume this might be due to an updated seurat version, but our code just started spitting out this warning:
2021-05-10T06:32:14.3076028Z 11. Seurat:::PseudobulkExpression(...)
2021-05-10T06:32:14.3076758Z 13. SeuratObject:::CreateSeuratObject.default(...)
2021-05-10T06:32:14.3077559Z 14. SeuratObject::CreateAssayObject(...)
2021-05-10T06:32:14.3078195Z 16. SeuratObject:::as.sparse.matrix(x = counts, ...)
2021-05-10T06:32:14.3078760Z 17. SeuratObject:::CheckDots(...)
From what I can see, this is b/c as.sparse.Matrix is called here, with "...":
and yet here it's called with the argument row.names:
should it?
Hello,
I am getting an error about not able find the function .GetSeuratCompat when using SCTransform.
After spending a whole afternoon searching for the reason and checking if someone else has come across this issue, I think I have stumbled upon a unique error.
I am running this on a HPC using 16 cores and 128GB of memory, if that matters.
I have run SCTransform with and without the conserve memory = T
argument, and in both cases stumbles at the centering data matrix with the following error:
Computing corrected UMI count matrix
Place corrected count matrix in counts slot
Centering data matrix
Error in .GetSeuratCompat() : could not find function ".GetSeuratCompat"
Execution halted
Here are the package versions I am using:
"Package": "Seurat", "Version": "4.4.0"
"Package": "SeuratObject", "Version": "4.1.4"
I would appreciate it if anyone has any input to solve this error!
Thank you,
Ishwar
When using AddMetaData
to add metadata columns via a data.frame
object, the resulting added columns contain only NA
s instead of the actual data.
library("Seurat")
dims <- c(5, 6)
dim_names <- list(LETTERS[seq_len(dims[1])], letters[seq_len(dims[2])])
data <- `dimnames<-`(
matrix(runif(dims[1] * dims[2]), nrow = dims[1], ncol = dims[2]),
dim_names
)
meta_data <- data.frame(cell_type = as.character(seq_len(ncol(data))))
mini_so <- CreateSeuratObject(data)
mini_so_meta <- AddMetaData(mini_so, meta_data)
cat("\n\nmeta_data:\n")
print(meta_data)
cat("\n\nSeurat object metadata slot, should contain meta_data:\n")
print(mini_so_meta@meta.data)
cat("\n\nSession info:\n")
print(sessionInfo())
Excerpt output for ´[email protected]`:
orig.ident nCount_RNA nFeature_RNA cell_type
a SeuratProject 1.439934 5 <NA>
b SeuratProject 1.714582 5 <NA>
c SeuratProject 3.170943 5 <NA>
d SeuratProject 2.085310 5 <NA>
e SeuratProject 3.430311 5 <NA>
f SeuratProject 2.643897 5 <NA>
Full output:
The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,
which was just loaded, were retired in October 2023.
Please refer to R-spatial evolution reports for details, especially
https://r-spatial.org/r/2023/05/15/evolution4.html.
It may be desirable to make the sf package available;
package maintainers should consider adding sf to Suggests:.
Attaching SeuratObject
meta_data:
cell_type
1 1
2 2
3 3
4 4
5 5
6 6
Seurat object metadata slot, should contain meta_data:
orig.ident nCount_RNA nFeature_RNA cell_type
a SeuratProject 2.442678 5 <NA>
b SeuratProject 2.598159 5 <NA>
c SeuratProject 2.018998 5 <NA>
d SeuratProject 2.494010 5 <NA>
e SeuratProject 3.467824 5 <NA>
f SeuratProject 1.654405 5 <NA>
Session info:
R version 4.3.1 (2023-06-16)
Platform: x86_64-unknown-linux-gnu (64-bit)
Running under: Ubuntu 22.04.2 LTS
Matrix products: default
BLAS/LAPACK: /gnu/store/d94sxy6axgzd3xr6bnp49l4v1nqzf825-openblas-0.3.20/lib/libopenblasp-r0.3.20.so; LAPACK version 3.9.0
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
time zone: Europe/Berlin
tzcode source: system (glibc)
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] SeuratObject_4.1.4 Seurat_4.4.0
loaded via a namespace (and not attached):
[1] deldir_1.0-9 pbapply_1.7-2 gridExtra_2.3
[4] rlang_1.1.1 magrittr_2.0.3 RcppAnnoy_0.0.21
[7] matrixStats_1.0.0 ggridges_0.5.4 compiler_4.3.1
[10] spatstat.geom_3.2-5 png_0.1-8 vctrs_0.6.3
[13] reshape2_1.4.4 stringr_1.5.0 pkgconfig_2.0.3
[16] fastmap_1.1.1 ellipsis_0.3.2 utf8_1.2.3
[19] promises_1.2.1 purrr_1.0.2 jsonlite_1.8.7
[22] goftest_1.2-3 later_1.3.1 spatstat.utils_3.0-3
[25] irlba_2.3.5.1 parallel_4.3.1 cluster_2.1.4
[28] R6_2.5.1 ica_1.0-3 stringi_1.7.12
[31] RColorBrewer_1.1-3 spatstat.data_3.0-1 reticulate_1.32.0
[34] parallelly_1.36.0 lmtest_0.9-40 scattermore_1.2
[37] Rcpp_1.0.11 tensor_1.5 future.apply_1.11.0
[40] zoo_1.8-12 sctransform_0.4.0 httpuv_1.6.11
[43] Matrix_1.6-1.1 splines_4.3.1 igraph_1.5.1
[46] tidyselect_1.2.0 abind_1.4-5 codetools_0.2-19
[49] spatstat.random_3.1-6 miniUI_0.1.1.1 spatstat.explore_3.2-3
[52] listenv_0.9.0 lattice_0.21-9 tibble_3.2.1
[55] plyr_1.8.9 shiny_1.7.4 ROCR_1.0-11
[58] Rtsne_0.16 future_1.33.0 survival_3.5-7
[61] polyclip_1.10-6 fitdistrplus_1.1-11 pillar_1.9.0
[64] KernSmooth_2.23-22 plotly_4.10.2 generics_0.1.3
[67] sp_2.1-0 ggplot2_3.4.3 munsell_0.5.0
[70] scales_1.2.1 globals_0.16.2 xtable_1.8-4
[73] glue_1.6.2 lazyeval_0.2.2 tools_4.3.1
[76] data.table_1.14.8 RANN_2.6.1 leiden_0.4.3
[79] cowplot_1.1.1 grid_4.3.1 tidyr_1.3.0
[82] colorspace_2.1-0 nlme_3.1-163 patchwork_1.1.3
[85] cli_3.6.1 spatstat.sparse_3.0-2 fansi_1.0.5
[88] viridisLite_0.4.2 dplyr_1.1.3 uwot_0.1.16
[91] gtable_0.3.4 digest_0.6.33 progressr_0.14.0
[94] ggrepel_0.9.3 htmlwidgets_1.6.2 htmltools_0.5.6.1
[97] lifecycle_1.0.3 httr_1.4.7 mime_0.12
[100] MASS_7.3-60
When trying to add feature metadata to Seurat v5 object using the nromal SeuratObject::AddMetaData() you get the following error
Error in `LayerData<-`:
! 'layer' must be a single non-empty string
Reprex
library(Seurat)
library(SeuratData)
library(BPCells)
library(dplyr)
options(Seurat.object.assay.version = "v5")
pbmc3k <- SeuratData::LoadData("pbmc3k")
pbmc3k_feature_data <- pbmc3k[["RNA"]][["counts"]] |>
dplyr::mutate(new_vairable =sample(1:100, nrow(pbmc3k), replace = TRUE))
pbmc3k[["RNA"]] <- SeuratObject::AddMetaData(pbmc3k[["RNA"]], metadata = pbmc3k_feature_data)
Hi team,
Greetings from the LIGER team!
Recently, we have been addressing the updates from Seurat 5. We have made some patches and is trying to pass the CRAN check, however it is blocked by the LogMap()
, only on winbuilder though. I can reproduce the error at my local with the following info:
> library(SeuratObject)
Loading required package: sp
‘SeuratObject’ was built with package ‘Matrix’ 1.6.1.1 but the current version is 1.6.2; it is recomended
that you reinstall ‘SeuratObject’ as the ABI for ‘Matrix’ may have changed
Attaching package: ‘SeuratObject’
The following objects are masked from ‘package:base’:
%||%, intersect
> LogMap(2)
Error in validObject(.Object) :
invalid class “LogMap” object: superclass "mMatrix" not defined in the environment of the object's class
> sessionInfo()
R Under development (unstable) (2023-11-06 r85483 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 10 x64 (build 19045)
Matrix products: default
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] SeuratObject_5.0.0 sp_2.1-1
loaded via a namespace (and not attached):
[1] digest_0.6.33 progressr_0.14.0 dotCall64_1.1-0 codetools_0.2-19 Matrix_1.6-2
[6] lattice_0.22-5 parallel_4.4.0 generics_0.1.3 lifecycle_1.0.4 cli_3.6.1
[11] parallelly_1.36.0 future_1.33.0 grid_4.4.0 compiler_4.4.0 globals_0.16.2
[16] rstudioapi_0.15.0 tools_4.4.0 listenv_0.9.0 future.apply_1.11.0 Rcpp_1.0.11
[21] rlang_1.1.2 spam_2.10-0
It's quite unclear to me why LogMap, which should be just an extension around the base matrix class, can be related to some Matrix classes. However, I found something I can do to get rid of it temporarily which is just setOldClass("mMatrix")
. And I'm planning to have a if
condition for Matrix version check to related example code, so that we can have a release asap (rliger is currently archived due to other dependencies). Have you already been aware of such an issue? If so, do you have any suggestion or plan on fixing it?
Best wishes!
LIGER team
Hi,
I'm aware that in R the signs '.' and '-' are sorting equally in version numbers. This is not true for Debian package versions and thus for the latest Debian package I needed the following patch:
-Imports: future, future.apply, grDevices, grid, Matrix (>= 1.6.1),
+Imports: future, future.apply, grDevices, grid, Matrix (>= 1.6-1),
for the version of Matrix. It would be extremely helpful if you would simply keep the same spelling for version numbers as the authors of a package have decided for.
Kind regards, Andreas.
I'm seeing this report in CRAN checks:
Package: scCustomize
Check: whether package can be installed
New result: WARNING
Found the following significant warnings:
Warning: replacing previous import ‘Seurat::%||%’ by ‘rlang::%||%’ when loading ‘scCustomize’
Currently rlang::%||%
is copied into the SeuratObject namespace:
`%||%` <- rlang::`%||%`
This should be a reexport instead, like you did in Seurat with
#' @importFrom SeuratObject %||%
#' @rdname reexports
#' @export
#'
SeuratObject::`%||%`
Hopefully that will be enough to fix the warning in scCustomize
. If not, you might need to reexport %||%
from Seurat directly from rlang instead of SeuratObject.
Hello,
I have been running an analysis in Seurat 5 that is partially run on a local machine and a remote server, and I've been trying to work out how to change the address of where the BP cell generated count matrices are located. After moving Seurat objects generated remotely to my local machine, I encounter errors when trying to run certain functions as the root directory for the count data is set to the remote directory, rather than the local directory. See here for more details.
The SaveSeuratRds()
function looks as if it may be able to change this directory address, but there does not appear to be functionality to just change it without moving the on-disk layers from their original location. I've tried running SaveSeuratRds()
with move = F
, but when you reload the object the layers are missing:
> seurat_object
An object of class Seurat
53590 features across 144380 samples within 2 assays
Active assay: RNA (26795 features, 2000 variable features)
0 layers present:
1 other assay present: sketch
6 dimensional reductions calculated: pca, umap, harmony, umap.harmony, harmony.full, umap.full
When running SaveSeuratRds()
with move = T
, obviously the original path is not found (this also occurs when setting relative = T
or relative = F
).
SaveSeuratRds(seurat_object, paste0(R_dir, '02seurat_', region, '_test.rds'))
Error:
! Can't find path:
...
I've also tried digging around the Seurat Object, but I can't put my finger where this address is stored. The best I could do was find a list of 28 identical items containing the following, but I'm not convinced this is worth changing as it looks like a log:
seurat_object@assays$RNA@layers$counts@matrix@matrix@matrix_list[[1]]
26795 x 5706 IterableMatrix object with class RenameDims
Row names: TTR, LINC01821 ... PARVG
Col names: 10X356_4:GGTGAAGCAGGTGACA, 10X356_4:TGGATGTCACGACAAG ... 10X356_4:AGTGATCAGGCCCAAA
Data type: double
Storage order: column major
Queued Operations:
1. Load compressed matrix from directory /scratch/results/01R_objects/CBL_BP
2. Select rows: 1, 5 ... 59357 and cols: 1, 2 ... 28010
3. Reset dimnames
4. Reset dimnames
5. Reset dimnames
6. Reset dimnames
7. Reset dimnames
8. Reset dimnames
9. Reset dimnames
10. Reset dimnames
11. Reset dimnames
So a couple of questions then:
SaveSeuratRds()
or otherwise?SaveSeuratRds()
to handle local / remote analyses?Many thanks.
Hi,
If you run RenameCells
on a seurat object with one cell (I'll put below why this came up in my analysis), it does not actually rename the cells because of a <=
not <
in RenameCells.Assay
(see here). It's possible that this <=
is required but git blame
at least doesn't help me understand why it was added.
The reason why this came up is I had a list of Seurat objects, one cell type per object. I ultimately wanted a single seurat object of cell type averages so first AverageExpression
'd each element of the list (to get a Seurat object with one 'cell') and then was going to merge together. It was impractical to first merge all the seurat objects, then average by Ident, because they were so large they hit R's 2^31-1 size limitations. However, AverageExpression
leaves each cell's ID as just all
so all the cell ID's were the same pre-merge. When merge.Seurat
tries to make the cell IDs unique, it uses RenameCell
which then silently fails and later processing errors. I can't manually unique-ify the cell names for similar RenameCell
reasons.
I ended up just extracting the average matrices myself and rbind
'ing but it's a pretty pernicious error :-)
Thanks
Jonah
Hi,
I tried to convert a seurat object to a single cell experiment and back using the as.SingleCellExperiment and as.Seurat functions and I get he following error when converting back to Seurat
sce= as.SingleCellExperiment(object)
object=as.Seurat(sce)
Error in .subset2(x, i, exact = exact) : subscript out of bounds
It has worked fine before. I recently updated Seurat to version 4. Does it have anything to do with that ?
Thanks for your help.
Hi,
I have been running Seurat for data analysis on version 4.3.0.1 along with SeuratObject package 4.1.3. Until a few weeks back, all the analysis was running fine but from almost 3 weeks, I'm whenever I try to run analysis for any sample, I get this error message: Error in .GetSeuratCompat() : could not find function ".GetSeuratCompat"
. I have tried googling and updated/downgraded the versions of both Seurat and SeuratObject, but no luck. Could you suggest how can I fix this?
Thanks in advance for assistance.
Best,
Rahul
Had a part of my script that looked like this:
all_objs <- c()
for (i in seq_along(dirs)) {
samplename <- basename(dirs[i])
obj <- Load10X_Spatial(data.dir=dirs[i],
filename='filtered_feature_bc_matrix.h5')
all_objs[[samplename]] <- obj
}
obj_combined <- merge(all_objs[1], y = all_objs[-1],
add.cell.ids = names(all_objs),
project = "Spatial Seq")
This was taking upwards of several hours, even when I restricted my all_objs
to contain only two objects. After some tinkering, I found that the offending part was inside the merge()
operation: the argument x
here is technically a Seurat object inside a vector, rather than the object itself. Changing x
to all_objs[[1]]
, without making any changes to y
, seemed to do the trick and the samples merged in a few seconds.
Ultimately, this is on me for not reading the docs more closely to realize that x
should literally be the object itself, and not the object contained inside a named vector (which isn't the case for y
). However, I can imagine that at least a few other people may accidentally make such a mistake and not realize anything is wrong for a while; my htop
showed 100% CPU usage so I assumed the function was running normally and was simply a lot more computationally intensive than I thought.
No idea why this bug occurs, since merge.Assay
in assay.R
simply performs c(x, y)
under the hood anyways. If not fixable, would it be possible to add a warning message?
Relevant package versions: SeuratObject_4.1.3 Seurat_4.3.0 spacexr_2.2.1
Thank you for getting to my issue
I'm encountering an issue while attempting to subset my Seurat object and subsequently splitting it. The error message I'm encountering is as follows
Splitting ‘counts’, ‘data’ layers. Not splitting ‘scale.data’. If you would like to split other layers, set in layers argument.
Error in split():
! The following layers are already split: ‘counts’, ‘data’ Please join before splitting
Run rlang::last_trace() to see where the error occurred.
When attempting to apply functions such as NormalizeData or ScaleData to the object, I consistently encounter this error, and the code never completes execution.
Normalizing layer: counts
Performing log-normalization
0% 10 20 30 40 50 60 70 80 90 100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
Error in fn():
! Cannot add new cells with [[<-
Run rlang::last_trace() to see where the error occurred.
When I print the myeloid_cells object, I notice a reduction in the number of cells, indicating a focus on specific cell types or criteria.
An object of class Seurat
36620 features across 21912 samples within 2 assays
Active assay: RNA (36601 features, 2000 variable features)
3 layers present: data, counts, scale.data
1 other assay present: HTO
4 dimensional reductions calculated: pca, umap, harmony, umap.harmony
Upon investigation of my Seurat object, I discovered that myeloid_cells@assays[["RNA"]] contains the same number of cells as the original object, which was 45635
myeloid_cells@assays[["RNA"]]
Assay (v5) data with 36601 features for 45635 cells
Top 10 variable features:
IGHG1, IGHGP, GNLY, IGHG3, JCHAIN, IGKC, CXCL10, IGHA1, CXCL9, SPP1
Layers:
data, counts, scale.data
Upon inspecting the layers of the RNA assay, I observed that the data and counts layers contain a number of cells equal to the subsetted data. However, I noticed that the myeloid_cells@assays[["RNA"]]@cells
section in the object still retains the original number
myeloid_cells@assays[["RNA"]]@cells
A logical map for 45635 values across 10 observations
When printing myeloid_cells@assays[["RNA"]]@cells
as a matrix I encountered a matrix with scale.data.x columns where x is the same number as the objects I joined
maybe this why it we get this error however I am not sure how to resolve this.
Thank you very much for any help
Hi,
I'm trying to calculate the mitochondrial percentage using the V5 assay as follows:
options(Seurat.object.assay.version = "v5")
c1_scrna <- Read10X("./data/c1_scrna_filtered_feature_bc_matrix/")
c1_scrna <- CreateSeuratObject(c1_scrna, project="C1")
c1_scrna$mitoRatio <- PercentageFeatureSet(c1_scrna, pattern = '^Mt-')
Error in LayerData.Assay5(object = x, layer = DefaultLayer(object = x)[1L], :
features are not found
Does anyone know what's going on?
Hello everyone!
when use the function CreateSeuratObject
given assay = "Spatial",
I am wondering how to add X-Y coordinates to the object?
Thanks in advance!
Best,
Pei
Problem
Wanting to randomly subset a Seurat object, one could do
library(Seurat)
set.seed(12345)
for (i in 1:5)
{
ten_cells <- pbmc_small[, sample(Cells(pbmc_small), 5)]
print(Cells(ten_cells))
}
This prints
[1] "CATGAGACACGGGA" "CGTAGCCTGTATGC" "ACTCGCACGAAAGT" "CTAGGTGATGGTTG" "TTACGTACGTTCAG"
[1] "GATAGAGATCACGA" "GGCATATGCTTATC" "ATGCCAGAACGACT" "AGATATACCCGTAA" "TACAATGATGCTAG"
[1] "GATAGAGATCACGA" "GGCATATGCTTATC" "ATGCCAGAACGACT" "AGATATACCCGTAA" "TACAATGATGCTAG"
[1] "GATAGAGATCACGA" "GGCATATGCTTATC" "ATGCCAGAACGACT" "AGATATACCCGTAA" "TACAATGATGCTAG"
[1] "GATAGAGATCACGA" "GGCATATGCTTATC" "ATGCCAGAACGACT" "AGATATACCCGTAA" "TACAATGATGCTAG"
Expected behaviour
The five rounds should all return different cells, while it always (but for the first round) returns the same cells.
Issue
Credits to wurli on Stackoverflow for figuring out the problem.
Seurat overloads []
to call subset.Seurat()
which in turn calls WhichCells()
, which has a default seed parameter of 1.
The first time our seed 12345 works (hence the first sample being different), but for the following rounds it is overwritten to 1.
Workaround
library(Seurat)
set.seed(12345)
for (i in 1:5)
{
ten_cells <- pbmc_small[, sample(Cells(pbmc_small), 5), seed=NULL]
print(Cells(ten_cells))
}
This prints
[1] "CATGAGACACGGGA" "CGTAGCCTGTATGC" "ACTCGCACGAAAGT" "CTAGGTGATGGTTG" "TTACGTACGTTCAG"
[1] "CATGGCCTGTGCAT" "TTACGTACGTTCAG" "ACAGGTACTGGTGT" "AATGTTGACAGTCA" "GATAGAGAAGGGTG"
[1] "CATTACACCAACTG" "GGCATATGCTTATC" "ACAGGTACTGGTGT" "CATCAGGATGCACA" "ATGCCAGAACGACT"
[1] "GAGTTGTGGTAGCT" "GGCATATGGGGAGT" "AGAGATGATCTCGC" "GAACCTGATGAACC" "GATATAACACGCAT"
[1] "CATGAGACACGGGA" "GGGTAACTCTAGTG" "TTTAGCTGTACTCT" "TACATCACGCTAAC" "CTAAACCTGTGCAT"
Proposed solution
Not sure if removing the default seed with break other things, but this should probably be better documented as calling WhichCells overwrites the user seed, which is definitely unwanted behaviour.
Hi,
As you might know, the latest versions of Matrix have introduced changes that break a number of packages on machines where they were installed before Matrix got updated.
One of the victims is the SeuratObject package:
> library(SeuratObject)
> LogMap(y=letters)
Error in validObject(.Object) :
invalid class "LogMap" object: superclass "mMatrix" not defined in the environment of the object's class
This happens on any machine where SeuratObject got installed before the latest Matrix (1.6-3) got into the wild and landed on the machine.
Unfortunately, the approach of the Matrix maintainers is to simply assume that people will proactively reinstall packages affected by the changes they're doing. Even though it's really hard or even impossible for the end users or system admins to know what packages exactly need reinstallation.
However, the situation would greatly improve if SeuratObject's version was bumped and the bumped version resubmitted to CRAN. The new version would then naturally propagate to the user machine which in turn would trigger a reinstallation.
I'm kindly asking if you would consider doing that.
Note that 20+ Bioconductor packages depend directly or indirectly on SeuratObject and are currently broken on any machine where the latest Matrix has landed.
FWIW here is another CRAN package broken by the recent changes to Matrix.
Thanks,
H.
problem installing it from CRAN and from github as shown below
remotes::install_github("mojaveazure/seurat-object", "seurat5")
Error: Failed to install 'unknown package' from GitHub:
HTTP error 404.
No commit found for the ref seurat5
Did you spell the repo owner and repo name correctly?
remotes::install_github("satijalab/seurat", "seurat5", quiet = TRUE)
Installing 1 packages: SeuratObject
RunningR CMD build
...
STDOUT:
Error: Failed to install 'Seurat' from GitHub:
Failed to R CMD build
package, try build = FALSE
.
In addition: Warning message:
In i.p(...) :
installation of package ‘SeuratObject’ had non-zero exit status
I was trying to read seurat object saved previous, but was told that "Error in .requirePackage(package) :
unable to find required package 'SeuratObject'".
The package "SeuratObject" is on the version 4.0.0 or higher. So is it required if I would like to read 4.0.0 objects to the environment of Seurat v3.0.0?
I was frustrated that my school's HPC only have the version of 3.0.0 for Seurat.
Heatbroken.
Is there anyways to transfer the v4 object to v3 maybe?
I and others have posted about issues related to V5 assays that have a single cell. While an assay with one cell is probably a fringe case and usually not very useful, there are valid situations where they could arise. Someone posted about uses of pseudobulking. We've found these when we iterate a lot of seurat objects with some kind of subset operation with the goal for merging the resulting objects. I dont really see a good argument for why a single-cell object is inherently invalid, outside of R making it inconvenient by converting a matrix to a vector if the code doesnt account for that. The earlier Assay object, SingleCellExperiment, etc., don't have this limitation.
Below is one more example of what I'd argue is inconsistent Seurat behavior around this. You'll see you can easily start with a valid object, but after subset end up with an object that is basically non-functional with no errors in seurat:
# Example matrix with two cells
mat <- matrix(rep(1, 10), ncol = 2)
colnames(mat) <- c('Cell1', 'Cell2')
rownames(mat) <- LETTERS[1:5]
# Make object, which is valid
seuratObj <- Seurat::CreateSeuratObject(mat)
# Subset to one cell. Seurat doesnt complain about this. If a one-cell object is invalid, it should error here:
seuratObj <- subset(seuratObj, cells = 'Cell1')
# But a very basic operation fails on that object:
GetAssayData(seuratObj, layer = 'counts')
Error in methods::slot(object = object, name = "layers")[[layer]][features, :
incorrect number of dimensions
The purpose of posting is to ask your team to consider re-enabling this case with V5 assays. While on the fact of it a one cell assay might not seem useful, the inability to support it does cause headaches when using a seurat object to handle data.
Hi,
I'm following the tutorial "Introduction to scRNA-seq integration". I have already installed the dataset ifnb, but when I try to Load the dataset using LoadData("ifnb"), the error message pop up:
Error in slot(object = object, name = s) :
no slot of name "images" for this object of class "Seurat"
Error during wrapup: no slot of name "images" for this object of class "Seurat"
Error: no more error handlers available (recursive errors?); invoking 'abort' restart
I have clicked the lazyloaded dataset in the pkg environment and the object "ifnb" is shown, but after clicking the object in order to view, it seems the object is NULL.
How could I cope with this?
Note, my R is v4.3.0 and the SeuratData package version is 0.2.2
Hi, I would appreciate if you help me.
Any solutions for this?
Warning in install.packages :
package ‘SeuratObject’ is not available (for R version 3.6.2)
Thanks a lot.
I'm getting the following error when I try to create a Seurat
object from a matrix. A data frame seems to work fine so not sure exactly what is going on.
library(SeuratObject)
pbmc_raw <- read.table(
file = system.file('extdata', 'pbmc_raw.txt', package = 'Seurat'),
as.is = TRUE
)
CreateSeuratObject(counts = pbmc_raw)
#> An object of class Seurat
#> 230 features across 80 samples within 1 assay
#> Active assay: RNA (230 features, 0 variable features)
CreateSeuratObject(counts = as.matrix(pbmc_raw))
#> Error in switch(EXPR = getOption(x = "Seurat.checkdots"), warn = warning(msg, : EXPR must be a length 1 vector
Created on 2021-05-13 by the reprex package (v2.0.0)
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R Under development (unstable) (2021-03-29 r80130)
#> os macOS Catalina 10.15.7
#> system x86_64, darwin17.0
#> ui X11
#> language (EN)
#> collate en_US.UTF-8
#> ctype en_US.UTF-8
#> tz Europe/Berlin
#> date 2021-05-13
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> package * version date lib source
#> backports 1.2.1 2020-12-09 [1] standard (@1.2.1)
#> cli 2.5.0 2021-04-26 [1] standard (@2.5.0)
#> crayon 1.4.1 2021-02-08 [1] CRAN (R 4.1.0)
#> digest 0.6.27 2020-10-24 [1] CRAN (R 4.1.0)
#> ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.1.0)
#> evaluate 0.14 2019-05-28 [1] standard (@0.14)
#> fansi 0.4.2 2021-01-15 [1] CRAN (R 4.1.0)
#> fs 1.5.0 2020-07-31 [1] standard (@1.5.0)
#> glue 1.4.2 2020-08-27 [1] CRAN (R 4.1.0)
#> highr 0.9 2021-04-16 [1] standard (@0.9)
#> htmltools 0.5.1.1 2021-01-22 [1] standard (@0.5.1.1)
#> knitr 1.33 2021-04-24 [1] standard (@1.33)
#> lattice 0.20-44 2021-05-02 [1] CRAN (R 4.1.0)
#> lifecycle 1.0.0 2021-02-15 [1] CRAN (R 4.1.0)
#> magrittr 2.0.1 2020-11-17 [1] CRAN (R 4.1.0)
#> Matrix 1.3-3 2021-05-04 [1] CRAN (R 4.1.0)
#> pillar 1.6.0 2021-04-13 [1] CRAN (R 4.1.0)
#> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.1.0)
#> purrr 0.3.4 2020-04-17 [1] standard (@0.3.4)
#> Rcpp 1.0.6 2021-01-15 [1] standard (@1.0.6)
#> reprex 2.0.0 2021-04-02 [1] standard (@2.0.0)
#> rlang 0.4.11 2021-04-30 [1] CRAN (R 4.1.0)
#> rmarkdown 2.8 2021-05-07 [1] CRAN (R 4.1.0)
#> sessioninfo 1.1.1 2018-11-05 [1] standard (@1.1.1)
#> SeuratObject * 4.0.1 2021-05-08 [1] standard (@4.0.1)
#> stringi 1.6.1 2021-05-10 [1] CRAN (R 4.1.0)
#> stringr 1.4.0 2019-02-10 [1] CRAN (R 4.1.0)
#> styler 1.4.1 2021-03-30 [1] standard (@1.4.1)
#> tibble 3.1.1 2021-04-18 [1] CRAN (R 4.1.0)
#> utf8 1.2.1 2021-03-12 [1] CRAN (R 4.1.0)
#> vctrs 0.3.8 2021-04-29 [1] CRAN (R 4.1.0)
#> withr 2.4.2 2021-04-18 [1] CRAN (R 4.1.0)
#> xfun 0.22 2021-03-11 [1] standard (@0.22)
#> yaml 2.2.1 2020-02-01 [1] standard (@2.2.1)
#>
#> [1] /Library/Frameworks/R.framework/Versions/4.1/Resources/library
I have 2 Seurat objects with the same cell barcodes, but in different column orders. I believe this occurred during an integration step. See example below (steps omitted).
ifnb = CreateSeuratObject(counts = data)
ifnb.list <- SplitObject(ifnb, split.by = "stim")
immune.combined <- IntegrateData(anchorset = immune.anchors)
# add to non-Assay slots
ifnb <- FindClusters(ifnb, resolution = 0.5)
immune.combined <- FindClusters(immune.combined, resolution = 0.5)
colnames(ifnb)[1:10]
[1] "AAAA-1" "AAAB-1" "AAAC-1" "AAAD-1" "AAAE-1" "AAAF-1" "AAAG-1" "AAAH-1" "AAAI-1" "AAAJ-1"
colnames(immune.combined)[1:10]
[1] "AAAE-1" "AAAC-1" "AAAJ-1" "AAAF-1" "AAAA-1" "AAAB-1" "AAAD-1" "AAAG-1" "AAAH-1" "AAAI-1"
# can one Suerat object's columns be reordered by a second Seurat's colnames? No
test = immune.combined[, colnames(ifnb)]
colnames(test)[1:10]
[1] "AAAE-1" "AAAC-1" "AAAJ-1" "AAAF-1" "AAAA-1" "AAAB-1" "AAAD-1" "AAAG-1" "AAAH-1" "AAAI-1"
# desired outcome of previous line: "AAAA-1" "AAAB-1" "AAAC-1" "AAAD-1" "AAAE-1" "AAAF-1" "AAAG-1" "AAAH-1" "AAAI-1" "AAAJ-1"
I would like to transfer all assays (counts, data, and scale.data slots), dimension reductions, cluster idents, graphs, etc from immune.combined
to ifnb
. Trying merge()
doesn't work well since both objects have the same barcodes (just different column orders):
identical( sort(colnames(ifnb), sort(colnames(immune.combined)) )
[1] TRUE
So merge(ifnb, immune.combined)
doesn't seem to have the desired outcome; it will append suffixes to each barcode to keep barcodes from each object unique.
My current solution is:
ifnb[["integrated"]] = immune.combined[["integrated"]]
My main question/concern is: will the barcodes/matrices from the "old" assay: immune.combined[["integrated"]]
be reordered to match the order of the "new" object: colnames(ifnb)
prior to creation of the new assay: ifnb[["integrated"]]
?
Or put differently,
identical(immune.combined[["integrated"]], colnames(ifnb))
[1] FALSE
Instead if we do this:
ifnb[["integrated"]] = immune.combined[["integrated"]]
identical(ifnb[["integrated"]], colnames(ifnb))
[1] TRUE
Will the values of the associated matrices (such as ifnb[["integrated"]]@counts
) be rearranged accordingly, or will the original matrices such as immune.combined[["integrated"]]@counts
simply be copied over to the ifnb[["integrated"]]@counts
slot WITHOUT re-arranging/re-indexing the column order of the incoming assay/matrix?
Based on some initial checks of the newly transferred assay and a cursory check of Seurat/SeuratObject source code, I expect there is a reordering of both the column names and underlying matrices, but I wanted to double check. If you need reproducible example, let me know.
I am trying to create a seurat object from the available files from https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSM5596828. The data that is available to create a seurat object from Sci-sequencing data are the counts matrix (matrix.gz), cell annotation (txt.gz), and gene annotation (txt.gz). I am having some issue combining these files to create one seurat object. I have tried to change the file names to fit the seurat format but that does not work. Do you have any suggestions?
Hello,
maybe this is expected behavior, but I was surprised when I updating an object v3.99
to v5.0.1
that the new object still contained the old data structure: slots instead layers.
> combined.obj.after@version
[1] ‘3.9.9.9010’
> obj.Fig.4D <- UpdateSeuratObject(combined.obj.after )
Validating object structure
Updating object slots
Ensuring keys are in the proper structure
Updating matrix keys for DimReduc ‘pca’
Updating matrix keys for DimReduc ‘umap’
Warning: Assay RNA changing from Assay to Assay
Warning: Assay integrated changing from Assay to Assay
Warning: Assay alra changing from Assay to Assay
Ensuring keys are in the proper structure
Ensuring feature names dont have underscores or pipes
Updating slots in RNA
Updating slots in integrated
Updating slots in alra
Updating slots in integrated_nn
Setting default assay of integrated_nn to integrated
Updating slots in integrated_snn
Setting default assay of integrated_snn to integrated
Updating slots in pca
Updating slots in umap
Setting umap DimReduc to global
No assay information could be found for FindIntegrationAnchors
No assay information could be found for withCallingHandlers
No assay information could be found for RunTSNE
Setting assay used for FindVariableFeatures.integrated to integrated
Setting assay used for ScaleData.integrated to integrated
Setting assay used for RunPCA.integrated to integrated
Setting assay used for RunUMAP.integrated.pca to integrated
Setting assay used for FindNeighbors.integrated.pca to integrated
No assay information could be found for FindClusters
Validating object structure for Assay ‘RNA’
Validating object structure for Assay ‘integrated’
Validating object structure for Assay ‘alra’
Validating object structure for Graph ‘integrated_nn’
Validating object structure for Graph ‘integrated_snn’
Validating object structure for DimReduc ‘pca’
Validating object structure for DimReduc ‘umap’
Object representation is consistent with the most current Seurat version
Warning messages:
1: Adding a command log without an assay associated with it
2: Adding a command log without an assay associated with it
3: Adding a command log without an assay associated with it
4: Adding a command log without an assay associated with it
> obj.Fig.4D@version
[1] ‘5.0.1’
> (otherv5.obj@assays$RNA)
Assay (v5) data with 30753 features for 162615 cells
Top 10 variable features:
TTR, KRT19, SLPI, S100A9 ...
Layers:
scale.data, data, counts
> obj.Fig.4D@assays$RNA
Assay data with 26690 features for 5478 cells
First 10 features:
AL627309.1, AL669831.5, LINC00115, FAM41C, AL645608.7, AL645608.1, SAMD11, NOC2L, KLHL17, AL645608.8
> combined.obj.after@assays$RNA
Assay data with 26690 features for 5478 cells
First 10 features:
AL627309.1, AL669831.5, LINC00115, FAM41C, AL645608.7, AL645608.1, SAMD11, NOC2L, KLHL17, AL645608.8
>
Warnings
→ in this case, how to perform a proper update?Thank you for your time and continued work on the package!
Hi, we recently noticed that due to the programmed retirement (October 2023) of packages maptools, rgdal and rgeos packages, it became troublesome to use the SeuratObject package as a dependency. Using it triggers a warning during R CMD check that we are not still able to find a solution for.
We're wondering id adding "sf" to the suggests in seurat-objects' DESCRIPTION could solve it.
Below the text of the Warnings:
❯ checking for missing documentation entries ... WARNING
The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,
which was just loaded, will retire in October 2023.
Please refer to R-spatial evolution reports for details, especially
https://r-spatial.org/r/2023/05/15/evolution4.html.
It may be desirable to make the sf package available;
package maintainers should consider adding sf to Suggests:.
The sp package is now running under evolution status 2
(status 2 uses the sf package in place of rgdal)
All user-level objects in a package should have documentation entries.
See chapter 'Writing R documentation files' in the 'Writing R
Extensions' manual.
❯ checking for code/documentation mismatches ... WARNING
The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,
which was just loaded, will retire in October 2023.
Please refer to R-spatial evolution reports for details, especially
https://r-spatial.org/r/2023/05/15/evolution4.html.
It may be desirable to make the sf package available;
package maintainers should consider adding sf to Suggests:.
The sp package is now running under evolution status 2
(status 2 uses the sf package in place of rgdal)
Hi Seurat Team,
Before attempting PR on this (which would be slightly more complicated than what I've done before) I wanted to just inquire about whether this is something that would be accepted or whether there is reason to leave as is. If this sounds like something that you would be open to PR on please let me know and I'll work on implementing it.
Best,
Sam
Basically wondering about implementing DefaultDimReduc<-
to allow users to manually set the default dimensionality reduction. Right now, the function just checks for umap, tsne, pca in object reductions slot, and then prioritizes which one is default in that order.
The place I see this being most relevant is if users either want to save multiple reductions of the same type with different parameters (by changing key for each one when running commands) or if for instance they have run tsne and umap but want tsne to be their default. It would save entering extra parameter for reduction
each time when plotting if the default could be updated.
From looking at things my thoughts on how to implement this would be to add new slot in Seurat class called active.reduc
(similar to active.assay
slot) and then DefaultDimReduc
can check for a value in that slot or use current default ordering (umap, tsne, pca).
DefaultDimReduc<-
would then have a check to ensure that the value being set matched a present reduction in the object so that it couldn't be set to non-present value.
If you have any thoughts, changes, or other suggestions please let me know.
Thanks again for all you do!
Sam
Since I updated Seurat from v4 to v5, I kept getting this error message when I was loading Seurat:
library(Seurat)
Loading required package: SeuratObject
Loading required package: sp
‘SeuratObject’ was built under R 4.3.1 but the current version is 4.3.3; it is
recomended that you reinstall ‘SeuratObject’ as the ABI for R may have changed
‘SeuratObject’ was built with package ‘Matrix’ 1.6.3 but the current version is
1.6.5; it is recomended that you reinstall ‘SeuratObject’ as the ABI for ‘Matrix’ may
have changed
When I ran FindAllMarkers after PrepSCTFindMarkers, the number of observation was changed from 7,141 to 46,367.
This is the code that I used:
ALL.MARKERS.WNN <- FindAllMarkers(seg_status, assay = "SCT", recorrect_umi = FALSE)
My previous version of Seurat and SeuratObject was 4.4.0 and 4.1.4, respectively. The Matrix version was 1.6-5.
I deleted SeuratObject and Matrix package and re-install, and I restarted R whenever I deleted or re-installed them.
I also deleted Seurat and Signac and re-installed them, but it kept giving me the same error.
I even uninstalled R and RStudio and re-downloaded them. After that, I installed Seurat and Signac, non other packages. However, I am still getting same error.
I tried to update my Seurat object. The version of my Seurat object (CF_MultiModal_WNN) was 4.1.4:
seg_status@version
‘4.1.4’
I used this code to update the object:
seg_status <- UpdateSeuratObject(seg_status)
Validating object structure
Updating object slots
Ensuring keys are in the proper structure
Updating matrix keys for DimReduc ‘pca’
Updating matrix keys for DimReduc ‘umap’
Updating matrix keys for DimReduc ‘lsi’
Updating matrix keys for DimReduc ‘umap.atac’
Updating matrix keys for DimReduc ‘harmony’
Updating matrix keys for DimReduc ‘wnn.umap’
Ensuring keys are in the proper structure
Ensuring feature names don't have underscores or pipes
Updating slots in RNA
Updating slots in ATAC
Updating slots in SCT
Updating slots in integrated
Updating slots in integrated_nn
Setting default assay of integrated_nn to integrated
Updating slots in integrated_snn
Setting default assay of integrated_snn to integrated
Updating slots in ATAC_nn
Setting default assay of ATAC_nn to ATAC
Updating slots in ATAC_snn
Setting default assay of ATAC_snn to ATAC
Updating slots in wknn
Cannot find wknn in the object, setting default assay of wknn to ATAC
Updating slots in wsnn
Cannot find wsnn in the object, setting default assay of wsnn to ATAC
Updating slots in pca
Updating slots in umap
Setting umap DimReduc to global
Updating slots in lsi
Updating slots in umap.atac
Setting umap.atac DimReduc to global
Updating slots in harmony
Updating slots in wnn.umap
Setting wnn.umap DimReduc to global
No assay information could be found for FindIntegrationAnchors
No assay information could be found for withCallingHandlers
Setting assay used for ScaleData.integrated to integrated
Setting assay used for RunPCA.integrated to integrated
Setting assay used for FindNeighbors.integrated.pca to integrated
Setting assay used for RunUMAP.integrated.pca to integrated
Setting assay used for RunUMAP.ATAC.lsi to ATAC
Setting assay used for RunUMAP.ATAC.harmony to ATAC
Setting assay used for FindNeighbors.ATAC.harmony to ATAC
No assay information could be found for FindModalityWeights
No assay information could be found for FindMultiModalNeighbors
Setting assay used for RunUMAP.ATAC.pca to integrated
No assay information could be found for FindClusters
Validating object structure for Assay ‘RNA’
Validating object structure for ChromatinAssay ‘ATAC’
Validating object structure for SCTAssay ‘SCT’
Validating object structure for Assay ‘integrated’
Validating object structure for Graph ‘integrated_nn’
Validating object structure for Graph ‘integrated_snn’
Validating object structure for Graph ‘ATAC_nn’
Validating object structure for Graph ‘ATAC_snn’
Validating object structure for Graph ‘wknn’
Validating object structure for Graph ‘wsnn’
Validating object structure for DimReduc ‘pca’
Validating object structure for DimReduc ‘umap’
Validating object structure for DimReduc ‘lsi’
Validating object structure for DimReduc ‘umap.atac’
Validating object structure for DimReduc ‘harmony’
Validating object structure for DimReduc ‘wnn.umap’
Object representation is consistent with the most current Seurat version
Warning messages:
1: Adding a command log without an assay associated with it
2: Adding a command log without an assay associated with it
3: Adding a command log without an assay associated with it
4: Adding a command log without an assay associated with it
5: Adding a command log without an assay associated with it
The version of the object changed to 5.0.1, but this didn't help me to solve the issue.
This is my sessionInfo:
R version 4.3.3 (2024-02-29)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.4Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8time zone: US/Pacific
tzcode source: internalattached base packages:
[1] stats graphics grDevices utils datasets methods baseother attached packages:
[1] Seurat_5.0.3 SeuratObject_5.0.1 sp_2.1-3loaded via a namespace (and not attached):
[1] deldir_2.0-4 pbapply_1.7-2 gridExtra_2.3
[4] rlang_1.1.3 magrittr_2.0.3 RcppAnnoy_0.0.22
[7] matrixStats_1.2.0 ggridges_0.5.6 compiler_4.3.3
[10] spatstat.geom_3.2-9 png_0.1-8 vctrs_0.6.5
[13] reshape2_1.4.4 stringr_1.5.1 pkgconfig_2.0.3
[16] fastmap_1.1.1 utf8_1.2.4 promises_1.2.1
[19] purrr_1.0.2 jsonlite_1.8.8 goftest_1.2-3
[22] later_1.3.2 spatstat.utils_3.0-4 irlba_2.3.5.1
[25] parallel_4.3.3 cluster_2.1.6 R6_2.5.1
[28] ica_1.0-3 stringi_1.8.3 RColorBrewer_1.1-3
[31] spatstat.data_3.0-4 reticulate_1.35.0 parallelly_1.37.1
[34] lmtest_0.9-40 scattermore_1.2 Rcpp_1.0.12
[37] tensor_1.5 future.apply_1.11.2 zoo_1.8-12
[40] sctransform_0.4.1 httpuv_1.6.15 Matrix_1.6-5
[43] splines_4.3.3 igraph_2.0.3 tidyselect_1.2.1
[46] rstudioapi_0.16.0 abind_1.4-5 spatstat.random_3.2-3
[49] codetools_0.2-19 miniUI_0.1.1.1 spatstat.explore_3.2-7
[52] listenv_0.9.1 lattice_0.22-5 tibble_3.2.1
[55] plyr_1.8.9 shiny_1.8.1 ROCR_1.0-11
[58] Rtsne_0.17 future_1.33.2 fastDummies_1.7.3
[61] survival_3.5-8 polyclip_1.10-6 fitdistrplus_1.1-11
[64] pillar_1.9.0 KernSmooth_2.23-22 plotly_4.10.4
[67] generics_0.1.3 RcppHNSW_0.6.0 ggplot2_3.5.0
[70] munsell_0.5.0 scales_1.3.0 globals_0.16.3
[73] xtable_1.8-4 glue_1.7.0 pheatmap_1.0.12
[76] lazyeval_0.2.2 tools_4.3.3 data.table_1.15.2
[79] RSpectra_0.16-1 RANN_2.6.1 leiden_0.4.3.1
[82] dotCall64_1.1-1 cowplot_1.1.3 grid_4.3.3
[85] tidyr_1.3.1 colorspace_2.1-0 nlme_3.1-164
[88] patchwork_1.2.0 cli_3.6.2 spatstat.sparse_3.0-3
[91] spam_2.10-0 fansi_1.0.6 viridisLite_0.4.2
[94] dplyr_1.1.4 uwot_0.1.16 gtable_0.3.4
[97] digest_0.6.35 progressr_0.14.0 ggrepel_0.9.5
[100] htmlwidgets_1.6.4 htmltools_0.5.8 lifecycle_1.0.4
[103] httr_1.4.7 mime_0.12 MASS_7.3-60.0.1
Hello,
This is a 2-in-1 issue (A, B).
I am trying to rename genes in Seurat. I know you principally disagree, however I need it.
For that end, I:
obj <- SetAssayData(obj, layer = layer.name, new.data = matrix_n)
where matrix_n
contains e.g. a single gene renamed.
Also tried
SeuratObject::LayerData(assayobj, layer = layer.name) <- matrix_n
, but same error
Matrix replaced.
Warning: Different features in new layer data than already exists for counts
nrow
becomes n-1
!A)
At least this should be a "nrow !=" type of error! )B)
Questionobj@assays$RNA@[email protected]
. Is there any other place that needs replacement? I guess if I replace rownames of @[email protected]
, SetAssayData wont complain?Doing operations on layers with same number of features and cells results in missing feature overlap issue (seuratv5 branch):
set.seed(seed = 1)
dummyexpMat <- matrix(
data = sample(x = c(1:50), size = 1e4, replace = TRUE),
ncol = 100, nrow = 100
)
colnames(x = dummyexpMat) <- paste0("cell", seq(ncol(x = dummyexpMat)))
row.names(x = dummyexpMat) <- paste0("gene", seq(nrow(x = dummyexpMat)))
# Create Seurat object for testing
obj <- CreateSeuratObject(counts = as.sparse(dummyexpMat))
obj <- NormalizeData(object = obj, verbose = FALSE)
obj <- ScaleData(object = obj, verbose = FALSE)
Warning: No layers found matching search pattern provided
Error: No feature overlap between existing object and new layer data
SpatiallyVariableFeatures()
throws the following warning with R4.1 and Seurat 4.0.4:
Warning in xtfrm.data.frame(x) : cannot xtfrm data frames
I think this crops up in line 501 of assay.R
when order()
is called on the vf
data frame.
See this blog article for an explanation of the likely cause and a work-around.
There may be other instances.
Cheers :)
rgeos is only used for segmentation simplification and has a dependency on libgeos, which is difficult to install in restricted environments. Moving rgeos to suggests would make SeuratObject easier to install for the majority of users
Seurat and SeuratObject 5.0.1 installed from CRAN.
Attempting to merge SeuratObjects with "collapse=TRUE" results in error "Collapsing layers is not yet supported". I can see also in the current GitHub source that the functionality is not yet implemented. However, the documentation in the current release version (from "?merge.Seurat") does not indicate that the option does not yet exist and that it will throw an error.
Hello, I am running into an issue when trying to work with a list of Seurat objects, which I named seurats. not sure if this issue belongs to the seurat or seuratobject repo. Anyway, my code:
lapply(X = seurats, FUN = function(x){
FeatureScatter(x, feature1 = "percent.mt", feature2 = "nFeature_RNA") +
geom_density2d()
})
the answer:
Error in vapply(X = keyed.objects, FUN = function(x) { :
values must be length 1,
but FUN(X[[2]]) result is length 0
The versions:
packageVersion("SeuratObject")
[1] ‘4.0.4’
packageVersion("Seurat")
[1] ‘4.1.0’
R is 4.1.2
RStudio is 2022.02.0
OS is MacOS Monterey
If this is a bug that it's going to take some time to fix, what can I do in the meantime?
Many thanks!
Lili
For purposes of anonymization I need to rename the cell-names which include the study number in our dataset.
I have a Seurat-object with test@assays$RNA$counts@Dimnames[2])
and test@assays$SCT$counts@Dimnames[2])
having for instance: "aab1.P2.299" "aab1.P2.311" "aab1.P2.315" "aab1.P2.318" "aab1.P2.319" "aab1.P2.321" "aab1.P2.322" "aab1.P2.338" "aab1.P2.349"
.
Here's what I did.
First, I got the list of original cell names in a new column:
[email protected]$orig.cellname <- unlist(c(test@assays$RNA$counts@Dimnames[2]))
Next, I split this column:
[email protected] <- [email protected] %>% separate(orig.cellname, c('Cell_SNR', 'Cell_Plate', 'Cell_nr'))
Then I created a new cellname:
[email protected]$new.cellname <- paste(test$SampleID, test$Cell_Plate, test$Cell_nr, sep = ".")
Where SampleID
is a new anonymized sample ID.
Finally, I apply RenameCell
.
test <- RenameCells(test, new.names = [email protected]$new.cellname)
Here I assume the dimnames
will be replaced throughout the SeuratObject
, so at test@assays$RNA$counts
, test@assays$RNA$data
, test@assays$SCT$counts
, and test@assays$SCT$data
, but also at test@graphs$SCT_nn
, and test@graphs$SCT_snn
.
I get this error:
Error in new.cell.names.global[match(x = working.cells, table = old.names)] <- new.cell.names :
NAs are not allowed in subscripted assignments
I don't get this as far as I can see there aren't any 'NAs' in my new column.
I am not sure how to move forward from here. Any advice or suggestions would be great.
I'm using SeuratObject 5.0.0, and ran Seurat::UpdateSeuratObject on a seurat object created with seurat 4.x.
This code works fine with Matrix 1.6-1.1, but fails with 1.6-2, which was apparently just released (https://github.com/cran/Matrix/releases/tag/1.6-2). The error is:
Error in validObject(.Object)
: invalid class "Graph" object: superclass "mMatrix" not defined in the environment of the object's class
Have you seen this error before? Below is the stack:
3. └─Seurat::UpdateSeuratObject(readRDS("../testdata/seuratOutput.rds"))
***. ├─base::suppressWarnings(...)
5. │ └─base::withCallingHandlers(...)
6. └─SeuratObject::UpdateSlots(object = object[[obj]])
7. ├─base::suppressWarnings(expr = do.call(what = "new", args = object.list))
8. │ └─base::withCallingHandlers(...)
9. ├─base::do.call(what = "new", args = object.list)
10. └─methods::new(...)
11. ├─methods::initialize(value, ...)
12. └─Matrix (local) initialize(value, ...)
13. ├─methods::callNextMethod()
1***. └─methods (local) .nextMethod(.Object = .Object, ... = ...)
15. └─methods::validObject(.Object)
16. ```
Since there is a RenameCells()
function, it would be helpful to also have a function to rename features. The current advice is to create a new assay object with renamed features, which can be very memory intensive.
Hi @mojaveazure,
I was trying to downgrade seuratobject_4.0.3 to earlier version. I tried the following code,
remotes::install_version(package = 'SeuratObject', version = package_version('4.0.2'))
Here is the error message,
fatal error: too many errors emitted, stopping now [-ferror-limit=]
21 warnings and 20 errors generated.
make: *** [data_manipulation.o] Error 1
ERROR: compilation failed for package ‘SeuratObject’
Any suggestions?
Thanks in advance,
Chi
Error in parse(outFile) : /tmp/RtmpafO9XW/Rbuild84c567e69b58/SeuratObject/R/assay5.R:108:13: unexpected input 107: expr = Layers(object = object, search = layer), 108: error = \
Suggestion: I think it would be good to see a warning if the cell names in the counts matrix and the metadata do not match.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.