Irrationone / cellassign

Automated, probabilistic assignment of cell types in scRNA-seq data
Other
191 stars 79 forks source link

SizeFactors() does not add size factors to SingleCellObject #64

Open tkapello opened 4 years ago

tkapello commented 4 years ago

Hi,

   I want to classify 1,047 cells from a Seurat object in 16 possible phenotypes and I used the cellassign package for that. I ran the below code, but I had the mentioned error. I think I followed the vignette correctly, but it seems like the sizeFactors() does not add the size factors to the SingleCellObject. Any suggestions?
CellAssign
# Import data as SingleCellExperiment object
 counts <- tcelldataset@assays$RNA@counts
 sce <- SingleCellExperiment(assays = list(counts = counts))

 # Prepare the marker gene set
 marker.gene.set<-merge(x=df.cd4, y=df.cd8, by='test', all=T, sort=F)
 marker.gene.set<-merge(x=marker.gene.set, y=df.tregs, by='test', all=T, sort=F)
 marker.gene.set[is.na(marker.gene.set)] <- 0
 rownames(marker.gene.set)<-marker.gene.set$test
 marker.gene.set$test<-NULL
 marker.gene.set<-as.matrix(marker.gene.set)

 # Compute size factors
 sf <- sizeFactors(sce)

 # Run cellassign
 sce_marker <- sce[intersect(rownames(marker.gene.set), rownames(sce)),]
 marker.gene.set<-marker.gene.set[intersect(rownames(marker.gene.set), rownames(sce)),]
 fit <- cellassign(exprs_obj = sce_marker, 
                   marker_gene_info = marker.gene.set, 
                   s = sf, 
                   #X=X,
                   learning_rate = 1e-2, 
                   shrinkage = TRUE,
                   verbose = FALSE)

No size factors supplied - computing from matrix. It is highly recommended to supply size factors calculated using the full gene set
Error in py_module_import(module, convert = convert) : 
  ModuleNotFoundError: No module named 'tensorflow_probability'
In addition: Warning messages:
1: In cellassign(exprs_obj = sce_marker, marker_gene_info = marker.gene.set,  :
  Genes with no mapping counts are present. Make sure this is expected -- this can be valid input in some cases (e.g. when cell types are overspecified).
2: In cellassign(exprs_obj = sce_marker, marker_gene_info = marker.gene.set,  :
  You have specified 1564 input genes. Are you sure these are just your markers? Only the marker genes should be used as input
3: use 'calculateSumFactors' for any 'x' that is not a SingleCellExperiment

I attach my SessionInfo() in case it may be useful

sessionInfo()
R version 3.6.2 (2019-12-12)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 10 (buster)

Matrix products: default
BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.3.5.so

Random number generation:
 RNG:     Mersenne-Twister 
 Normal:  Inversion 
 Sample:  Rounding 

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

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

other attached packages:
 [1] scran_1.14.6                SingleR_1.0.5               org.Hs.eg.db_3.10.0         org.Mm.eg.db_3.10.0        
 [5] AnnotationDbi_1.48.0        DOSE_3.12.0                 clusterProfiler_3.14.3      genefilter_1.68.0          
 [9] ggrepel_0.8.1               jsonlite_1.6                backports_1.1.5             ggExtra_0.9                
[13] Matrix_1.2-18               RColorBrewer_1.1-2          dplyr_0.8.3                 readr_1.3.1                
[17] Seurat_3.1.2                useful_1.2.6                scales_1.1.0                ggplot2_3.2.1              
[21] data.table_1.12.8           gdata_2.18.0                SingleCellExperiment_1.8.0  SummarizedExperiment_1.16.1
[25] DelayedArray_0.12.2         BiocParallel_1.20.1         matrixStats_0.55.0          Biobase_2.46.0             
[29] GenomicRanges_1.38.0        GenomeInfoDb_1.22.0         IRanges_2.20.1              S4Vectors_0.24.1           
[33] BiocGenerics_0.32.0         tensorflow_2.0.0            cellassign_0.99.16          BiocManager_1.30.10        

loaded via a namespace (and not attached):
  [1] rappdirs_0.3.1                R.methodsS3_1.7.1             tidyr_1.0.0                  
  [4] bit64_0.9-7                   irlba_2.3.3                   multcomp_1.4-11              
  [7] R.utils_2.9.2                 RCurl_1.95-4.12               metap_1.2                    
 [10] callr_3.4.0                   cowplot_1.0.0                 TH.data_1.0-10               
 [13] usethis_1.5.1                 RSQLite_2.2.0                 RANN_2.6.1                   
 [16] europepmc_0.3                 future_1.15.1                 bit_1.1-14                   
 [19] enrichplot_1.6.1              mutoss_0.1-12                 xml2_1.2.2                   
 [22] httpuv_1.5.2                  assertthat_0.2.1              viridis_0.5.1                
 [25] hms_0.5.3                     promises_1.1.0                fansi_0.4.1                  
 [28] progress_1.2.2                caTools_1.17.1.3              dbplyr_1.4.2                 
 [31] igraph_1.2.4.2                DBI_1.1.0                     htmlwidgets_1.5.1            
 [34] purrr_0.3.3                   ellipsis_0.3.0                annotate_1.64.0              
 [37] gbRd_0.4-11                   RcppParallel_4.4.4            vctrs_0.2.1                  
 [40] remotes_2.1.0                 ROCR_1.0-7                    withr_2.1.2                  
 [43] ggforce_0.3.1                 triebeard_0.3.0               sctransform_0.2.0            
 [46] prettyunits_1.1.0             mnormt_1.5-5                  cluster_2.1.0                
 [49] ExperimentHub_1.12.0          ape_5.3                       lazyeval_0.2.2               
 [52] crayon_1.3.4                  edgeR_3.28.0                  pkgconfig_2.0.3              
 [55] tweenr_1.0.1                  vipor_0.4.5                   nlme_3.1-143                 
 [58] pkgload_1.0.2                 devtools_2.2.1                rlang_0.4.2                  
 [61] globals_0.12.5                lifecycle_0.1.0               miniUI_0.1.1.1               
 [64] sandwich_2.5-1                BiocFileCache_1.10.2          rsvd_1.0.2                   
 [67] AnnotationHub_2.18.0          rprojroot_1.3-2               polyclip_1.10-0              
 [70] lmtest_0.9-37                 urltools_1.7.3                zoo_1.8-6                    
 [73] beeswarm_0.2.3                base64enc_0.1-3               pheatmap_1.0.12              
 [76] whisker_0.4                   ggridges_0.5.1                processx_3.4.1               
 [79] png_0.1-7                     viridisLite_0.3.0             bitops_1.0-6                 
 [82] R.oo_1.23.0                   KernSmooth_2.23-16            blob_1.2.0                   
 [85] DelayedMatrixStats_1.8.0      stringr_1.4.0                 qvalue_2.18.0                
 [88] gridGraphics_0.4-1            memoise_1.1.0                 magrittr_1.5                 
 [91] plyr_1.8.5                    ica_1.0-2                     gplots_3.0.1.1               
 [94] bibtex_0.4.2.2                zlibbioc_1.32.0               compiler_3.6.2               
 [97] lsei_1.2-0                    dqrng_0.2.1                   plotrix_3.7-7                
[100] fitdistrplus_1.0-14           cli_2.0.1                     XVector_0.26.0               
[103] listenv_0.8.0                 pbapply_1.4-2                 ps_1.3.0                     
[106] MASS_7.3-51.5                 tidyselect_0.2.5              stringi_1.4.4                
[109] yaml_2.2.0                    GOSemSim_2.12.0               locfit_1.5-9.1               
[112] BiocSingular_1.2.1            grid_3.6.2                    fastmatch_1.1-0              
[115] tools_3.6.2                   future.apply_1.4.0            rstudioapi_0.10              
[118] gridExtra_2.3                 farver_2.0.1                  Rtsne_0.15                   
[121] ggraph_2.0.0                  digest_0.6.23                 rvcheck_0.1.7                
[124] shiny_1.4.0                   Rcpp_1.0.3                    SDMTools_1.1-221.2           
[127] BiocVersion_3.10.1            later_1.0.0                   RcppAnnoy_0.0.14             
[130] httr_1.4.1                    npsurv_0.4-0                  Rdpack_0.11-1                
[133] colorspace_1.4-1              XML_3.98-1.20                 fs_1.3.1                     
[136] reticulate_1.14               splines_3.6.2                 statmod_1.4.32               
[139] uwot_0.1.5                    sn_1.5-4                      scater_1.14.6                
[142] graphlayouts_0.5.0            multtest_2.42.0               ggplotify_0.0.4              
[145] plotly_4.9.1                  sessioninfo_1.1.1             xtable_1.8-4                 
[148] tidygraph_1.1.2               zeallot_0.1.0                 testthat_2.3.1               
[151] R6_2.4.1                      TFisher_0.2.0                 pillar_1.4.3                 
[154] htmltools_0.4.0               mime_0.8                      glue_1.3.1                   
[157] fastmap_1.0.1                 BiocNeighbors_1.4.1           interactiveDisplayBase_1.24.0
[160] codetools_0.2-16              fgsea_1.12.0                  pkgbuild_1.0.6               
[163] tsne_0.1-3                    mvtnorm_1.0-12                lattice_0.20-38              
[166] tibble_2.1.3                  numDeriv_2016.8-1.1           ggbeeswarm_0.6.0             
[169] curl_4.3                      leiden_0.3.1                  tfruns_1.4                   
[172] gtools_3.8.1                  GO.db_3.8.2                   limma_3.42.0                 
[175] survival_3.1-8                desc_1.2.0                    munsell_0.5.0                
[178] DO.db_2.9                     GenomeInfoDbData_1.2.2        reshape2_1.4.3               
[181] gtable_0.3.0 
kieranrcampbell commented 4 years ago

Looks like 2 problems here. Size factors not being carried over because I suspect sizeFactors(sce) is NULL. You should be able to recompute them by calling

sce <- scran::computeSumFactors(sce)

after creating the object. But more importantly, it looks like tensorflow probability isn't installed properly:

Error in py_module_import(module, convert = convert) : 
  ModuleNotFoundError: No module named 'tensorflow_probability'

If you run

tensorflow::install_tensorflow(extra_packages='tensorflow-probability', version = "2.1.0")

then call

tensorflow::tf_config()

how does it look?

tkapello commented 4 years ago

Sorry for the delay, time difference... Is it possible to work with tensorflow v 2.0.0?

kieranrcampbell commented 4 years ago

You can try but I think there was a tensorflow probability error last time I did