-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This significantly speeds up conda installation since no R packages create dependencies. It further solved some issues with R packages being located in the global conda pkg folder.
- Loading branch information
Marius Wöste
committed
Nov 15, 2019
1 parent
550e661
commit 1a89a51
Showing
5 changed files
with
106 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
if (exists("snakemake")) { | ||
logFile <- file(snakemake@log[[1]]) | ||
|
||
sink(logFile, append = TRUE) | ||
sink(logFile, append = TRUE, type = "message") | ||
} | ||
|
||
|
||
options(repos = c(CRAN = "https://cran.rstudio.com")) | ||
|
||
ensurePackageInstallation <- function (packageName, type = "CRAN") { | ||
|
||
isPackageInstalled <- packageName %in% rownames(installed.packages()) | ||
|
||
if (!isPackageInstalled) { | ||
|
||
if (type == "CRAN") { | ||
|
||
install.packages(packageName, quiet = TRUE) | ||
|
||
} else if (type == "bioc") { | ||
|
||
if (!requireNamespace("BiocManager", quietly = TRUE)) | ||
install.packages("BiocManager") | ||
BiocManager::install(packageName) | ||
|
||
} | ||
|
||
} | ||
|
||
} | ||
|
||
loadOrInstall <- function (packageName, type = "CRAN") { | ||
|
||
ensurePackageInstallation(packageName, type) | ||
|
||
library(packageName, character.only = TRUE) | ||
} | ||
|
||
# install dependencies | ||
|
||
cranPackages <- c( | ||
"data.table", | ||
"KernSmooth", | ||
"parallel", | ||
"ggplot2", | ||
"stringr" | ||
) | ||
|
||
biocPackages <- c( | ||
"BSgenome", | ||
"bsseq", | ||
"GenomicRanges", | ||
"MethylSeekR", | ||
"rtracklayer" | ||
) | ||
|
||
for (package in cranPackages) { | ||
loadOrInstall(package) | ||
} | ||
|
||
for (package in biocPackages) { | ||
loadOrInstall(package, type = "bioc") | ||
} | ||
|
||
# prepare shiny app | ||
ensurePackageInstallation("shiny") | ||
|
||
writeLines(capture.output(sessionInfo()), snakemake@output$r_session_info) |