satijalab / seurat

R toolkit for single cell genomics
http://www.satijalab.org/seurat
Other
2.27k stars 910 forks source link

RunUMAP leads to ValueError #1553

Closed plath997 closed 5 years ago

plath997 commented 5 years ago

Hello,

I am trying to call the RunUMAP function on the object 'funston', but I have encountered this error: RunUMAP('funston') Error in py_call_impl(callable, dots$args, dots$keywords) : ValueError: could not convert string to float: 'funstun'

Detailed traceback: 
  File "/home/jan/miniconda3/lib/python3.7/site-packages/umap/umap_.py", line 1572, in fit_transform
    self.fit(X, y)
  File "/home/jan/miniconda3/lib/python3.7/site-packages/umap/umap_.py", line 1325, in fit
    X = check_array(X, dtype=np.float32, accept_sparse="csr")
  File "/home/jan/miniconda3/lib/python3.7/site-packages/sklearn/utils/validation.py", line 527, in check_array
    array = np.asarray(array, dtype=dtype, order=order)
  File "/home/jan/miniconda3/lib/python3.7/site-packages/numpy/core/numeric.py", line 538, in asarray
    return array(a, dtype, copy=False, order=order)

I have installed umap via pip3 install umap-learn I am running Seurat v3 with R 3.6.0 on a Linux server. Any help would be much appreciated!

timoast commented 5 years ago

Hi, can you please provide the full code you're using and the output of sessionInfo()?

plath997 commented 5 years ago

Here's the code:

library('Seurat')
library(reticulate)
load('/home/files/jan/raw_objs/funston.RData')
funston = RunUMAP('funston')
Error in py_call_impl(callable, dots$args, dots$keywords) : 
  ValueError: could not convert string to float: 'funston'

When I take out the quotation marks in the RunUMAP command, I get this:

funston = RunUMAP(funston)
Error in as.vector(data) : 
  no method for coercing this S4 class to a vector

Session info:

R version 3.6.0 (2019-04-26)
Platform: x86_64-pc-linux-gnu (64-bit)

Matrix products: default
BLAS:   /home/shared/cbc/software_cbc/R/R-3.6.0/lib64/R/lib/libRblas.so
LAPACK: /home/shared/cbc/software_cbc/R/R-3.6.0/lib64/R/lib/libRlapack.so

locale:
[1] C

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

other attached packages:
[1] reticulate_1.12 Seurat_3.0.0   

loaded via a namespace (and not attached):
 [1] httr_1.4.0          tidyr_0.8.3         jsonlite_1.6       
 [4] viridisLite_0.3.0   splines_3.6.0       lsei_1.2-0         
 [7] R.utils_2.8.0       gtools_3.8.1        Rdpack_0.11-0      
[10] assertthat_0.2.1    ggrepel_0.8.1       globals_0.12.4     
[13] pillar_1.3.1        lattice_0.20-38     glue_1.3.1         
[16] digest_0.6.18       RColorBrewer_1.1-2  SDMTools_1.1-221.1 
[19] colorspace_1.4-1    cowplot_0.9.4       htmltools_0.3.6    
[22] Matrix_1.2-17       R.oo_1.22.0         plyr_1.8.4         
[25] pkgconfig_2.0.2     bibtex_0.4.2        tsne_0.1-3         
[28] listenv_0.7.0       purrr_0.3.2         scales_1.0.0       
[31] RANN_2.6.1          gdata_2.18.0        Rtsne_0.15         
[34] tibble_2.1.1        ggplot2_3.1.1       ROCR_1.0-7         
[37] pbapply_1.4-0       lazyeval_0.2.2      survival_2.44-1.1  
[40] magrittr_1.5        crayon_1.3.4        R.methodsS3_1.7.1  
[43] future_1.12.0       nlme_3.1-139        MASS_7.3-51.4      
[46] gplots_3.0.1.1      ica_1.0-2           tools_3.6.0        
[49] fitdistrplus_1.0-14 data.table_1.12.2   gbRd_0.4-11        
[52] stringr_1.4.0       plotly_4.9.0        munsell_0.5.0      
[55] cluster_2.0.8       irlba_2.3.3         compiler_3.6.0     
[58] rsvd_1.0.0          caTools_1.17.1.2    rlang_0.3.4        
[61] grid_3.6.0          ggridges_0.5.1      htmlwidgets_1.3    
[64] igraph_1.2.4.1      bitops_1.0-6        npsurv_0.4-0       
[67] gtable_0.3.0        codetools_0.2-16    reshape2_1.4.3     
[70] R6_2.4.0            gridExtra_2.3       zoo_1.8-5          
[73] dplyr_0.8.0.1       future.apply_1.2.0  KernSmooth_2.23-15 
[76] metap_1.1           ape_5.3             stringi_1.4.3      
[79] parallel_3.6.0      Rcpp_1.0.1          sctransform_0.2.0  
[82] png_0.1-7           tidyselect_0.2.5    lmtest_0.9-37      

Any advice would be greatly appreciated!

timoast commented 5 years ago

Can you run class(funston) and provide the output, and include the script used to make the object if you can.

plath997 commented 5 years ago

Here's the output to class(funston):

class(funston)
[1] "seurat"
attr(,"package")
[1] "Seurat"

I am still looking for the code, but I know that this object is a merged from several different samples.

timoast commented 5 years ago

That's a Seurat v2 object, you need to update it to v3 before running any v3 functions.

funston <- UpdateSeuratObject(funston)
plath997 commented 5 years ago

I tried to update the object, but now I get this error:

funston <- UpdateSeuratObject(funston)
Error in if (grepl(pattern = "^[[:alnum:]]+_", x = key)) { : 
  argument is of length zero
timoast commented 5 years ago

Can you send me the object? It's hard to debug this further without it

plath997 commented 5 years ago

Here's the google drive link: https://drive.google.com/file/d/1dT2etUFoTwXrmn_C203LY1xqXaN8m3M2/view?usp=sharing

Let me know if you have issues accessing

timoast commented 5 years ago

Hi, the issue was due to a missing dimension reduction key for the fastPCA reduction in the v2 object. I have added a check for missing keys in the UpdateSeuratObject function, which will be available on the develop branch shortly. Here's a link to the updated object: https://www.dropbox.com/s/eftddgg2hrs74od/funston_v3.Rdata?dl=0

plath997 commented 5 years ago

Thank you!

McStber commented 5 years ago

@timoast Thank you so much.

I had the same issue with the Seuratv2 object. After using "UpdateSeuratObject" command I just had to adapt my commands to Seuratv3 and it worked and I could do RunUMAP! :)