matrixStats icon indicating copy to clipboard operation
matrixStats copied to clipboard

CLEANUP: useNames=NA is now defunct; next is to drop code explaining that and just give an error

Open HenrikBengtsson opened this issue 1 year ago • 11 comments

I've submitted matrixStats 1.2.0 (2023-12-11), which makes useNames = NA default.

There is a temporary, secret R option/env var to undefunct it, but that's just in case someone runs it to this and need an emergency fix. Next on the road map is to:

  • [ ] Remove all remaining code handling useNames = NA.
  • [ ] Anything but useNames = FALSE and useNames = TRUE should simply be an error.

This one should be a quick cleanup.

HenrikBengtsson avatar Dec 11 '23 21:12 HenrikBengtsson

Hello! Our research project used "SingleR" package which is associated with "matrixStats". We met the problem that "useNames = NA is defunct.". Could you please give us more detailed information about the temporary, secret R option/env var to undefunct it? We don't know the detailed data processing information about SingleR. Maybe we have to emergently change env var to solve this problem. Thank you!

Our code is:

predictions <- SingleR(test=assay_for_singleR,

  •                    ref=cgData, labels=cgData$label.main)
    

Error: useNames = NA is defunct. Instead, specify either useNames = TRUE or useNames = FALSE.

7788zzoo avatar Feb 17 '24 07:02 7788zzoo

You can still R_MATRIXSTATS_USENAMES_NA=deprecated.

That said, this option will soon be removed from matrixStats. After that, your only option is to install an older version of the package.

We don't know the detailed data processing information about SingleR.

Call traceback() when you get that error. That will help you narrow in on where the error occurs. I recommend trying to fix this in whatever code cases this. It's worth it, and it's always risky to rely on legacy code.

HenrikBengtsson avatar Feb 17 '24 08:02 HenrikBengtsson

Will wait with this updated until after the next Bioconductor release 3.19 on 2024-05-01.

HenrikBengtsson avatar Apr 03 '24 19:04 HenrikBengtsson

Our research project used "SingleR" package which is associated with "matrixStats". We met the problem that "useNames = NA is defunct.".

@7788zzoo , this is most likely because you're running an outdated version of Bioconductor. Upgrading would fix it. See https://github.com/LTLA/SingleR/issues/256 for details and instructions.

HenrikBengtsson avatar Apr 11 '24 13:04 HenrikBengtsson

Bioconductor 3.19 was release on 2024-05-01. We can now go ahead and clean out the special code handling useNames = NA. We should basically replace:

  if (is.na(useNames)) {
    deprecatedUseNamesNA()
  } else ...

with

  if (is.na(useNames)) {
    stop("Argument 'useNames' must not be NA")
  } else ...

everywhere.

HenrikBengtsson avatar May 03 '24 21:05 HenrikBengtsson

Where's the package changelog? Couldn't find any deprecation notice. I am looking for hints as to how to fix this... it migh be that there's no easy way around it, the broken downstream dependencies (SCTransform, glmGamPoi, SingleR, etc.) would need to be adjusted on their source code to add this function argument...

Perhaps switching to TRUE if the value was NA, with a warning, as to prevent breaking functionality would've been better. I am just saying this as a constructive criticism. Of course, I am just throwing my opinion with a lot of ignorance on the matter (from what I understand, the argument is not switching any important functionality for the downstream dependant packages.)

I'm using Bioc 3.16 with a matching CRAN snapshot for a course. I will probably downgrade to 1.1.0 on top of the package installation setup. If there's any better advice, a cleaner fix, I'd appreciate it.

adRn-s avatar Jun 18 '24 07:06 adRn-s

Hi adRn's,

as the maintainer of glmGamPoi and contributor to MatrixGenerics, I am sorry to hear about the difficulties that you encountered with switch of the useNames arguments. I think the easiest option is to update MatrixGenerics:

devtools::install_github("Bioconductor/MatrixGenerics@RELEASE_3_18")

After that, I am able to run glmGamPoi on Bioconductor 3.16 with matrixStats version 1.2.0:

> y <- rpois(n = 100, lambda = 0.1)
> glmGamPoi::glm_gp(y)
glmGamPoiFit object:
The data had 1 rows and 100 columns.
A model with 1 coefficient was fitted.
> BiocManager::version()
[1] ‘3.16’
> packageVersion("matrixStats")
[1] ‘1.2.0’
> packageVersion("MatrixGenerics")
[1] ‘1.14.0’

And regarding your question about the changelog; it is in the NEWS.md file (as for every R package) : https://github.com/HenrikBengtsson/matrixStats/blob/develop/NEWS.md#deprecated-and-defunct-1

const-ae avatar Jun 18 '24 07:06 const-ae

Perhaps switching to TRUE if the value was NA, with a warning, as to prevent breaking functionality would've been better. I am just saying this as a constructive criticism.

Agree, and this is what we have done over several years and release cycles. We really have tried to reach an as big audience as possible, but we knew that some will always find out much later and in years from now.

Installing an older version of matrixStats is one workaround. I'll try to mention this in the docs/news.

FYI, news(package = "matrixStats") is the canonical way in R to access the news/changelog.

HenrikBengtsson avatar Jun 18 '24 10:06 HenrikBengtsson

I'm using Bioc 3.16 with a matching CRAN snapshot for a course.

I'd expect you get an older version of matrixStats that is compatible with Bioc 3.16 if you use CRAN snapshots. So, I'm surprised if you get a newer, incompatible version.

HenrikBengtsson avatar Jun 18 '24 10:06 HenrikBengtsson

Thanks for all of your helpful answers. It's under control now 👍🏽 ...Indeed, the CRAN snapshot was set incorrectly. I've just confirmed it. Another incompatibility was around (can't remember well what was it), so I moved the date forward a little... and that's how my frustration grew, jumping from one issue to the other (the usual debugging procedure, maybe). Anyway, thanks again for the support.

adRn-s avatar Jun 18 '24 14:06 adRn-s

Hi adRn's,

as the maintainer of glmGamPoi and contributor to MatrixGenerics, I am sorry to hear about the difficulties that you encountered with switch of the useNames arguments. I think the easiest option is to update MatrixGenerics:

devtools::install_github("Bioconductor/MatrixGenerics@RELEASE_3_18")

After that, I am able to run glmGamPoi on Bioconductor 3.16 with matrixStats version 1.2.0:

> y <- rpois(n = 100, lambda = 0.1)
> glmGamPoi::glm_gp(y)
glmGamPoiFit object:
The data had 1 rows and 100 columns.
A model with 1 coefficient was fitted.
> BiocManager::version()
[1] ‘3.16’
> packageVersion("matrixStats")
[1] ‘1.2.0’
> packageVersion("MatrixGenerics")
[1] ‘1.14.0’

And regarding your question about the changelog; it is in the NEWS.md file (as for every R package) : https://github.com/HenrikBengtsson/matrixStats/blob/develop/NEWS.md#deprecated-and-defunct-1

This solution worked for me too. Thank you!

gabrielascui avatar Jul 25 '24 18:07 gabrielascui

useNames = NA is finally fully defunct and removed. There is no longer a workaround via options or env vars.

HenrikBengtsson avatar Dec 29 '24 07:12 HenrikBengtsson