From a710e607b7a7f77787e88684fd9bc68e1e5d73c5 Mon Sep 17 00:00:00 2001 From: brucemoran Date: Tue, 24 Nov 2020 08:56:28 +0000 Subject: [PATCH] Recursive dir.create --- NAMESPACE | 2 +- R/DESeq2_module.R | 2 +- R/edgeR_module.R | 2 +- R/fgsea.R | 2 +- R/limma_module.R | 2 +- R/post_module_joins.R | 2 +- R/prep_RNAseq_output.R | 4 ++-- R/wrapper_scripts.R | 6 +++--- man/{get_tx2gen.Rd => get_tx2gene.Rd} | 6 +++--- 9 files changed, 14 insertions(+), 14 deletions(-) rename man/{get_tx2gen.Rd => get_tx2gene.Rd} (87%) diff --git a/NAMESPACE b/NAMESPACE index 4e3b87b..ea079d0 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -10,7 +10,7 @@ export(found_in_three) export(found_in_two) export(genesGTF) export(get_metadata) -export(get_tx2gen) +export(get_tx2gene) export(limma_module) export(master_parse_join) export(nf_core_rnaseq_featco_parser) diff --git a/R/DESeq2_module.R b/R/DESeq2_module.R index fb50426..d5dcae3 100644 --- a/R/DESeq2_module.R +++ b/R/DESeq2_module.R @@ -47,7 +47,7 @@ DESeq2_module <- function(count_data, anno_tb = NULL, tpm_tb = NULL, tag = NULL, output_dir <- "./DEseq2" } else { output_dir <- paste0(output_dir, "/DEseq2") - dir.create(output_dir, showWarnings = FALSE) + dir.create(output_dir, recursive = TRUE, showWarnings = FALSE) } ##read in condition data diff --git a/R/edgeR_module.R b/R/edgeR_module.R index ac6154f..1fbaa3d 100644 --- a/R/edgeR_module.R +++ b/R/edgeR_module.R @@ -42,7 +42,7 @@ edgeR_module <- function(count_data, anno_tb = NULL, tpm_tb = NULL, tag = NULL, output_dir <- "./edgeR" } else { output_dir <- paste0(output_dir, "/edgeR") - dir.create(output_dir, showWarnings = FALSE) + dir.create(output_dir, recursive = TRUE, showWarnings = FALSE) } ##read in condition data diff --git a/R/fgsea.R b/R/fgsea.R index a6e8bad..b6b98c8 100644 --- a/R/fgsea.R +++ b/R/fgsea.R @@ -97,7 +97,7 @@ fgsea_plot <- function(res, sig_res = NULL, msigdb_species = "Homo sapiens", msi ##plotting out_dir <- paste0(output_dir, "/fgsea") - dir.create(out_dir, showWarnings = FALSE) + dir.create(out_dir, recursive = TRUE, showWarnings = FALSE) gg_fgsea <- ggplot2::ggplot(fgsea_res_sig_tb, ggplot2::aes(reorder(pathway, NES), NES)) + ggplot2::geom_col(ggplot2::aes(fill = padj)) + ggplot2::coord_flip() + diff --git a/R/limma_module.R b/R/limma_module.R index 6613087..7e6d72f 100644 --- a/R/limma_module.R +++ b/R/limma_module.R @@ -40,7 +40,7 @@ limma_module <- function(count_data, anno_tb = NULL, tpm_tb = NULL, tag = NULL, output_dir <- "./limma" } else { output_dir <- paste0(output_dir, "/limma") - dir.create(output_dir, showWarnings = FALSE) + dir.create(output_dir, recursive = TRUE, showWarnings = FALSE) } ##read in condition data diff --git a/R/post_module_joins.R b/R/post_module_joins.R index a73db88..14cb546 100644 --- a/R/post_module_joins.R +++ b/R/post_module_joins.R @@ -168,7 +168,7 @@ venn_3 <- function(master_list, tag, output_dir, padj = 0.01){ ##compare those lists vdf <- cbind(unc, unlist(lapply(compf_list, length))) colnames(vdf) <- c(names(master_list), "Counts") - dir.create(paste0(output_dir, "/venn_3"), showWarnings = FALSE) + dir.create(paste0(output_dir, "/venn_3"), recursive = TRUE, showWarnings = FALSE) readr::write_csv(as.data.frame(vdf), path = paste0(output_dir, "/venn_3/", tag, ".", contrast, ".venn_3.csv")) ##write venn diff --git a/R/prep_RNAseq_output.R b/R/prep_RNAseq_output.R index 5414d51..5bdc84c 100644 --- a/R/prep_RNAseq_output.R +++ b/R/prep_RNAseq_output.R @@ -69,7 +69,7 @@ brucemoran_rnaseq_kallisto_parser <- function(metadata_csv, data_dir = NULL, agg ##annotation to use print("Getting tx2gene object") - tx2gene <- get_tx2gen(genome_prefix) + tx2gene <- RNAseqR::get_tx2gene(genome_prefix) if(genome_prefix != "hsapiens"){ tx2gene1 <- tx2gene @@ -99,7 +99,7 @@ brucemoran_rnaseq_kallisto_parser <- function(metadata_csv, data_dir = NULL, agg #' @return tx2gene format for sleuth_prep() in get_abundance_tsv() #' @export -get_tx2gen <- function(genome_prefix){ +get_tx2gene <- function(genome_prefix){ datasets <- biomaRt::listDatasets(biomaRt::useMart("ensembl")) datasetm <- paste0(genome_prefix, "_gene_ensembl") diff --git a/R/wrapper_scripts.R b/R/wrapper_scripts.R index fd8bd95..8ef129b 100644 --- a/R/wrapper_scripts.R +++ b/R/wrapper_scripts.R @@ -26,7 +26,7 @@ run_prep_modules_bm <- function(metadata_csv, metadata_design, tag, output_dir = ##create an output called RNAseqR in current dir if no output_dir defined if(is.null(output_dir)){ output_dir <- paste0(getwd(), "/", tag, "/RNAseqR") - dir.create(output_dir, showWarnings = FALSE) + dir.create(output_dir, recursive = TRUE, showWarnings = FALSE) } ##prepare data and save @@ -39,7 +39,7 @@ run_prep_modules_bm <- function(metadata_csv, metadata_design, tag, output_dir = tpm_tb <- tpm_tb <- sot[[1]]$obs_raw_tpm$wide anno_tb <- tibble::as_tibble(sot[[2]]) outdir <- paste0(output_dir, "/inputs") - dir.create(outdir, showWarnings = FALSE) + dir.create(outdir, recursive = TRUE, showWarnings = FALSE) save(count_data, tpm_tb, anno_tb, file = paste0(outdir, "/", tag, ".count_tpm_anno.RData")) ##run modules @@ -95,5 +95,5 @@ run_prep_modules_bm <- function(metadata_csv, metadata_design, tag, output_dir = }) save(master_list, fitwo_list, fithree, fgsea_list, - paste0(outdir, "/", tag, ".full_results.RData") + paste0(outdir, "/", tag, ".full_results.RData")) } diff --git a/man/get_tx2gen.Rd b/man/get_tx2gene.Rd similarity index 87% rename from man/get_tx2gen.Rd rename to man/get_tx2gene.Rd index 72db5c2..70e6e5d 100644 --- a/man/get_tx2gen.Rd +++ b/man/get_tx2gene.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/prep_RNAseq_output.R -\name{get_tx2gen} -\alias{get_tx2gen} +\name{get_tx2gene} +\alias{get_tx2gene} \title{Get annotation in tx2gene format; returns hsapiens_homolog when non-hsapiens input} \usage{ -get_tx2gen(genome_prefix) +get_tx2gene(genome_prefix) } \arguments{ \item{genome_prefix}{string of a genome in biomart$dataset, suffixed with '_gene_ensembl'}