Skip to content

example("SpatialExperiment") requires suggested packages but doesn't check for this #163

Description

@PeteHaitch

These examples depend on the suggested packages DropletUtils and ** BumpyMatrix** but don't check that these are installed/available.
I'm not certain, but I don't think this is expected/correct behaviour.

FWIW my quick read of WRE is that these should have a if(require(pkgname)) guarding the relevant examples which is consistent with the advice in https://r-pkgs.org/dependencies-in-practice.html#sec-dependencies-in-suggests-in-examples-and-vignettes

# Using renv to mock a new R installation with empty package library
renv::init()
#> - Linking packages into the project library ... [55/84] ��������[56/84] ��������[57/84] ��������[58/84] ��������[59/84] ��������[60/84] ��������[61/84] ��������[62/84] ��������[63/84] ��������[64/84] ��������[65/84] ��������[66/84] ��������[67/84] ��������[68/84] ��������[69/84] ��������[70/84] ��������[71/84] ��������[72/84] ��������[73/84] ��������[74/84] ��������[75/84] ��������[76/84] ��������[77/84] ��������[78/84] ��������[79/84] ��������[80/84] ��������[81/84] ��������[82/84] ��������[83/84] ��������[84/84] Done!
#> The following package(s) will be updated in the lockfile:
#> 
#> # Bioconductor ---------------------------------------------------------------
#> - GenomeInfoDbData       [* -> 1.2.13]
#> 
#> # Bioconductor 3.20 ----------------------------------------------------------
#> - Biobase                [* -> 2.66.0]
#> - BiocFileCache          [* -> 2.14.0]
#> - BiocGenerics           [* -> 0.52.0]
#> - BiocVersion            [* -> 3.20.0]
#> - DelayedArray           [* -> 0.32.0]
#> - GenomeInfoDb           [* -> 1.42.1]
#> - GenomicRanges          [* -> 1.58.0]
#> - IRanges                [* -> 2.40.1]
#> - MatrixGenerics         [* -> 1.18.1]
#> - S4Arrays               [* -> 1.6.0]
#> - S4Vectors              [* -> 0.44.0]
#> - SingleCellExperiment   [* -> 1.28.1]
#> - SparseArray            [* -> 1.6.0]
#> - SpatialExperiment      [* -> 1.16.0]
#> - SummarizedExperiment   [* -> 1.36.0]
#> - UCSC.utils             [* -> 1.2.0]
#> - XVector                [* -> 0.46.0]
#> - zlibbioc               [* -> 1.52.0]
#> 
#> # CRAN -----------------------------------------------------------------------
#> - abind                  [* -> 1.4-8]
#> - askpass                [* -> 1.2.1]
#> - base64enc              [* -> 0.1-3]
#> - BiocManager            [* -> 1.30.25]
#> - bit                    [* -> 4.5.0.1]
#> - bit64                  [* -> 4.6.0-1]
#> - blob                   [* -> 1.2.4]
#> - bslib                  [* -> 0.8.0]
#> - cachem                 [* -> 1.1.0]
#> - cli                    [* -> 3.6.3]
#> - cpp11                  [* -> 0.5.1]
#> - crayon                 [* -> 1.5.3]
#> - curl                   [* -> 6.1.0]
#> - DBI                    [* -> 1.2.3]
#> - dbplyr                 [* -> 2.5.0]
#> - digest                 [* -> 0.6.37]
#> - dplyr                  [* -> 1.1.4]
#> - evaluate               [* -> 1.0.3]
#> - fansi                  [* -> 1.0.6]
#> - fastmap                [* -> 1.2.0]
#> - filelock               [* -> 1.0.3]
#> - fontawesome            [* -> 0.5.3]
#> - fs                     [* -> 1.6.5]
#> - generics               [* -> 0.1.3]
#> - glue                   [* -> 1.8.0]
#> - highr                  [* -> 0.11]
#> - htmltools              [* -> 0.5.8.1]
#> - httr                   [* -> 1.4.7]
#> - jquerylib              [* -> 0.1.4]
#> - jsonlite               [* -> 1.8.9]
#> - knitr                  [* -> 1.49]
#> - lattice                [* -> 0.22-6]
#> - lifecycle              [* -> 1.0.4]
#> - magick                 [* -> 2.8.5]
#> - magrittr               [* -> 2.0.3]
#> - Matrix                 [* -> 1.7-1]
#> - matrixStats            [* -> 1.5.0]
#> - memoise                [* -> 2.0.1]
#> - mime                   [* -> 0.12]
#> - openssl                [* -> 2.3.1]
#> - pillar                 [* -> 1.10.1]
#> - pkgconfig              [* -> 2.0.3]
#> - plogr                  [* -> 0.2.0]
#> - purrr                  [* -> 1.0.2]
#> - R6                     [* -> 2.5.1]
#> - rappdirs               [* -> 0.3.3]
#> - Rcpp                   [* -> 1.0.14]
#> - renv                   [* -> 1.0.11]
#> - rjson                  [* -> 0.2.23]
#> - rlang                  [* -> 1.1.4]
#> - rmarkdown              [* -> 2.29]
#> - RSQLite                [* -> 2.3.9]
#> - sass                   [* -> 0.4.9]
#> - sessioninfo            [* -> 1.2.2]
#> - stringi                [* -> 1.8.4]
#> - stringr                [* -> 1.5.1]
#> - sys                    [* -> 3.4.3]
#> - tibble                 [* -> 3.2.1]
#> - tidyr                  [* -> 1.3.1]
#> - tidyselect             [* -> 1.2.1]
#> - tinytex                [* -> 0.54]
#> - utf8                   [* -> 1.2.4]
#> - vctrs                  [* -> 0.6.5]
#> - withr                  [* -> 3.0.2]
#> - xfun                   [* -> 0.50]
#> - yaml                   [* -> 2.3.10]
#> 
#> The version of R recorded in the lockfile will be updated:
#> - R                      [* -> 4.4.2]
#> 
#> - Lockfile written to "/private/var/folders/z7/48jz0mzd6ms7zdv4vhkgns_c001kx2/T/Rtmp7ajbf9/reprex-ff59599d1f8c-ivory-pewee/renv.lock".
install.packages("BiocManager")
#> The following package(s) will be installed:
#> - BiocManager [1.30.25]
#> These packages will be installed into "/private/var/folders/z7/48jz0mzd6ms7zdv4vhkgns_c001kx2/T/Rtmp7ajbf9/reprex-ff59599d1f8c-ivory-pewee/renv/library/macos/R-4.4/aarch64-apple-darwin20".
#> 
#> # Installing packages --------------------------------------------------------
#> - Installing BiocManager ...                    OK [linked from cache]
#> Successfully installed 1 package in 4.3 milliseconds.
BiocManager::install("SpatialExperiment", ask = FALSE)
#> 'getOption("repos")' replaces Bioconductor standard repositories, see
#> 'help("repositories", package = "BiocManager")' for details.
#> Replacement repositories:
#>     BioCsoft: https://bioconductor.org/packages/3.20/bioc
#>     BioCann: https://bioconductor.org/packages/3.20/data/annotation
#>     BioCexp: https://bioconductor.org/packages/3.20/data/experiment
#>     BioCworkflows: https://bioconductor.org/packages/3.20/workflows
#>     BioCbooks: https://bioconductor.org/packages/3.20/books
#>     CRAN: https://packagemanager.posit.co/cran/latest
#> Bioconductor version 3.20 (BiocManager 1.30.25), R 4.4.2 (2024-10-31)
#> Warning: package(s) not installed when version(s) same as or greater than current; use
#>   `force = TRUE` to re-install: 'SpatialExperiment'
#> Old packages: 'rlang', 'SparseArray'
#> 
#> The downloaded binary packages are in
#>  /var/folders/z7/48jz0mzd6ms7zdv4vhkgns_c001kx2/T//RtmpULLNjL/downloaded_packages
library(SpatialExperiment)
#> Loading required package: SingleCellExperiment
#> Loading required package: SummarizedExperiment
#> Loading required package: MatrixGenerics
#> Loading required package: matrixStats
#> 
#> Attaching package: 'MatrixGenerics'
#> The following objects are masked from 'package:matrixStats':
#> 
#>     colAlls, colAnyNAs, colAnys, colAvgsPerRowSet, colCollapse,
#>     colCounts, colCummaxs, colCummins, colCumprods, colCumsums,
#>     colDiffs, colIQRDiffs, colIQRs, colLogSumExps, colMadDiffs,
#>     colMads, colMaxs, colMeans2, colMedians, colMins, colOrderStats,
#>     colProds, colQuantiles, colRanges, colRanks, colSdDiffs, colSds,
#>     colSums2, colTabulates, colVarDiffs, colVars, colWeightedMads,
#>     colWeightedMeans, colWeightedMedians, colWeightedSds,
#>     colWeightedVars, rowAlls, rowAnyNAs, rowAnys, rowAvgsPerColSet,
#>     rowCollapse, rowCounts, rowCummaxs, rowCummins, rowCumprods,
#>     rowCumsums, rowDiffs, rowIQRDiffs, rowIQRs, rowLogSumExps,
#>     rowMadDiffs, rowMads, rowMaxs, rowMeans2, rowMedians, rowMins,
#>     rowOrderStats, rowProds, rowQuantiles, rowRanges, rowRanks,
#>     rowSdDiffs, rowSds, rowSums2, rowTabulates, rowVarDiffs, rowVars,
#>     rowWeightedMads, rowWeightedMeans, rowWeightedMedians,
#>     rowWeightedSds, rowWeightedVars
#> Loading required package: GenomicRanges
#> Loading required package: stats4
#> Loading required package: BiocGenerics
#> 
#> Attaching package: 'BiocGenerics'
#> The following objects are masked from 'package:stats':
#> 
#>     IQR, mad, sd, var, xtabs
#> The following objects are masked from 'package:base':
#> 
#>     anyDuplicated, aperm, append, as.data.frame, basename, cbind,
#>     colnames, dirname, do.call, duplicated, eval, evalq, Filter, Find,
#>     get, grep, grepl, intersect, is.unsorted, lapply, Map, mapply,
#>     match, mget, order, paste, pmax, pmax.int, pmin, pmin.int,
#>     Position, rank, rbind, Reduce, rownames, sapply, saveRDS, setdiff,
#>     table, tapply, union, unique, unsplit, which.max, which.min
#> Loading required package: S4Vectors
#> 
#> Attaching package: 'S4Vectors'
#> The following object is masked from 'package:utils':
#> 
#>     findMatches
#> The following objects are masked from 'package:base':
#> 
#>     expand.grid, I, unname
#> Loading required package: IRanges
#> Loading required package: GenomeInfoDb
#> Loading required package: Biobase
#> Welcome to Bioconductor
#> 
#>     Vignettes contain introductory material; view with
#>     'browseVignettes()'. To cite Bioconductor, see
#>     'citation("Biobase")', and for packages 'citation("pkgname")'.
#> 
#> Attaching package: 'Biobase'
#> The following object is masked from 'package:MatrixGenerics':
#> 
#>     rowMedians
#> The following objects are masked from 'package:matrixStats':
#> 
#>     anyMissing, rowMedians
example("SpatialExperiment")
#> 
#> SptlEx> #########################################################
#> SptlEx> # Example 1: Spot-based ST (10x Visium) using constructor
#> SptlEx> #########################################################
#> SptlEx> 
#> SptlEx> dir <- system.file(
#> SptlEx+     file.path("extdata", "10xVisium", "section1", "outs"),
#> SptlEx+     package = "SpatialExperiment")
#> 
#> SptlEx> # read in counts
#> SptlEx> fnm <- file.path(dir, "raw_feature_bc_matrix")
#> 
#> SptlEx> sce <- DropletUtils::read10xCounts(fnm)
#> Error in loadNamespace(x): there is no package called 'DropletUtils'

Created on 2025-01-21 with reprex v2.1.1

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.4.2 (2024-10-31)
#>  os       macOS Sequoia 15.0.1
#>  system   aarch64, darwin20
#>  ui       X11
#>  language (EN)
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       Australia/Melbourne
#>  date     2025-01-21
#>  pandoc   3.2 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/aarch64/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  !  package              * version date (UTC) lib source
#>  P  abind                  1.4-8   2024-09-12 [?] CRAN (R 4.4.1)
#>  P  Biobase              * 2.66.0  2024-10-29 [?] Bioconductor 3.20 (R 4.4.0)
#>  P  BiocGenerics         * 0.52.0  2024-10-29 [?] Bioconductor 3.20 (R 4.4.0)
#>  P  BiocManager            1.30.25 2024-08-28 [?] CRAN (R 4.4.1)
#>  P  cli                    3.6.3   2024-06-21 [?] CRAN (R 4.4.0)
#>  P  crayon                 1.5.3   2024-06-20 [?] CRAN (R 4.4.0)
#>  P  DelayedArray           0.32.0  2024-10-29 [?] Bioconductor 3.20 (R 4.4.0)
#>  P  digest                 0.6.37  2024-08-19 [?] CRAN (R 4.4.1)
#>  P  evaluate               1.0.3   2025-01-10 [?] CRAN (R 4.4.1)
#>  P  fastmap                1.2.0   2024-05-15 [?] CRAN (R 4.4.0)
#>  P  fs                     1.6.5   2024-10-30 [?] CRAN (R 4.4.1)
#>  P  GenomeInfoDb         * 1.42.1  2024-11-28 [?] Bioconductor 3.20 (R 4.4.2)
#>  P  GenomeInfoDbData       1.2.13  2024-10-30 [?] Bioconductor
#>  P  GenomicRanges        * 1.58.0  2024-10-29 [?] Bioconductor 3.20 (R 4.4.0)
#>  P  glue                   1.8.0   2024-09-30 [?] CRAN (R 4.4.1)
#>  P  htmltools              0.5.8.1 2024-04-04 [?] CRAN (R 4.4.0)
#>  P  httr                   1.4.7   2023-08-15 [?] CRAN (R 4.4.0)
#>  P  IRanges              * 2.40.1  2024-12-05 [?] Bioconductor 3.20 (R 4.4.2)
#>  P  jsonlite               1.8.9   2024-09-20 [?] CRAN (R 4.4.1)
#>  P  knitr                  1.49    2024-11-08 [?] CRAN (R 4.4.1)
#>  P  lattice                0.22-6  2024-03-20 [?] CRAN (R 4.4.2)
#>  P  lifecycle              1.0.4   2023-11-07 [?] CRAN (R 4.4.0)
#>  P  magick                 2.8.5   2024-09-20 [?] CRAN (R 4.4.1)
#>  P  magrittr               2.0.3   2022-03-30 [?] CRAN (R 4.4.0)
#>  P  Matrix                 1.7-1   2024-10-18 [?] CRAN (R 4.4.2)
#>  P  MatrixGenerics       * 1.18.1  2025-01-09 [?] Bioconductor 3.20 (R 4.4.2)
#>  P  matrixStats          * 1.5.0   2025-01-07 [?] CRAN (R 4.4.1)
#>  P  R6                     2.5.1   2021-08-19 [?] CRAN (R 4.4.0)
#>  P  Rcpp                   1.0.14  2025-01-12 [?] CRAN (R 4.4.1)
#>  P  renv                   1.0.11  2024-10-12 [?] CRAN (R 4.4.1)
#>  R  reprex                 2.1.1   <NA>       [?] <NA>
#>  P  rjson                  0.2.23  2024-09-16 [?] CRAN (R 4.4.1)
#>  VP rlang                  1.1.4   2025-01-17 [?] RSPM (R 4.4.0) (on disk 1.1.5)
#>  P  rmarkdown              2.29    2024-11-04 [?] CRAN (R 4.4.1)
#>  R  rstudioapi             0.17.1  <NA>       [?] <NA>
#>  P  S4Arrays               1.6.0   2024-10-29 [?] Bioconductor 3.20 (R 4.4.0)
#>  P  S4Vectors            * 0.44.0  2024-10-29 [?] Bioconductor 3.20 (R 4.4.0)
#>  P  sessioninfo            1.2.2   2021-12-06 [?] CRAN (R 4.4.0)
#>  P  SingleCellExperiment * 1.28.1  2024-11-10 [?] Bioconductor 3.20 (R 4.4.2)
#>     SparseArray            1.6.0   2024-11-08 [1] Bioconductor 3.20 (R 4.4.1)
#>  P  SpatialExperiment    * 1.16.0  2024-11-08 [?] Bioconductor 3.20 (R 4.4.1)
#>  P  SummarizedExperiment * 1.36.0  2024-10-29 [?] Bioconductor 3.20 (R 4.4.0)
#>  P  UCSC.utils             1.2.0   2024-10-29 [?] Bioconductor 3.20 (R 4.4.0)
#>  P  withr                  3.0.2   2024-10-28 [?] CRAN (R 4.4.1)
#>  P  xfun                   0.50    2025-01-07 [?] CRAN (R 4.4.1)
#>  P  XVector                0.46.0  2024-10-29 [?] Bioconductor 3.20 (R 4.4.0)
#>  P  yaml                   2.3.10  2024-07-26 [?] CRAN (R 4.4.0)
#>  P  zlibbioc               1.52.0  2024-10-29 [?] Bioconductor 3.20 (R 4.4.0)
#> 
#>  [1] /private/var/folders/z7/48jz0mzd6ms7zdv4vhkgns_c001kx2/T/Rtmp7ajbf9/reprex-ff59599d1f8c-ivory-pewee/renv/library/macos/R-4.4/aarch64-apple-darwin20
#>  [2] /Users/hickey/Library/Caches/org.R-project.R/R/renv/sandbox/macos/R-4.4/aarch64-apple-darwin20/f7156815
#> 
#>  V ── Loaded and on-disk version mismatch.
#>  P ── Loaded and on-disk path mismatch.
#>  R ── Package was removed from disk.
#> 
#> ──────────────────────────────────────────────────────────────────────────────

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions