Bioconductor / BiocGenerics

Defines many S4 generic functions used in Bioconductor
https://bioconductor.org/packages/BiocGenerics
11 stars 7 forks source link

as.data.frame.integer(x) is deprecated #16

Closed sgibb closed 7 months ago

sgibb commented 7 months ago

Hi Hervé,

I am confused about an error on my topdownr package caused by as.data.frame generic:

https://bioconductor.org/checkResults/devel/data-experiment-LATEST/topdownrdata/nebbiolo1-checksrc.html

Warning in as.data.frame.numeric(value, row.names = row.names, optional = optional, : Direct call of 'as.data.frame.numeric()' is deprecated. Use 'as.data.frame.vector()' or 'as.data.frame()' instead Error in value[3L] : converted from warning: Direct call of 'as.data.frame.numeric()' is deprecated. Use 'as.data.frame.vector()' or 'as.data.frame()' instead

The backtrace of one of my unit tests is:

── Warning (test_utils.R:158:5): .groupByLabels ────────────────────────────────
Direct call of 'as.data.frame.integer()' is deprecated.  Use 'as.data.frame.vector()' or 'as.data.frame()' instead
Backtrace:
     ▆
  1. ├─testthat::expect_equal(...) at test_utils.R:158:5
  2. │ └─testthat::quasi_label(enquo(object), label, arg = "object")
  3. │   └─rlang::eval_bare(expr, quo_get_env(quo))
  4. └─topdownr:::.groupByLabels(DF, c("ID", "LE"))
  5.   ├─BiocGenerics::as.data.frame(x) at topdownr/R/utils.R:241:5
  6.   └─S4Vectors::as.data.frame(x)
  7.     └─S4Vectors (local) .local(x, row.names, optional, ...)
  8.       ├─BiocGenerics::lapply(...)
  9.       └─base::lapply(...)
 10.         └─S4Vectors (local) FUN(X[[i]], ...)
 11.           ├─BiocGenerics::as.data.frame(col, optional = optional)
 12.           ├─base::as.data.frame(col, optional = optional)
 13.           └─base::as.data.frame.integer(col, optional = optional)
 14.             └─base::.Deprecated(...)Do you have a

A MWE:

x <- 1L:3L

as.data.frame(x)
#>   x
#> 1 1
#> 2 2
#> 3 3

library("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, setdiff, table,
#>     tapply, union, unique, unsplit, which.max, which.min

as.data.frame(x)
#> Warning in as.data.frame.integer(x): Direct call of 'as.data.frame.integer()'
#> is deprecated.  Use 'as.data.frame.vector()' or 'as.data.frame()' instead
#>   x
#> 1 1
#> 2 2
#> 3 3

Created on 2024-03-15 with reprex v2.1.0

Session info ``` r sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R Under development (unstable) (2024-03-15 r86132) #> os Debian GNU/Linux 12 (bookworm) #> system x86_64, linux-gnu #> ui X11 #> language en #> collate de_DE.UTF-8 #> ctype de_DE.UTF-8 #> tz Europe/Berlin #> date 2024-03-15 #> pandoc 2.19.2 @ /home/sebastian/.guix-profile/bin/ (via rmarkdown) #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date (UTC) lib source #> BiocGenerics * 0.49.1 2023-11-01 [1] Bioconductor #> cli 3.6.2 2023-12-11 [1] CRAN (R 4.4.0) #> digest 0.6.35 2024-03-11 [1] CRAN (R 4.4.0) #> evaluate 0.23 2023-11-01 [1] CRAN (R 4.4.0) #> fastmap 1.1.1 2023-02-24 [1] CRAN (R 4.4.0) #> fs 1.6.3 2023-07-20 [1] CRAN (R 4.4.0) #> glue 1.7.0 2024-01-09 [1] CRAN (R 4.4.0) #> htmltools 0.5.7 2023-11-03 [1] CRAN (R 4.4.0) #> knitr 1.45 2023-10-30 [1] CRAN (R 4.4.0) #> lifecycle 1.0.4 2023-11-07 [1] CRAN (R 4.4.0) #> reprex 2.1.0 2024-01-11 [1] CRAN (R 4.4.0) #> rlang 1.1.3 2024-01-10 [1] CRAN (R 4.4.0) #> rmarkdown 2.26 2024-03-05 [1] CRAN (R 4.4.0) #> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.4.0) #> withr 3.0.0 2024-01-16 [1] CRAN (R 4.4.0) #> xfun 0.42 2024-02-08 [1] CRAN (R 4.4.0) #> yaml 2.3.8 2023-12-11 [1] CRAN (R 4.4.0) #> #> [1] /home/sebastian/opt/R/lib/R/library #> #> ────────────────────────────────────────────────────────────────────────────── ```

I looked at the as.data.frame generic which is just setGeneric("as.data.frame", signature="x"). Any idea to fix this?

Best wishes,

Sebastian

hpages commented 7 months ago

See https://github.com/Bioconductor/S4Vectors/issues/122

sgibb commented 7 months ago

Works, thanks!