# E. Issues & Solutions

Original version: 16 October, 2023

    library(AlphaMissenseR)

# Updating duckdb to 0.9.1

The R duckdb client version 0.9.1 cannot read databases created with previous versions of the package. The duckdb error message indicates

> > am_available() Error in h(simpleError(msg, call)) : error in evaluating the argument ‘drv’ in selecting a method for function ‘dbConnect’: rapi_startup: Failed to open database: IO Error: Trying to read a database file with version number 51, but we can only read version 64.

> The database file was created with DuckDB version v0.8.0 or v0.8.1.

> The storage of DuckDB is not yet stable; newer versions of DuckDB cannot read old database files and vice versa. The storage will be stabilized when version 1.0 releases.

> For now, we recommend that you load the database file in a supported version of DuckDB, and use the EXPORT DATABASE command followed by IMPORT DATABASE on the current version of DuckDB.

> See the storage page for more information: https://duckdb.org/internals/storage

but in practice the most straight-forward solution is to remove existing AlphaMissenseR data resources and ‘start again’.

The following attempts to identify AlphaMissenseR data resources cached locally

    am_rids <-
        bfcinfo() |>
        dplyr::filter(
            grepl("zenodo", rname) |
            startsWith(rname, "AlphaMissense_")
        ) |>
        pull(rid)

After verifying that these resources have not been created outside AlphaMissenseR, remove them.

    BiocFileCache::bfcremove(rids = am_rids)

Commands such as `am_available()` should report no files cached. The command

    am_data("gene_hg38")
    #> # Source:   table<gene_hg38> [?? x 2]
    #> # Database: DuckDB v1.3.2 [biocbuild@Windows Server x64:R 4.5.1/C:\Users\biocbuild\AppData\Local\R\cache\R\BiocFileCache\1dab04d9b1b81_1dab04d9b1b81]
    #>    transcript_id      mean_am_pathogenicity
    #>    <chr>                              <dbl>
    #>  1 ENST00000000233.10                 0.742
    #>  2 ENST00000000412.8                  0.378
    #>  3 ENST00000001008.6                  0.422
    #>  4 ENST00000001146.6                  0.467
    #>  5 ENST00000002125.9                  0.351
    #>  6 ENST00000002165.11                 0.406
    #>  7 ENST00000002501.10                 0.320
    #>  8 ENST00000002596.6                  0.471
    #>  9 ENST00000002829.8                  0.524
    #> 10 ENST00000003084.10                 0.405
    #> # ℹ more rows

will re-download the file and insert it into a database that functions with duckdb 0.9.1.

# Resource temporarily unavailable

Trying to access a data resource with `am_data()` may sometimes result in a DuckDB errors about “Resource unavailable”.

    > am_data("hg38")

    * [10:05:09][warning] error in evaluating the argument 'drv' in selecting a
        method for function 'dbConnect': rapi_startup: Failed to open database:
        IO Error: Could not set lock on file
        ".../Caches/org.R-project.R/R/BiocFileCache/1ec5157ddaa2_1ec5157ddaa2":
        Resource unavailable

    Error in value[[3L]](cond) :
        failed to connect to DuckDB database, see 'Issues & Solutions' vignette

This occures when the database is being used by an independent R process. The solution is to identify the process and disconnect from the database using, e.g., `db_disconnect_all()`.

# Finally

Remember to disconnect and shutdown all managed DuckDB connections.

    db_disconnect_all()
    #> * [17:22:55][info] disconnecting all registered connections

Database connections that are not closed correctly trigger warning messages.

# Session information

    sessionInfo()
    #> R version 4.5.1 (2025-06-13 ucrt)
    #> Platform: x86_64-w64-mingw32/x64
    #> Running under: Windows Server 2022 x64 (build 20348)
    #>
    #> Matrix products: default
    #>   LAPACK version 3.12.1
    #>
    #> locale:
    #> [1] LC_COLLATE=C
    #> [2] LC_CTYPE=English_United States.utf8
    #> [3] LC_MONETARY=English_United States.utf8
    #> [4] LC_NUMERIC=C
    #> [5] LC_TIME=English_United States.utf8
    #>
    #> time zone: America/New_York
    #> tzcode source: internal
    #>
    #> attached base packages:
    #> [1] stats4    stats     graphics  grDevices utils     datasets  methods
    #> [8] base
    #>
    #> other attached packages:
    #>  [1] ensembldb_2.33.1        AnnotationFilter_1.33.0 GenomicFeatures_1.61.6
    #>  [4] AnnotationDbi_1.71.1    Biobase_2.69.0          GenomicRanges_1.61.1
    #>  [7] Seqinfo_0.99.2          IRanges_2.43.0          S4Vectors_0.47.0
    #> [10] gghalves_0.1.4          ggplot2_3.5.2           ggdist_3.3.3
    #> [13] tidyr_1.3.1             ExperimentHub_2.99.5    AnnotationHub_3.99.6
    #> [16] BiocFileCache_2.99.5    dbplyr_2.5.0            BiocGenerics_0.55.1
    #> [19] generics_0.1.4          AlphaMissenseR_1.5.3    dplyr_1.1.4
    #>
    #> loaded via a namespace (and not attached):
    #>  [1] DBI_1.2.3                   bitops_1.0-9
    #>  [3] httr2_1.2.1                 rlang_1.1.6
    #>  [5] magrittr_2.0.3              matrixStats_1.5.0
    #>  [7] compiler_4.5.1              RSQLite_2.4.2
    #>  [9] png_0.1-8                   vctrs_0.6.5
    #> [11] ProtGenerics_1.41.0         pkgconfig_2.0.3
    #> [13] crayon_1.5.3                fastmap_1.2.0
    #> [15] XVector_0.49.0              labeling_0.4.3
    #> [17] utf8_1.2.6                  Rsamtools_2.25.2
    #> [19] promises_1.3.3              rmarkdown_2.29
    #> [21] UCSC.utils_1.5.0            purrr_1.1.0
    #> [23] bit_4.6.0                   xfun_0.52
    #> [25] cachem_1.1.0                GenomeInfoDb_1.45.9
    #> [27] jsonlite_2.0.0              blob_1.2.4
    #> [29] later_1.4.2                 DelayedArray_0.35.2
    #> [31] BiocParallel_1.43.4         parallel_4.5.1
    #> [33] spdl_0.0.5                  R6_2.6.1
    #> [35] bslib_0.9.0                 RColorBrewer_1.1-3
    #> [37] rtracklayer_1.69.1          jquerylib_0.1.4
    #> [39] Rcpp_1.1.0                  SummarizedExperiment_1.39.1
    #> [41] knitr_1.50                  BiocBaseUtils_1.11.2
    #> [43] Matrix_1.7-3                httpuv_1.6.16
    #> [45] tidyselect_1.2.1            abind_1.4-8
    #> [47] dichromat_2.0-0.1           yaml_2.3.10
    #> [49] codetools_0.2-20            curl_6.4.0
    #> [51] rjsoncons_1.3.2             lattice_0.22-7
    #> [53] tibble_3.3.0                shiny_1.11.1
    #> [55] bio3d_2.4-5                 withr_3.0.2
    #> [57] KEGGREST_1.49.1             evaluate_1.0.4
    #> [59] r3dmol_0.1.2                Biostrings_2.77.2
    #> [61] pillar_1.11.0               BiocManager_1.30.26
    #> [63] filelock_1.0.3              MatrixGenerics_1.21.0
    #> [65] whisker_0.4.1               distributional_0.5.0
    #> [67] RCurl_1.98-1.17             BiocVersion_3.22.0
    #> [69] scales_1.4.0                xtable_1.8-4
    #> [71] glue_1.8.0                  lazyeval_0.2.2
    #> [73] tools_4.5.1                 BiocIO_1.19.0
    #> [75] GenomicAlignments_1.45.2    XML_3.99-0.18
    #> [77] grid_4.5.1                  colorspace_2.1-1
    #> [79] RcppSpdlog_0.0.22           duckdb_1.3.2
    #> [81] restfulr_0.0.16             cli_3.6.5
    #> [83] rappdirs_0.3.3              shiny.gosling_1.5.0
    #> [85] S4Arrays_1.9.1              viridisLite_0.4.2
    #> [87] gtable_0.3.6                sass_0.4.10
    #> [89] digest_0.6.37               SparseArray_1.9.1
    #> [91] rjson_0.2.23                htmlwidgets_1.6.4
    #> [93] farver_2.1.2                memoise_2.0.1
    #> [95] htmltools_0.5.8.1           lifecycle_1.0.4
    #> [97] httr_1.4.7                  mime_0.13
    #> [99] bit64_4.6.0-1