NathanSkene / EWCE

Expression Weighted Celltype Enrichment. See the package website for up-to-date instructions on usage.
https://nathanskene.github.io/EWCE/index.html
53 stars 25 forks source link

`filter_ctd_genes`: handle new CTD format #72

Closed bschilder closed 2 years ago

bschilder commented 2 years ago

1. Bug description

Update filter_ctd_genes to handle the new CTD format which has extra slots. Also consider exporting this function as it may be generally useful.

Console output

Filtering CTD to 100 genes.
level 1
   - mean_exp
   - specificity
   - specificity_quantiles
   - standardised
Error in ctd_lvl[[mat_nm]][rownames(ctd_lvl[[mat_nm]]) %in% gene_subset,  : 
  incorrect number of dimensions

Expected behaviour

Handle new CTD format.

2. Reproducible example

Code

ctd <- ewceData::ctd()
ctd <- EWCE::standardise_ctd(ctd, input_species = "mouse")
ctd2 <- EWCE:::filter_ctd_genes(ctd=ctd, gene_subset = rownames(ctd$level_1$mean_exp)[1:100])

3. Session info

``` R Under development (unstable) (2022-02-25 r81808) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 20.04.3 LTS Matrix products: default BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.8.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] stats graphics grDevices utils datasets methods base other attached packages: [1] ewceData_1.4.0 ExperimentHub_2.4.0 AnnotationHub_3.4.0 BiocFileCache_2.4.0 dbplyr_2.2.1 [6] BiocGenerics_0.42.0 loaded via a namespace (and not attached): [1] ica_1.0-3 class_7.3-20 ps_1.7.1 [4] Rsamtools_2.12.0 foreach_1.5.2 lmtest_0.9-40 [7] rprojroot_2.0.3 crayon_1.5.1 spatstat.core_2.4-4 [10] MASS_7.3-55 rhdf5filters_1.8.0 nlme_3.1-155 [13] backports_1.4.1 basilisk_1.8.0 rlang_1.0.4 [16] XVector_0.36.0 ROCR_1.0-11 readxl_1.4.0 [19] irlba_2.3.5 nloptr_2.0.3 callr_3.7.1 [22] limma_3.52.2 filelock_1.0.2 BiocParallel_1.30.3 [25] rjson_0.2.21 bit64_4.0.5 glue_1.6.2 [28] scKirby_0.1.0 sctransform_0.3.3 parallel_4.2.0 [31] processx_3.7.0 spatstat.sparse_2.1-1 AnnotationDbi_1.58.0 [34] HGNChelper_0.8.1 spatstat.geom_2.4-0 tidyselect_1.1.2 [37] SummarizedExperiment_1.26.1 usethis_2.1.6 SeuratObject_4.1.0 [40] fitdistrplus_1.1-8 XML_3.99-0.10 tidyr_1.2.0 [43] zoo_1.8-10 ggpubr_0.4.0 GenomicAlignments_1.32.0 [46] ontologyIndex_2.7 xtable_1.8-4 magrittr_2.0.3 [49] evaluate_0.15 ggplot2_3.3.6 cli_3.3.0 [52] zlibbioc_1.42.0 rstudioapi_0.13 miniUI_0.1.1.1 [55] sp_1.5-0 rpart_4.1.16 treeio_1.20.1 [58] maps_3.4.0 shiny_1.7.2 xfun_0.31 [61] clue_0.3-61 pkgbuild_1.3.1 cluster_2.1.2 [64] caTools_1.18.2 echoconda_0.99.6 TSP_1.2-1 [67] GeneOverlap_1.32.0 KEGGREST_1.36.3 tibble_3.1.7 [70] interactiveDisplayBase_1.34.0 expm_0.999-6 ggrepel_0.9.1 [73] ape_5.6-2 listenv_0.8.0 dendextend_1.16.0 [76] Biostrings_2.64.0 png_0.1-7 future_1.26.1 [79] bitops_1.0-7 plyr_1.8.7 cellranger_1.1.0 [82] e1071_1.7-11 pillar_1.8.0 gplots_3.1.3 [85] GlobalOptions_0.1.2 cachem_1.0.6 GenomicFeatures_1.48.3 [88] fs_1.5.2 googleAuthR_2.0.0 GetoptLong_1.0.5 [91] vctrs_0.4.1 ellipsis_0.3.2 generics_0.1.3 [94] gh_1.3.0 devtools_2.4.4 tools_4.2.0 [97] munsell_0.5.0 proxy_0.4-27 DelayedArray_0.22.0 [100] fastmap_1.1.0 compiler_4.2.0 pkgload_1.3.0 [103] abind_1.4-5 httpuv_1.6.5 rtracklayer_1.56.1 [106] sessioninfo_1.2.2 DescTools_0.99.45 plotly_4.10.0 [109] rgeos_0.5-9 GenomeInfoDbData_1.2.8 gridExtra_2.3 [112] lattice_0.20-45 dir.expiry_1.4.0 deldir_1.0-6 [115] gitcreds_0.1.1 sceasy_0.0.6 utf8_1.2.2 [118] later_1.3.0 dplyr_1.0.9 jsonlite_1.8.0 [121] scales_1.2.0 gld_2.6.5 tidytree_0.3.9 [124] pbapply_1.5-0 carData_3.0-5 lazyeval_0.2.2 [127] promises_1.2.0.1 doParallel_1.0.17 car_3.1-0 [130] R.utils_2.12.0 goftest_1.2-3 spatstat.utils_2.3-1 [133] reticulate_1.25 rmarkdown_2.14 cowplot_1.1.1 [136] webshot_0.5.3 Rtsne_0.16 dichromat_2.0-0.1 [139] BSgenome_1.64.0 Biobase_2.56.0 uwot_0.1.11 [142] igraph_1.3.4 HDF5Array_1.24.1 survival_3.2-13 [145] yaml_2.3.5 htmltools_0.5.3 memoise_2.0.1 [148] VariantAnnotation_1.42.1 profvis_0.3.7 BiocIO_1.6.0 [151] Seurat_4.1.1 seriation_1.3.6 IRanges_2.30.0 [154] here_1.0.1 viridisLite_0.4.0 digest_0.6.29 [157] assertthat_0.2.1 mime_0.12 piggyback_0.1.4 [160] rappdirs_0.3.3 registry_0.5-1 downloadR_0.99.3 [163] pals_1.7 RSQLite_2.2.15 yulab.utils_0.0.5 [166] future.apply_1.9.0 mapproj_1.2.8 Exact_3.1 [169] remotes_2.4.2 orthogene_1.2.0 data.table_1.14.2 [172] urlchecker_1.0.1 blob_1.2.3 S4Vectors_0.34.0 [175] R.oo_1.25.0 splines_4.2.0 Rhdf5lib_1.18.2 [178] RCurl_1.98-1.7 broom_1.0.0 hms_1.1.1 [181] gprofiler2_0.2.1 rhdf5_2.40.0 colorspace_2.0-3 [184] BiocManager_1.30.18 shape_1.4.6 GenomicRanges_1.48.0 [187] aplot_0.1.6 GEOquery_2.64.2 Rcpp_1.0.9 [190] RANN_2.6.1 circlize_0.4.15 mvtnorm_1.1-3 [193] fansi_1.0.3 tzdb_0.3.0 parallelly_1.32.0 [196] R6_2.5.1 grid_4.2.0 ggridges_0.5.3 [199] lifecycle_1.0.1 rootSolve_1.8.2.3 MungeSumstats_1.4.5 [202] curl_4.3.2 ggsignif_0.6.3 minqa_1.2.4 [205] gdata_2.18.0.1 leiden_0.4.2 Matrix_1.4-0 [208] RcppAnnoy_0.0.19 RColorBrewer_1.1-3 iterators_1.0.14 [211] stringr_1.4.0 htmlwidgets_1.5.4 polyclip_1.10-0 [214] biomaRt_2.52.0 purrr_0.3.4 gridGraphics_0.5-1 [217] MAGMA.Celltyping_2.0.4 ComplexHeatmap_2.12.0 mgcv_1.8-39 [220] globals_0.15.1 lmom_2.9 patchwork_1.1.1 [223] spatstat.random_2.2-0 progressr_0.10.1 lubridate_1.8.0 [226] codetools_0.2-18 matrixStats_0.62.0 gtools_3.9.3 [229] EWCE_1.5.3 prettyunits_1.1.1 SingleCellExperiment_1.18.0 [232] basilisk.utils_1.8.0 R.methodsS3_1.8.2 GenomeInfoDb_1.32.2 [235] gtable_0.3.0 DBI_1.1.3 stats4_4.2.0 [238] ggfun_0.0.6 tensor_1.5 httr_1.4.3 [241] KernSmooth_2.23-20 stringi_1.7.8 anndata_0.7.5.3 [244] progress_1.2.2 reshape2_1.4.4 heatmaply_1.3.0 [247] viridis_0.6.2 ggtree_3.4.1 xml2_1.3.3 [250] ggdendro_0.1.23 boot_1.3-28 lme4_1.1-30 [253] restfulr_0.0.15 RNOmni_1.0.0 readr_2.1.2 [256] ggplotify_0.1.0 homologene_1.4.68.19.3.27 scattermore_0.8 [259] BiocVersion_3.15.2 bit_4.0.4 MatrixGenerics_1.8.1 [262] spatstat.data_2.2-0 gargle_1.2.0 pkgconfig_2.0.3 [265] babelgene_22.3 corrplot_0.92 rstatix_0.7.0 [268] knitr_1.39 ```