LieberInstitute / spatialLIBD

Code for the spatialLIBD R/Bioconductor package and shiny app
http://LieberInstitute.github.io/spatialLIBD/
78 stars 16 forks source link

[BUG] An error when using registration_wrapper(). #50

Closed GGFranck closed 9 months ago

GGFranck commented 10 months ago

I'm so sorry to make troubles because I have no idea to solve the little bug. I'm learing the spatial registraion when I'm following the _Guide to Spatial Registration_. I just copy and run the codes from the guide. However, when it turns to the function registration_wrapper(), I meet an error. Here is the code.

library("spatialLIBD")
library("SingleCellExperiment")

## get reference layer enrichment statistics
layer_modeling_results <- fetch_data(type = "modeling_results")

# Download and save a local cache of the data available at:
# https://github.com/LieberInstitute/10xPilot_snRNAseq-human#processed-data
bfc <- BiocFileCache::BiocFileCache()
url <- paste0(
  "https://libd-snrnaseq-pilot.s3.us-east-2.amazonaws.com/",
  "SCE_DLPFC-n3_tran-etal.rda"
)
local_data <- BiocFileCache::bfcrpath(url, x = bfc)

load(local_data, verbose = TRUE)

## Perform the spatial registration
sce_modeling_results <- registration_wrapper(
  sce = sce.dlpfc.tran,
  var_registration = "cellType",
  var_sample_id = "donor",
  gene_ensembl = "gene_id",
  gene_name = "gene_name"
)

It's the same with the guide. And here is the error.

2023-10-26 21:23:51 make pseudobulk object
2023-10-26 21:23:55 dropping 13 pseudo-bulked samples that are below 'min_ncells'.
2023-10-26 21:23:55 drop lowly expressed genes
2023-10-26 21:23:55 normalize expression
2023-10-26 21:23:56 create model matrix
Error: The resulting model is not full rank. You might have some 'var_registration' levels that are empty which you can drop with 'droplevels()'. Check the output of 'table(sce_pseudo[[var_registration]])'.

Expected behavior

## Perform the spatial registration
sce_modeling_results <- registration_wrapper(
    sce = sce.dlpfc.tran,
    var_registration = "cellType",
    var_sample_id = "donor",
    gene_ensembl = "gene_id",
    gene_name = "gene_name"
)
#> 2023-09-05 20:41:51.590053 make pseudobulk object
#> 2023-09-05 20:41:54.461424 dropping 13 pseudo-bulked samples that are below 'min_ncells'.
#> 2023-09-05 20:41:54.569132 drop lowly expressed genes
#> 2023-09-05 20:41:54.90711 normalize expression
#> 2023-09-05 20:41:55.922038 create model matrix
#> 2023-09-05 20:41:55.972502 run duplicateCorrelation()
#> 2023-09-05 20:42:32.153248 The estimated correlation is: 0.138734774807097
#> 2023-09-05 20:42:32.157722 computing enrichment statistics
#> 2023-09-05 20:42:34.301225 extract and reformat enrichment results
#> 2023-09-05 20:42:34.464852 running the baseline pairwise model
#> 2023-09-05 20:42:34.695452 computing pairwise statistics
#> 2023-09-05 20:42:37.152251 computing F-statistics

R Session Information

Please report the output of either sessionInfo() or sessioninfo::session_info() here.

```R options(width = 120) ## insert session info here # sessioninfo::session_info() ## provides GitHub, pandoc, and other details # sessionInfo() ## base R function in case you don't want to install sessioninfo > sessionInfo() R version 4.2.1 (2022-06-23) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Debian GNU/Linux 11 (bullseye) Matrix products: default BLAS: /home/opt/R/4.2.1/lib/R/lib/libRblas.so LAPACK: /home/opt/R/4.2.1/lib/R/lib/libRlapack.so 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] stats4 stats graphics grDevices utils datasets methods base other attached packages: [1] spatialLIBD_1.10.1 SpatialExperiment_1.8.1 SingleCellExperiment_1.18.0 [4] SummarizedExperiment_1.26.1 Biobase_2.58.0 GenomicRanges_1.48.0 [7] GenomeInfoDb_1.34.9 IRanges_2.32.0 S4Vectors_0.36.2 [10] BiocGenerics_0.44.0 MatrixGenerics_1.8.1 matrixStats_1.0.0 loaded via a namespace (and not attached): [1] spam_2.9-1 AnnotationHub_3.6.0 [3] BiocFileCache_2.6.1 lazyeval_0.2.2 [5] BiocParallel_1.32.6 ggplot2_3.4.2 [7] scater_1.26.1 benchmarkme_1.0.8 [9] digest_0.6.33 foreach_1.5.2 [11] htmltools_0.5.5 viridis_0.6.4 [13] magick_2.7.4 fansi_1.0.4 [15] magrittr_2.0.3 memoise_2.0.1 [17] ScaledMatrix_1.4.0 paletteer_1.5.0 [19] config_0.3.1 doParallel_1.0.17 [21] limma_3.52.2 Biostrings_2.66.0 [23] R.utils_2.12.0 colorspace_2.1-0 [25] ggrepel_0.9.3 blob_1.2.4 [27] rappdirs_0.3.3 dplyr_1.1.2 [29] crayon_1.5.2 RCurl_1.98-1.12 [31] jsonlite_1.8.7 iterators_1.0.14 [33] glue_1.6.2 gtable_0.3.3 [35] zlibbioc_1.44.0 XVector_0.38.0 [37] DelayedArray_0.22.0 BiocSingular_1.12.0 [39] DropletUtils_1.18.1 Rhdf5lib_1.18.2 [41] maps_3.4.0 HDF5Array_1.24.2 [43] scales_1.2.1 DBI_1.1.3 [45] edgeR_3.38.4 Rcpp_1.0.11 [47] viridisLite_0.4.2 xtable_1.8-4 [49] dqrng_0.3.0 bit_4.0.5 [51] rsvd_1.0.5 dotCall64_1.0-2 [53] DT_0.28 htmlwidgets_1.6.2 [55] httr_1.4.6 RColorBrewer_1.1-3 [57] ellipsis_0.3.2 pkgconfig_2.0.3 [59] XML_3.99-0.10 R.methodsS3_1.8.2 [61] scuttle_1.8.4 sass_0.4.7 [63] dbplyr_2.3.3 locfit_1.5-9.6 [65] utf8_1.2.3 tidyselect_1.2.0 [67] rlang_1.1.1 later_1.3.1 [69] AnnotationDbi_1.60.2 munsell_0.5.0 [71] BiocVersion_3.16.0 tools_4.2.1 [73] cachem_1.0.8 cli_3.6.1 [75] generics_0.1.3 RSQLite_2.3.1 [77] ExperimentHub_2.6.0 fastmap_1.1.1 [79] yaml_2.3.7 rematch2_2.1.2 [81] bit64_4.0.5 purrr_1.0.1 [83] KEGGREST_1.38.0 sparseMatrixStats_1.8.0 [85] mime_0.12 R.oo_1.25.0 [87] compiler_4.2.1 rstudioapi_0.14 [89] beeswarm_0.4.0 plotly_4.10.0 [91] filelock_1.0.2 curl_5.0.1 [93] png_0.1-8 interactiveDisplayBase_1.36.0 [95] statmod_1.5.0 tibble_3.2.1 [97] bslib_0.5.0 fields_14.1 [99] lattice_0.20-45 Matrix_1.6-0 [101] vctrs_0.6.3 pillar_1.9.0 [103] lifecycle_1.0.3 rhdf5filters_1.8.0 [105] BiocManager_1.30.21.1 jquerylib_0.1.4 [107] BiocNeighbors_1.16.0 data.table_1.14.8 [109] cowplot_1.1.1 bitops_1.0-7 [111] irlba_2.3.5 httpuv_1.6.11 [113] rtracklayer_1.58.0 R6_2.5.1 [115] BiocIO_1.8.0 promises_1.2.0.1 [117] gridExtra_2.3 vipor_0.4.5 [119] sessioninfo_1.2.2 codetools_0.2-18 [121] benchmarkmeData_1.0.4 golem_0.4.1 [123] rhdf5_2.40.0 rjson_0.2.21 [125] withr_2.5.0 shinyWidgets_0.7.6 [127] GenomicAlignments_1.34.1 Rsamtools_2.14.0 [129] GenomeInfoDbData_1.2.9 parallel_4.2.1 [131] grid_4.2.1 beachmat_2.12.0 [133] tidyr_1.3.0 attempt_0.3.1 [135] DelayedMatrixStats_1.18.0 shiny_1.7.4.1 [137] ggbeeswarm_0.7.2 restfulr_0.0.15 ```