From a29d73e4118382dab3e6d914c360cd7961ae58e7 Mon Sep 17 00:00:00 2001 From: Lorena Pantano Date: Thu, 18 Apr 2024 16:21:18 -0400 Subject: [PATCH] import-export accesory files --- DESCRIPTION | 2 ++ NAMESPACE | 2 ++ R/bcbioR-package.R | 7 +++++++ R/hello.R | 18 +++++++++++++++++- README.Rmd | 2 ++ README.md | 3 +++ .../templates/rnaseq/skeleton/README.md | 6 +++++- .../rnaseq/skeleton/reports/DEG/run_markdown.R | 18 ++++++++++++++++++ 8 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 R/bcbioR-package.R create mode 100644 inst/rmarkdown/templates/rnaseq/skeleton/reports/DEG/run_markdown.R diff --git a/DESCRIPTION b/DESCRIPTION index aec3cae..17cb675 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -10,3 +10,5 @@ LazyData: true Encoding: UTF-8 Roxygen: list(markdown = TRUE) RoxygenNote: 7.3.1 +Imports: + stringr diff --git a/NAMESPACE b/NAMESPACE index 5a75104..193fed0 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,4 +1,6 @@ # Generated by roxygen2: do not edit by hand +export(bcbio_gitignore) export(bcbio_set_project) export(bcbio_start_project) +importFrom(stringr,str_replace_all) diff --git a/R/bcbioR-package.R b/R/bcbioR-package.R new file mode 100644 index 0000000..7fb162e --- /dev/null +++ b/R/bcbioR-package.R @@ -0,0 +1,7 @@ +#' @keywords internal +"_PACKAGE" + +## usethis namespace: start +#' @importFrom stringr str_replace_all +## usethis namespace: end +NULL diff --git a/R/hello.R b/R/hello.R index e27efda..e148037 100644 --- a/R/hello.R +++ b/R/hello.R @@ -13,13 +13,23 @@ # Check Package: 'Cmd + Shift + E' # Test Package: 'Cmd + Shift + T' +.fix <- function(x){ + x <- tolower(x) %>% str_replace_all(x, "[[:punct:]]", " ") + retunr(x) +} + #' @export bcbio_set_project <- function() { hbc_code <- readline("What is the hbc code:\n") + pi <- readline("What is PI last name:\n") + technology <- readline("What is the technology:\n") + tissue <- readline("What is the tissue:\n") + org <- readline("What is the organism:\n") project <- readline("What is the project name:\n") dropbox <- readline("What is the dropbox name:\n") github_org <- readline("What is the github organization:\n") - project_full <- paste0(project, "_", hbc_code) + #hbc_$technology_of_$pilastname_$intervention_on_$tissue_in_$organism_$hbccode + project_full <- paste(project, technology, fix(pi), project, tissue, organism, hbc_code, sep="_") github <- c(github_org,project_full) opts <- list(code=hbc_code, project=project_full, dropbox=file.path(dropbox,project_full), @@ -33,6 +43,12 @@ bcbio_start_project <- function(options) { } +#' @export +bcbio_gitignore <- function(options) { + +} + + hello <- function() { print("Hello, world!") diff --git a/README.Rmd b/README.Rmd index 9192244..fbdc880 100644 --- a/README.Rmd +++ b/README.Rmd @@ -31,4 +31,6 @@ library(bcbioR) You'll still need to render `README.Rmd` regularly, to keep `README.md` up-to-date. `devtools::build_readme()` is handy for this. +Use `usethis::use_import_from()` to make sure all the imports are correct. + Don't forget to commit and push the resulting figure files, so they display on GitHub and CRAN. diff --git a/README.md b/README.md index 17d2f1e..ea6ea41 100644 --- a/README.md +++ b/README.md @@ -32,5 +32,8 @@ library(bcbioR) You’ll still need to render `README.Rmd` regularly, to keep `README.md` up-to-date. `devtools::build_readme()` is handy for this. +Use `usethis::use_import_from()` to make sure all the imports are +correct. + Don’t forget to commit and push the resulting figure files, so they display on GitHub and CRAN. diff --git a/inst/rmarkdown/templates/rnaseq/skeleton/README.md b/inst/rmarkdown/templates/rnaseq/skeleton/README.md index 0e4c4ef..30016c5 100644 --- a/inst/rmarkdown/templates/rnaseq/skeleton/README.md +++ b/inst/rmarkdown/templates/rnaseq/skeleton/README.md @@ -3,7 +3,11 @@ [ ] Replace Title in this file matching title projects [ ] run function`bcbio_set_project()` to set up information for this project - hbcxxxx code + - technology + - tissue + - organism - pi - - project name to be used in storage/github/dropbox + - project name [ ] run function `bcbio_set_git()` to set up git repository [ ] run function `bcbio_copy_dropbox()` to copy files to dropbox location + diff --git a/inst/rmarkdown/templates/rnaseq/skeleton/reports/DEG/run_markdown.R b/inst/rmarkdown/templates/rnaseq/skeleton/reports/DEG/run_markdown.R new file mode 100644 index 0000000..4902560 --- /dev/null +++ b/inst/rmarkdown/templates/rnaseq/skeleton/reports/DEG/run_markdown.R @@ -0,0 +1,18 @@ +library(rmarkdown) + +render_de <- function(subset_value, numerator, denominator){ + rmarkdown::render(input = "DEG.Rmd", + output_dir = "reports", + output_format = "html_document", + output_file = paste0('DE_', subset_value, '_', numerator, '_vs_', denominator, '.html'), + clean = TRUE, + envir = new.env(), + params = list( + subset_value = subset_value, + numerator = numerator, + denominator = denominator + ) + ) +} + +render_de('HDFn', "TNF", "untreated")