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

AddMetaData with data.frame as metadata fills NAs instead of data #157

Open
jonasfreimuth opened this issue Oct 22, 2023 · 0 comments
Open

Comments

@jonasfreimuth
Copy link

When using AddMetaData to add metadata columns via a data.frame object, the resulting added columns contain only NAs 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 ´mini_so_meta@meta.data`:

     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           

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant