csoneson / alevinQC

Create QC and summary reports for Alevin output
https://csoneson.github.io/alevinQC/
Other
30 stars 6 forks source link

outputDir problem and fix #3

Closed cansavvy closed 5 years ago

cansavvy commented 5 years ago

Problem Encountered:

For alevinQCReport the outputDir argument is not working. If all arguments are kept the same, but outputDir is used, things don't work.

Example of problem:

# A directory with Alevin results
alevin.dir <- "pbmc_data/alevin_output/pbmc_1k_v2_S1_L001"

# Create results directory if it doesn't exist
if (!dir.exists("results")) {
dir.create("results")
}
# This doesn't work
alevinQCReport(alevin.dir,
                            sampleId = basename(alevin.dir), 
                            outputFile = paste0(basename(alevin.file), 
                                                             "_qc_report.html"), 
                            outputFormat = "html_document",
                            outputDir = "results",
                            forceOverwrite = TRUE)

When the above is run, this is the output Note that all these files do actually exist.

Reading Alevin output files...
Quitting from lines 31-34 (pbmc_1k_v2_S1_L001_qc_report.Rmd) 
Error in checkAlevinInputFiles(baseDir) : 
The following required file(s) are missing:
pbmc_data/alevin_output/pbmc_1k_v2_S1_L001/alevin/raw_cb_frequency.txt
pbmc_data/alevin_output/pbmc_1k_v2_S1_L001/alevin/filtered_cb_frequency.txt
pbmc_data/alevin_output/pbmc_1k_v2_S1_L001/alevin/featureDump.txt
pbmc_data/alevin_output/pbmc_1k_v2_S1_L001/alevin/MappedUmi.txt
pbmc_data/alevin_output/pbmc_1k_v2_S1_L001/alevin/whitelist.txt
pbmc_data/alevin_output/pbmc_1k_v2_S1_L001/alevin/quants_mat_rows.txt
pbmc_data/alevin_output/pbmc_1k_v2_S1_L001/alevin/quants_mat_cols.txt
pbmc_data/alevin_output/pbmc_1k_v2_S1_L001/alevin/quants_mat.gz
pbmc_data/alevin_output/pbmc_1k_v2_S1_L001/aux_info/meta_info.json
pbmc_data/alevin_output/pbmc_1k_v2_S1_L001/cmd_info.json

And, if I get rid of the outputDir function, while keeping all the other arguments the same, everything works just fine. This chunk below runs just fine.

# This works
alevinQCReport(alevin.dir,
                            sampleId = basename(alevin.dir), 
                            outputFile = paste0(basename(alevin.file), 
                                                             "_qc_report.html"), 
                            outputFormat = "html_document",
                            forceOverwrite = TRUE)

Solution:

To fix this, I added outputDirto the arguments to be passed to do.call(render, args = args) Making this change has things work for me, however, you may want to check that this doesn't disrupt anything else.

csoneson commented 5 years ago

Thanks for reporting! I think the problem is that the path to your alevin directory is relative to the current working directory, but since the output directory is different, that relative path will not be recognized from there when the Rmd is compiled. Since the default value of the output directory is the current directory, the problem is not triggered if the output directory is not specified.

I have pushed a change that normalizes the provided path to the alevin directory. Could you please try if this works for you? Thanks!

cansavvy commented 5 years ago

Cool beans. Looks like your fix worked. Thanks for the help and for making this package!