stemangiola / tidybulk

Brings bulk and pseudobulk transcriptomics to the tidyverse
https://stemangiola.github.io/tidybulk/
164 stars 25 forks source link

`tidybulk` Remove hard dependency for `DESeq2` #286

Closed stemangiola closed 1 year ago

stemangiola commented 1 year ago

If I install tidybulk without DESeq2 it throws an error, even if DESeq2 is just in the suggests, in the DESCRIPTION file.

chilampoon commented 1 year ago

i also got this error in tests before I installed DESeq2

── Failed tests ─────────────────────────────────────
Error (test-bulk_methods.R:658:2): DESeq2 differential trancript abundance - no object
<packageNotFoundError/error/condition>
Error in `loadNamespace(x)`: there is no package called ‘DESeq2’
Backtrace:
    ▆
 1. └─base::loadNamespace(x) at test-bulk_methods.R:658:8
 2.   └─base::withRestarts(stop(cond), retry_loadNamespace = function() NULL)
 3.     └─base (local) withOneRestart(expr, restarts[[1L]])
 4.       └─base (local) doWithOneRestart(return(expr), restart)

Error (test-bulk_methods.R:854:2): test prefix
<packageNotFoundError/error/condition>
Error in `library(DESeq2)`: there is no package called ‘DESeq2’
Backtrace:
    ▆
 1. └─base::library(DESeq2) at test-bulk_methods.R:854:8

[ FAIL 2 | WARN 42 | SKIP 2 | PASS 203 ]
stemangiola commented 1 year ago

Why could it be. Maybe there is some object in /data directory which is carrying the DESeq2 class.

chilampoon commented 1 year ago

that error is just because i haven't installed DESeq2 and Suggests in DESCRIPTION won't install the package automatically during the installation of tidybulk.

usually I'd add a few lines to detect uninstalled CRAN packages in tests/vignette, e.g.

list.pkg <- c("stringr", "DESeq2")
new.pkg <- list.pkg[!(list.pkg %in% installed.packages()[ ,"Package"])]
if (length(new.pkg)) {
  install.packages(new.pkg, repos = "https://cloud.r-project.org/")
}
stemangiola commented 1 year ago

The problem is that it should not care about DESeq2 until you call test_differential_abundance, in the same way, it does not care about edgeR until you call test_differential_abundance.

There must be some trace of DESeq2 somewhere. I think it is in the data/ directory. If some file in data/ directory includes DESeq2 class we should remove it.

By the way, I don't remember this error before, I m curious if for a tidybulk version, 1-month-old, we have the same problem.

chilampoon commented 1 year ago

hmm seems like in tests/testthat/test-bulk_methods.R

test_that("test prefix",{
  library(DESeq2)
  library(stringr)

here directly uses DESeq2.

In get_differential_transcript_abundance_deseq2_SE() in R/functions_SE.R there is a install step already 👍

    # Check if package is installed, otherwise install
    if (find.package("DESeq2", quiet = TRUE) %>% length %>% equals(0)) {
        message("Installing DESeq2 needed for differential transcript abundance analyses")
        if (!requireNamespace("BiocManager", quietly = TRUE))
            install.packages("BiocManager", repos = "https://cloud.r-project.org")
        BiocManager::install("DESeq2", ask = FALSE)
    }
stemangiola commented 1 year ago

I was literally writing the same thing XD

Yes, if you have few minutes would you mind try to remove that

  library(DESeq2)
  library(string)

and see if tidybulk installs without DESeq2?

chilampoon commented 1 year ago

Sure! btw is this script dev/dplyr-master-methods.R still being used? can I delete it? cz it causes some errors in checks

stemangiola commented 1 year ago

The way is to add it to .Rbuildignore

The whole dev directory should already been added to .Rbuildignore. I don't see why it complains.

chilampoon commented 1 year ago

I don't know the examples there are being tested

* checking examples ... ERROR
Running examples in ‘tidybulk-Ex.R’ failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: arrange
> ### Title: Order rows using column values
> ### Aliases: arrange arrange.tidybulk
> 
> ### ** Examples
> 
> arrange(mtcars, cyl, disp)
Error in arrange(mtcars, cyl, disp) : could not find function "arrange"
Execution halted

the error is strange as well..

stemangiola commented 1 year ago

Remember that would need to add the zzz.R script and its linked scripts as well. Because now you are not exporting anything anymore. Take example from tidySCE package.

stemangiola commented 1 year ago

OK I think I found the problem. It was a dataset in the data/ directory. I created a PR that fixes this.

stemangiola commented 1 year ago

@chilampoon I believe is done.