hasaru-k / GlimmaV2

interactive plots for differential expression analysis
GNU Lesser General Public License v3.0
25 stars 6 forks source link

Removing possibly redundant files #84

Open PeteHaitch opened 7 months ago

PeteHaitch commented 7 months ago

Following on from internal Slack discussion (https://ritchie-lab.slack.com/archives/CDMAPG81F/p1706657023484329).

I'm generating a large number (> 150) glimma MDS and MA plots for the same project. Is there a way to generate the output to avoid/remove the the redundant(?) .js/.css files in each *_files directory?

An example

library(Glimma)

dge <- readRDS(
  system.file("RNAseq123/dge.rds", package = "Glimma"))
design <- readRDS(
  system.file("RNAseq123/design.rds", package = "Glimma"))
contr.matrix <- limma::makeContrasts(
  BasalvsLP = Basal - LP,
  BasalvsML = Basal - ML,
  levels = design)

v <- limma::voom(dge, design)
vfit <- limma::lmFit(v, design)
vfit <- limma::contrasts.fit(vfit, contrasts = contr.matrix)
efit <- limma::eBayes(vfit)

gd <- file.path(tempdir(), "Glimma")
dir.create(gd)
glimmaMA(efit, dge = dge, coef = "BasalvsLP", html = file.path(gd, "BasalvsLP.html"))
#> Saving widget...
#> /var/folders/z7/48jz0mzd6ms7zdv4vhkgns_c001kx2/T//Rtmpr0zCcj/Glimma/BasalvsLP.html generated.
glimmaMA(efit, dge = dge, coef = "BasalvsML", html = file.path(gd, "BasalvsML.html"))
#> Saving widget...
#> /var/folders/z7/48jz0mzd6ms7zdv4vhkgns_c001kx2/T//Rtmpr0zCcj/Glimma/BasalvsML.html generated.
list.files(gd)
#> [1] "BasalvsLP_files" "BasalvsLP.html"  "BasalvsML_files" "BasalvsML.html"

Here, is there a way so that I don't have both BasalvsLP_files and BasalvsML_files in the output directory? But rather they share these files (since i think they're the same?)?

Shian explained to me that these are standalone HTML files and therefore, if I understand properly, I can safely delete the *_files directories and the .html files still work because they are self-contained. My testing seems to show this works fine.

Could this be improved for the user so that these seemingly redundant/unrequired files aren't retained?

Shians commented 7 months ago

Related issue: https://github.com/ramnathv/htmlwidgets/issues/296

It sounds like a problem with htmlwidgets not cleaning up properly when working directories are shifted around (by the knitting process?). We could add a check for the redundant directory and delete it if it's present, though we will need to remember to change this if we ever allow a non-standalone figure to be saved.