diff --git a/NAMESPACE b/NAMESPACE index fe4c23d6..c448ff13 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -11,18 +11,19 @@ export(addLeaves2Alignment) export(addLineage) export(addName) export(addTaxID) -export(advanced_opts2est_walltime) export(alignFasta) -export(assign_job_queue) +export(assignJobQueue) +export(calculateEstimatedWallTimeFromOpts) +export(calculateProcessRuntime) export(cleanClusters) export(cleanDomainArchitecture) export(cleanGeneDescription) export(cleanGenomicContext) export(cleanLineage) export(cleanSpecies) -export(combine_files) -export(combine_full) -export(combine_ipr) +export(combineFiles) +export(combineFullAnalysis) +export(combineIPR) export(condenseRepeatedDomains) export(convert2TitleCase) export(convertAlignment2FA) @@ -32,10 +33,10 @@ export(countByColumn) export(createFA2Tree) export(createJobResultsURL) export(createJobStatusEmailMessage) +export(createLineageLookup) export(createRepresentativeAccNum) export(createWordCloud2Element) export(createWordCloudElement) -export(create_lineage_lookup) export(domain_network) export(downloadAssemblySummary) export(efetchIPG) @@ -48,13 +49,13 @@ export(gc_undirected_network) export(generateAllAlignments2FA) export(generate_msa) export(getAccNumFromFA) +export(getProcessRuntimeWeights) export(getTopAccByLinDomArch) -export(get_proc_medians) -export(get_proc_weights) -export(make_opts2procs) export(mapAcc2Name) -export(map_advanced_opts2procs) +export(mapAdvOption2Process) +export(mapOption2Process) export(msa_pdf) +export(plotEstimatedWallTimes) export(plotIPR2Viz) export(plotIPR2VizWeb) export(plotLineageDA) @@ -67,7 +68,6 @@ export(plotStackedLineage) export(plotSunburst) export(plotTreemap) export(plotUpSet) -export(plot_estimated_walltimes) export(prepareColumnParams) export(prepareSingleColumnParams) export(proteinAcc2TaxID) @@ -97,8 +97,8 @@ export(totalGenContextOrDomArchCounts) export(validateCountDF) export(wordcloud3) export(writeMSA_AA2FA) -export(write_proc_medians_table) -export(write_proc_medians_yml) +export(writeProcessRuntime2TSV) +export(writeProcessRuntime2YML) importFrom(Biostrings,AAStringSet) importFrom(Biostrings,readAAStringSet) importFrom(Biostrings,toString) diff --git a/R/acc2lin.R b/R/acc2lin.R index bf6fec54..5f25afe2 100644 --- a/R/acc2lin.R +++ b/R/acc2lin.R @@ -10,6 +10,7 @@ #' Sink Reset #' #' @return No return, but run to close all outstanding `sink()`s +#' #' @export #' #' @examples @@ -18,7 +19,7 @@ #' } sinkReset <- function() { for (i in seq_len(sink.number())) { - sink(NULL) + sink(NULL) } } @@ -56,18 +57,20 @@ addLineage <- function(df, acc_col = "AccNum", assembly_path, accessions <- df %>% pull(acc_col) lins <- acc2Lineage(accessions, assembly_path, lineagelookup_path, ipgout_path, plan) - # Drop a lot of the unimportant columns for now? will make merging much easier - lins <- lins[, c( + # Drop a lot of the unimportant columns for now? + # will make merging much easier + lins <- lins[, c( "Strand", "Start", "Stop", "Nucleotide Accession", "Source", "Id", "Strain" - ) := NULL] - lins <- unique(lins) + ) := NULL] + lins <- unique(lins) - # dup <- lins %>% group_by(Protein) %>% summarize(count = n()) %>% filter(count > 1) %>% - # pull(Protein) + # dup <- lins %>% group_by(Protein) %>% + # summarize(count = n()) %>% filter(count > 1) %>% + # pull(Protein) - merged <- merge(df, lins, by.x = acc_col, by.y = "Protein", all.x = TRUE) - return(merged) + merged <- merge(df, lins, by.x = acc_col, by.y = "Protein", all.x = TRUE) + return(merged) } @@ -107,10 +110,10 @@ acc2Lineage <- function(accessions, assembly_path, lineagelookup_path, ipgout_pa lins <- IPG2Lineage(accessions, ipgout_path, assembly_path, lineagelookup_path) - if (tmp_ipg) { - unlink(tempdir(), recursive = T) - } - return(lins) + if (tmp_ipg) { + unlink(tempdir(), recursive = T) + } + return(lins) } #' efetchIPG @@ -118,7 +121,6 @@ acc2Lineage <- function(accessions, assembly_path, lineagelookup_path, ipgout_pa #' @author Samuel Chen, Janani Ravi #' #' @description Perform efetch on the ipg database and write the results to out_path -#' #' @param accnums Character vector containing the accession numbers to query on #' the ipg database #' @param out_path Path to write the efetch results to @@ -144,46 +146,52 @@ efetchIPG <- function(accnums, out_path, plan = "sequential", ...) { # limit of 10/second w/ key l <- length(in_data) - partitioned <- list() - for (i in 1:groups) - { - partitioned[[i]] <- in_data[seq.int(i, l, groups)] - } - - return(partitioned) - } - - plan(strategy = plan, .skip = T) - - - min_groups <- length(accnums) / 200 - groups <- min(max(min_groups, 15), length(accnums)) - partitioned_acc <- partition(accnums, groups) - sink(out_path) - - a <- future_map(1:length(partitioned_acc), function(x) { - # Avoid hitting the rate API limit - if (x %% 9 == 0) { - Sys.sleep(1) - } - cat( - entrez_fetch( - id = partitioned_acc[[x]], - db = "ipg", - rettype = "xml", - api_key = "YOUR_KEY_HERE" ## Can this be included in public package? - ) - ) - }) - sink(NULL) + partitioned <- list() + for (i in 1:groups){ + partitioned[[i]] <- in_data[seq.int(i, l, groups)] + } + + return(partitioned) } + + # Set the future plan strategy + plan(strategy = plan, .skip = T) + + + min_groups <- length(accnums) / 200 + groups <- min(max(min_groups, 15), length(accnums)) + partitioned_acc <- partition(accnums, groups) + + # Open the sink to the output path + sink(out_path) + + a <- future_map(1:length(partitioned_acc), function(x) { + # Avoid hitting the rate API limit + if (x %% 9 == 0) { + Sys.sleep(1) + } + cat( + entrez_fetch( + id = partitioned_acc[[x]], + db = "ipg", + rettype = "xml", + api_key = "YOUR_KEY_HERE" ## Can this be included in public package? + ) + ) + }) + sink(NULL) + + } } + + #' IPG2Lineage #' #' @author Samuel Chen, Janani Ravi #' -#' @description Takes the resulting file of an efetch run on the ipg database and +#' @description Takes the resulting file +#' of an efetch run on the ipg database and #' #' @param accessions Character vector of protein accessions #' @param ipg_file Filepath to the file containing results of an efetch run on the @@ -193,7 +201,7 @@ efetchIPG <- function(accnums, out_path, plan = "sequential", ...) { #' This file can be generated using the \link[MolEvolvR]{downloadAssemblySummary} function #' @param lineagelookup_path String of the path to the lineage lookup file #' (taxid to lineage mapping). This file can be generated using the -#' "create_lineage_lookup()" function +#' "createLineageLookup()" function #' #' @importFrom data.table fread #' @@ -209,8 +217,10 @@ efetchIPG <- function(accnums, out_path, plan = "sequential", ...) { IPG2Lineage <- function(accessions, ipg_file, assembly_path, lineagelookup_path, ...) { ipg_dt <- fread(ipg_file, sep = "\t", fill = T) + # Filter the IPG data table to only include the accessions ipg_dt <- ipg_dt[Protein %in% accessions] + # Rename the 'Assembly' column to 'GCA_ID' ipg_dt <- setnames(ipg_dt, "Assembly", "GCA_ID") lins <- GCA2Lineage(prot_data = ipg_dt, assembly_path, lineagelookup_path) diff --git a/R/assign_job_queue.R b/R/assign_job_queue.R index bc5253d4..69609417 100644 --- a/R/assign_job_queue.R +++ b/R/assign_job_queue.R @@ -3,24 +3,31 @@ # pipeline. # to use this, construct paths like so: file.path(common_root, "path", "to", "file.R") # for example, the reference for this file would be: -# file.path(common_root, "molevol_scripts", "R", "assign_job_queue.R") +# file.path(common_root, "molevol_scripts", "R", "assignJobQueue.R") common_root <- Sys.getenv("COMMON_SRC_ROOT") +#' mapOption2Process +#' +#' @description #' Construct list where names (MolEvolvR advanced options) point to processes #' #' @return list where names (MolEvolvR advanced options) point to processes #' -#' example: list_opts2procs <- make_opts2procs +#' example: list_opts2procs <- mapOption2Process #' @export -make_opts2procs <- function() { - opts2processes <- list( - "homology_search" = c("dblast", "dblast_cleanup"), - "domain_architecture" = c("iprscan", "ipr2lineage", "ipr2da"), - "always" = c("blast_clust", "clust2table") # processes always present agnostic of advanced options - ) - return(opts2processes) +mapOption2Process <- function() { + opts2processes <- list( + "homology_search" = c("dblast", "dblast_cleanup"), + "domain_architecture" = c("iprscan", "ipr2lineage", "ipr2da"), + # processes always present agnostic of advanced options + "always" = c("blast_clust", "clust2table") + ) + return(opts2processes) } +#' mapAdvOption2Process +#' +#' @description #' Use MolEvolvR advanced options to get associated processes #' #' @param advanced_opts character vector of MolEvolvR advanced options @@ -30,19 +37,22 @@ make_opts2procs <- function() { #' #' example: #' advanced_opts <- c("homology_search", "domain_architecture") -#' procs <- map_advanced_opts2procs(advanced_opts) +#' procs <- mapAdvOption2Process(advanced_opts) #' @export -map_advanced_opts2procs <- function(advanced_opts) { - # append 'always' to add procs that always run - advanced_opts <- c(advanced_opts, "always") - opts2proc <- make_opts2procs() - # setup index for opts2proc based on advanced options - idx <- which(names(opts2proc) %in% advanced_opts) - # extract processes that will run - procs <- opts2proc[idx] |> unlist() - return(procs) +mapAdvOption2Process <- function(advanced_opts) { + # append 'always' to add procs that always run + advanced_opts <- c(advanced_opts, "always") + opts2proc <- mapOption2Process() + # setup index for opts2proc based on advanced options + idx <- which(names(opts2proc) %in% advanced_opts) + # extract processes that will run + procs <- opts2proc[idx] |> unlist() + return(procs) } +#' calculateProcessRuntime +#' +#' @description #' Scrape MolEvolvR logs and calculate median processes #' #' @param dir_job_results [chr] path to MolEvolvR job_results @@ -58,49 +68,54 @@ map_advanced_opts2procs <- function(advanced_opts) { #' #' 1) #' dir_job_results <- "/data/scratch/janani/molevolvr_out" -#' list_proc_medians <- get_proc_medians(dir_job_results) +#' list_proc_medians <- calculateProcessRuntime(dir_job_results) #' #' 2) from outside container environment #' common_root <- "/data/molevolvr_transfer/molevolvr_dev" #' dir_job_results <- "/data/molevolvr_transfer/molevolvr_dev/job_results" -#' list_proc_medians <- get_proc_medians(dir_job_results) +#' list_proc_medians <- calculateProcessRuntime(dir_job_results) #' @export -get_proc_medians <- function(dir_job_results) { - source(file.path(common_root, "molevol_scripts", "R", "metrics.R")) +calculateProcessRuntime <- function(dir_job_results) { + source(file.path(common_root, "molevol_scripts", "R", "metrics.R")) - # aggregate logs from - path_log_data <- file.path(common_root, "molevol_scripts", "log_data", "prod_logs.rda") + # aggregate logs from + path_log_data <- file.path(common_root, + "molevol_scripts", "log_data", "prod_logs.rda") - # ensure the folder exists to the location - if (!dir.exists(path_log_data)) { - dir.create(dirname(path_log_data), recursive = TRUE, showWarnings = FALSE) - } + # ensure the folder exists to the location + if (!dir.exists(path_log_data)) { + dir.create(dirname(path_log_data), + recursive = TRUE, showWarnings = FALSE) + } - # attempt to load pre-generated logdata - if (!file.exists(path_log_data)) { - logs <- aggregate_logs(dir_job_results, latest_date = Sys.Date() - 60) - save(logs, file = path_log_data) - } else { - load(path_log_data) # loads the logs object - } - df_log <- logs$df_log - procs <- c( - "dblast", "dblast_cleanup", "iprscan", - "ipr2lineage", "ipr2da", "blast_clust", - "clust2table" - ) - list_proc_medians <- df_log |> - dplyr::select(dplyr::all_of(procs)) |> - dplyr::summarise( - dplyr::across( - dplyr::everything(), - \(x) median(x, na.rm = TRUE) - ) - ) |> - as.list() - return(list_proc_medians) + # attempt to load pre-generated logdata + if (!file.exists(path_log_data)) { + logs <- aggregate_logs(dir_job_results, latest_date = Sys.Date() - 60) + save(logs, file = path_log_data) + } else { + load(path_log_data) # loads the logs object + } + df_log <- logs$df_log + procs <- c( + "dblast", "dblast_cleanup", "iprscan", + "ipr2lineage", "ipr2da", "blast_clust", + "clust2table" + ) + list_proc_medians <- df_log |> + dplyr::select(dplyr::all_of(procs)) |> + dplyr::summarise( + dplyr::across( + dplyr::everything(), + \(x) median(x, na.rm = TRUE) + ) + ) |> + as.list() + return(list_proc_medians) } +#' writeProcessRuntime2TSV +#' +#' @description #' Write a table of 2 columns: 1) process and 2) median seconds #' #' @param dir_job_results [chr] path to MolEvolvR job_results @@ -113,53 +128,61 @@ get_proc_medians <- function(dir_job_results) { #' #' @return [tbl_df] 2 columns: 1) process and 2) median seconds #' -#' example: write_proc_medians_table( +#' example: writeProcessRuntime2TSV( #' "/data/scratch/janani/molevolvr_out/", #' "/data/scratch/janani/molevolvr_out/log_tbl.tsv" #' ) #' @export -write_proc_medians_table <- function(dir_job_results, filepath) { - df_proc_medians <- get_proc_medians(dir_job_results) |> - tibble::as_tibble() |> - tidyr::pivot_longer( - dplyr::everything(), - names_to = "process", - values_to = "median_seconds" - ) |> - dplyr::arrange(dplyr::desc(median_seconds)) - readr::write_tsv(df_proc_medians, file = filepath) - return(df_proc_medians) +writeProcessRuntime2TSV <- function(dir_job_results, filepath) { + df_proc_medians <- calculateProcessRuntime(dir_job_results) |> + tibble::as_tibble() |> + tidyr::pivot_longer( + dplyr::everything(), + names_to = "process", + values_to = "median_seconds" + ) |> + dplyr::arrange(dplyr::desc(median_seconds)) + + # Write the resulting tibble to a TSV file + readr::write_tsv(df_proc_medians, file = filepath) + return(df_proc_medians) } +#' writeProcessRuntime2YML +#' +#' @description #' Compute median process runtimes, then write a YAML list of the processes and #' their median runtimes in seconds to the path specified by 'filepath'. #' #' The default value of filepath is the value of the env var -#' MOLEVOLVR_PROC_WEIGHTS, which get_proc_weights() also uses as its default +#' MOLEVOLVR_PROC_WEIGHTS, which getProcessRuntimeWeights() also uses as its default #' read location. #' #' @param dir_job_results [chr] path to MolEvolvR job_results directory -#' @param filepath [chr] path to save YAML file; if NULL, uses ./molevol_scripts/log_data/job_proc_weights.yml +#' @param filepath [chr] path to save YAML file; if NULL, +#' uses ./molevol_scripts/log_data/job_proc_weights.yml #' #' @importFrom yaml write_yaml #' #' @examples #' \dontrun{ -#' write_proc_medians_yml( +#' writeProcessRuntime2YML( #' "/data/scratch/janani/molevolvr_out/", #' "/data/scratch/janani/molevolvr_out/log_tbl.yml" #' ) #' } #' @export -write_proc_medians_yml <- function(dir_job_results, filepath = NULL) { - if (is.null(filepath)) { - filepath <- file.path(common_root, "molevol_scripts", "log_data", "job_proc_weights.yml") - } - - medians <- get_proc_medians(dir_job_results) - yaml::write_yaml(medians, filepath) +writeProcessRuntime2YML <- function(dir_job_results, filepath = NULL) { + if (is.null(filepath)) { + filepath <- file.path(common_root, "molevol_scripts", "log_data", "job_proc_weights.yml") + } + medians <- calculateProcessRuntime(dir_job_results) + yaml::write_yaml(medians, filepath) } +#' getProcessRuntimeWeights +#' +#' @description #' Quickly get the runtime weights for MolEvolvR backend processes #' #' @param dir_job_results [chr] path to MolEvolvR job_results @@ -170,50 +193,55 @@ write_proc_medians_yml <- function(dir_job_results, filepath = NULL) { #' #' @return [list] names: processes; values: median runtime (seconds) #' -#' example: get_proc_weights() +#' example: writeProcessRuntime2YML() #' @export -get_proc_weights <- function(medians_yml_path = NULL) { - if (is.null(medians_yml_path)) { - medians_yml_path <- file.path(common_root, "molevol_scripts", "log_data", "job_proc_weights.yml") - } +getProcessRuntimeWeights <- function(medians_yml_path = NULL) { + if (is.null(medians_yml_path)) { + medians_yml_path <- file.path(common_root, + "molevol_scripts", + "log_data", + "job_proc_weights.yml") + } - proc_weights <- tryCatch( - { - # attempt to read the weights from the YAML file produced by - # write_proc_medians_yml() - if (stringr::str_trim(medians_yml_path) == "") { - stop( - stringr::str_glue("medians_yml_path is empty ({medians_yml_path}), returning default weights") - ) - } + proc_weights <- tryCatch({ + # attempt to read the weights from the YAML file produced by + # writeProcessRuntime2YML() + if (stringr::str_trim(medians_yml_path) == "") { + stop( + stringr::str_glue("medians_yml_path is empty + ({medians_yml_path}), returning default weights") + ) + } - proc_weights <- yaml::read_yaml(medians_yml_path) - }, - # to avoid fatal errors in reading the proc weights yaml, - # some median process runtimes have been hardcoded based on - # the result of get_proc_medians() from Jan 2024 - error = function(cond) { - proc_weights <- list( - "dblast" = 2810, - "iprscan" = 1016, - "dblast_cleanup" = 79, - "ipr2lineage" = 18, - "ipr2da" = 12, - "blast_clust" = 2, - "clust2table" = 2 - ) - proc_weights - } + proc_weights <- yaml::read_yaml(medians_yml_path) + }, + # to avoid fatal errors in reading the proc weights yaml, + # some median process runtimes have been hardcoded based on + # the result of calculateProcessRuntime() from Jan 2024 + error = function(cond) { + proc_weights <- list( + "dblast" = 2810, + "iprscan" = 1016, + "dblast_cleanup" = 79, + "ipr2lineage" = 18, + "ipr2da" = 12, + "blast_clust" = 2, + "clust2table" = 2 ) + proc_weights + }) - return(proc_weights) + return(proc_weights) } +#' calculateEstimatedWallTimeFromOpts +#' +#' @description #' Given MolEvolvR advanced options and number of inputs, #' calculate the total estimated walltime for the job #' #' @param advanced_opts character vector of MolEvolvR advanced options -#' (see make_opts2procs for the options) +#' (see mapOption2Process for the options) #' @param n_inputs total number of input proteins #' #' @importFrom dplyr if_else @@ -221,70 +249,88 @@ get_proc_weights <- function(medians_yml_path = NULL) { #' #' @return total estimated number of seconds a job will process (walltime) #' -#' example: advanced_opts2est_walltime(c("homology_search", "domain_architecture"), n_inputs = 3, n_hits = 50L) +#' example: calculateEstimatedWallTimeFromOpts (c("homology_search", +#' "domain_architecture"), +#' n_inputs = 3, n_hits = 50L) #' @export -advanced_opts2est_walltime <- function(advanced_opts, n_inputs = 1L, n_hits = NULL, verbose = FALSE) { - # to calculate est walltime for a homology search job, the number of hits - # must be provided - validation_fail <- is.null(n_hits) && "homology_search" %in% advanced_opts - stopifnot(!validation_fail) +calculateEstimatedWallTimeFromOpts <- function(advanced_opts, + n_inputs = 1L, + n_hits = NULL, + verbose = FALSE) { + # to calculate est walltime for a homology search job, the number of hits + # must be provided + validation_fail <- is.null(n_hits) && "homology_search" %in% advanced_opts + stopifnot(!validation_fail) - proc_weights <- get_proc_weights() - # sort process weights by names and convert to vec - proc_weights <- proc_weights[order(names(proc_weights))] |> unlist() - all_procs <- names(proc_weights) |> sort() - # get processes from advanced options and sort by names - procs_from_opts <- map_advanced_opts2procs(advanced_opts) - procs_from_opts <- sort(procs_from_opts) - # binary encode: yes proc will run (1); else 0 - binary_proc_vec <- dplyr::if_else(all_procs %in% procs_from_opts, 1L, 0L) - # dot product of weights and procs to run; scaled by the number of inputs - est_walltime <- (n_inputs * (binary_proc_vec %*% proc_weights)) |> - as.numeric() - # calculate the additional processes to run for the homologous hits - if ("homology_search" %in% advanced_opts) { - opts2procs <- make_opts2procs() - # exclude the homology search processes for the homologous hits - procs2exclude_for_homologs <- opts2procs[["homology_search"]] - procs_homologs <- procs_from_opts[!(procs_from_opts %in% procs2exclude_for_homologs)] - binary_proc_vec_homolog <- dplyr::if_else(all_procs %in% procs_homologs, 1L, 0L) - # add the estimated walltime for processes run on the homologous hits - est_walltime <- est_walltime + - (n_hits * (binary_proc_vec_homolog %*% proc_weights) |> as.numeric()) - } - if (verbose) { - msg <- stringr::str_glue( - "warnings from advanced_opts2est_walltime():\n", - "\tn_inputs={n_inputs}\n", - "\tn_hits={ifelse(is.null(n_hits), 'null', n_hits)}\n", - "\test_walltime={est_walltime}\n\n" - ) - cat(file = stderr(), msg) - } - return(est_walltime) + # Get process weights + proc_weights <- writeProcessRuntime2YML() + + # sort process weights by names and convert to vec + proc_weights <- proc_weights[order(names(proc_weights))] |> unlist() + all_procs <- names(proc_weights) |> sort() + # get processes from advanced options and sort by names + procs_from_opts <- mapAdvOption2Process(advanced_opts) + procs_from_opts <- sort(procs_from_opts) + # binary encode: yes proc will run (1); else 0 + binary_proc_vec <- dplyr::if_else(all_procs %in% procs_from_opts, 1L, 0L) + # dot product of weights and procs to run; scaled by the number of inputs + est_walltime <- (n_inputs * (binary_proc_vec %*% proc_weights)) |> + as.numeric() + # calculate the additional processes to run for the homologous hits + if ("homology_search" %in% advanced_opts) { + opts2procs <- mapOption2Process() + # exclude the homology search processes for the homologous hits + procs2exclude_for_homologs <- opts2procs[["homology_search"]] + procs_homologs <- procs_from_opts[!(procs_from_opts + %in% procs2exclude_for_homologs)] + binary_proc_vec_homolog <- dplyr::if_else(all_procs + %in% procs_homologs, 1L, 0L) + # add the estimated walltime for processes run on the homologous hits + est_walltime <- est_walltime + + (n_hits * (binary_proc_vec_homolog + %*% proc_weights) |> as.numeric()) + } + if (verbose) { + msg <- stringr::str_glue( + "warnings from calculateEstimatedWallTimeFromOpts ():\n", + "\tn_inputs={n_inputs}\n", + "\tn_hits={ifelse(is.null(n_hits), 'null', n_hits)}\n", + "\test_walltime={est_walltime}\n\n" + ) + cat(file = stderr(), msg) + } + return(est_walltime) } + +#' assignJobQueue +#' +#' @description #' Decision function to assign job queue #' #' @param t_sec_estimate estimated number of seconds a job will process -#' (from advanced_opts2est_walltime()) +#' (from calculateEstimatedWallTimeFromOpts ()) #' @param t_long threshold value that defines the lower bound for assigning a #' job to the "long queue" #' #' @return a string of "short" or "long" #' #' example: -#' advanced_opts2est_walltime(c("homology_search", "domain_architecture"), 3) |> -#' assign_job_queue() +#' calculateEstimatedWallTimeFromOpts (c("homology_search", +#' "domain_architecture"), 3) |> +#' assignJobQueue() #' @export -assign_job_queue <- function( - t_sec_estimate, - t_cutoff = 21600 # 6 hours - ) { - queue <- ifelse(t_sec_estimate > t_cutoff, "long", "short") - return(queue) +assignJobQueue <- function( + t_sec_estimate, + t_cutoff = 21600 # 6 hours +) { + queue <- ifelse(t_sec_estimate > t_cutoff, "long", "short") + return(queue) } +#' plotEstimatedWallTimes +#' +#' @description #' Plot the estimated runtimes for different advanced options and number #' of inputs #' @@ -297,81 +343,88 @@ assign_job_queue <- function( #' @return line plot object #' #' example: -#' p <- plot_estimated_walltimes() -#' ggplot2::ggsave(filename = "/data/molevolvr_transfer/molevolvr_dev/molevol_scripts/docs/estimate_walltimes.png", plot = p) +#' p <- plotEstimatedWallTimes() +#' ggplot2::ggsave(filename = "/data/molevolvr_transfer/molevolvr_ +#' dev/molevol_scripts/docs/estimate_walltimes.png", plot = p) #' @export -plot_estimated_walltimes <- function() { - opts <- make_opts2procs() |> names() +plotEstimatedWallTimes <- function() { + opts <- mapOption2Process() |> names() # get all possible submission permutations (powerset) get_powerset <- function(vec) { - # generate powerset (do not include empty set) - n <- length(vec) - indices <- 1:n - powerset <- lapply(1:n, function(x) combn(indices, x, simplify = FALSE)) - powerset <- unlist(powerset, recursive = FALSE) - powerset <- lapply(powerset, function(index) vec[index]) - powerset + # generate powerset (do not include empty set) + n <- length(vec) + indices <- 1:n + powerset <- lapply(1:n, function(x) combn(indices, x, simplify = FALSE)) + powerset <- unlist(powerset, recursive = FALSE) + powerset <- lapply(powerset, function(index) vec[index]) + powerset } opts_power_set <- get_powerset(opts) est_walltimes <- list() for (i in 1:20) { - est_walltimes <- append( - x = est_walltimes, - values = sapply( - opts_power_set, - FUN = function(advanced_opts) { - # for simplicity, assume the default number of homologus hits (100) - n_hits <- if ("homology_search" %in% advanced_opts) { - 100 - } else { - NULL - } - est_walltime <- advanced_opts2est_walltime( - advanced_opts, - n_inputs = i, - n_hits = n_hits, - verbose = TRUE - ) - names(est_walltime) <- paste0(advanced_opts, collapse = "_") - est_walltime - } + est_walltimes <- append( + x = est_walltimes, + values = sapply( + opts_power_set, + FUN = function(advanced_opts) { + # for simplicity, assume the default number of homologus hits (100) + n_hits <- if ("homology_search" %in% advanced_opts) { + 100 + } else { + NULL + } + est_walltime <- calculateEstimatedWallTimeFromOpts ( + advanced_opts, + n_inputs = i, + n_hits = n_hits, + verbose = TRUE ) + names(est_walltime) <- paste0(advanced_opts, collapse = "_") + est_walltime + } ) + ) } # concat all results to their unique names est_walltimes <- tapply( - unlist( - est_walltimes, - use.names = FALSE - ), - rep( - names(est_walltimes), - lengths(est_walltimes) - ), - FUN = c + unlist( + est_walltimes, + use.names = FALSE + ), + rep( + names(est_walltimes), + lengths(est_walltimes) + ), + FUN = c ) df_walltimes <- est_walltimes |> - unlist() |> - matrix(nrow = length(est_walltimes[[1]]), ncol = length(names(est_walltimes))) + unlist() |> + matrix(nrow = length(est_walltimes[[1]]), + ncol = length(names(est_walltimes))) colnames(df_walltimes) <- names(est_walltimes) df_walltimes <- df_walltimes |> tibble::as_tibble() # rm always col or powerset outcome without the "always" processes col_idx_keep <- grep(pattern = "always$", x = names(df_walltimes)) df_walltimes <- df_walltimes |> - dplyr::select(col_idx_keep) + dplyr::select(col_idx_keep) # bind n_inputs df_walltimes <- df_walltimes |> - dplyr::mutate(n_inputs = 1:20) - df_walltimes <- tidyr::gather(df_walltimes, key = "advanced_opts", value = "est_walltime", -n_inputs) + dplyr::mutate(n_inputs = 1:20) + df_walltimes <- tidyr::gather(df_walltimes, + key = "advanced_opts", + value = "est_walltime", + n_inputs) # sec to hrs df_walltimes <- df_walltimes |> - dplyr::mutate(est_walltime = est_walltime / 3600) - p <- ggplot2::ggplot(df_walltimes, ggplot2::aes(x = n_inputs, y = est_walltime, color = advanced_opts)) + - ggplot2::geom_line() + - ggplot2::labs( - title = "MolEvolvR estimated runtimes", - x = "Number of inputs", - y = "Estimated walltime (hours)" - ) + dplyr::mutate(est_walltime = est_walltime / 3600) + p <- ggplot2::ggplot(df_walltimes, ggplot2::aes(x = n_inputs, + y = est_walltime, + color = advanced_opts)) + + ggplot2::geom_line() + + ggplot2::labs( + title = "MolEvolvR estimated runtimes", + x = "Number of inputs", + y = "Estimated walltime (hours)" + ) return(p) } diff --git a/R/blastWrappers.R b/R/blastWrappers.R index 552b1ff6..9b55f3ee 100755 --- a/R/blastWrappers.R +++ b/R/blastWrappers.R @@ -18,25 +18,28 @@ #' #' @examples run_deltablast <- function(deltablast_path, db_search_path, - db = "refseq", query, evalue = "1e-5", - out, num_alignments, num_threads = 1) { - start <- Sys.time() + db = "refseq", query, evalue = "1e-5", + out, num_alignments, num_threads = 1) { - system(paste0("export BLASTDB=/", db_search_path)) + start <- Sys.time() - system2( - command = deltablast_path, - args = c( - "-db", db, - "-query", query, - "-evalue", evalue, - "-out", out, - "-num_threads", num_threads, - "-num_alignments", num_alignments - # ,"-outfmt", outfmt - ) + + system(paste0("export BLASTDB=/", db_search_path)) + + system2( + command = deltablast_path, + args = c( + "-db", db, + "-query", query, + "-evalue", evalue, + "-out", out, + "-num_threads", num_threads, + "-num_alignments", num_alignments + # ,"-outfmt", outfmt ) - print(Sys.time() - start) + ) + print(Sys.time() - start) + } @@ -55,20 +58,21 @@ run_deltablast <- function(deltablast_path, db_search_path, #' #' @examples run_rpsblast <- function(rpsblast_path, db_search_path, - db = "refseq", query, evalue = "1e-5", - out, num_threads = 1) { - start <- Sys.time() - system(paste0("export BLASTDB=/", db_search_path)) - system2( - command = rpsblast_path, - args = c( - "-db", db, - "-query", query, - "-evalue", evalue, - "-out", out, - "-num_threads", num_threads - # , "-outfmt", outfmt - ) + db = "refseq", query, evalue = "1e-5", + out, num_threads = 1) { + + start <- Sys.time() + system(paste0("export BLASTDB=/", db_search_path)) + + system2( + command = rpsblast_path, + args = c( + "-db", db, + "-query", query, + "-evalue", evalue, + "-out", out, + "-num_threads", num_threads ) - print(Sys.time() - start) + ) + print(Sys.time() - start) } diff --git a/R/clean_clust_file.R b/R/clean_clust_file.R index d3f813e5..87dcde70 100755 --- a/R/clean_clust_file.R +++ b/R/clean_clust_file.R @@ -55,9 +55,9 @@ #' #' @examples #' \dontrun{ -#' clean_clust_file("data/pspa.op_ins_cls", writepath = NULL, query = "pspa") +#' cleanClusterFile("data/pspa.op_ins_cls", writepath = NULL, query = "pspa") #' } -clean_clust_file <- function(path, writepath = NULL, query) { +cleanClusterFile <- function(path, writepath = NULL, query) { # ?? does the following line need to be changed to read_lines()? prot <- read_tsv(path, col_names = F) diff --git a/R/combine_analysis.R b/R/combine_analysis.R index bb3b3ce2..55e36925 100755 --- a/R/combine_analysis.R +++ b/R/combine_analysis.R @@ -17,9 +17,9 @@ #' @export #' #' @examples -combine_full <- function(inpath, ret = FALSE) { +combineFullAnalysis <- function(inpath, ret = FALSE) { ## Combining full_analysis files - full_combnd <- combine_files(inpath, + full_combnd <- combineFiles(inpath, pattern = "*.full_analysis.tsv", skip = 0, col_names = T ) @@ -44,9 +44,9 @@ combine_full <- function(inpath, ret = FALSE) { #' @export #' #' @examples -combine_ipr <- function(inpath, ret = FALSE) { +combineIPR <- function(inpath, ret = FALSE) { ## Combining clean ipr files - ipr_combnd <- combine_files(inpath, + ipr_combnd <- combineFiles(inpath, pattern = "*.iprscan_cln.tsv", skip = 0, col_names = T ) diff --git a/R/combine_files.R b/R/combine_files.R index 76c5fa09..455ddd53 100755 --- a/R/combine_files.R +++ b/R/combine_files.R @@ -38,7 +38,7 @@ #' @export #' #' @examples -combine_files <- function(inpath = c("../molevol_data/project_data/phage_defense/"), +combineFiles <- function(inpath = c("../molevol_data/project_data/phage_defense/"), pattern = "*full_analysis.tsv", delim = "\t", skip = 0, col_names = T) { @@ -67,7 +67,7 @@ combine_files <- function(inpath = c("../molevol_data/project_data/phage_defense ## Sample Runs ## ################# # ## Combining full_analysis files -# full_combnd <- combine_files(inpath, +# full_combnd <- combineFiles(inpath, # pattern="*full_analysis.txt", skip=0, # col_names=T) # @@ -75,7 +75,7 @@ combine_files <- function(inpath = c("../molevol_data/project_data/phage_defense # path="../molevol_data/project_data/slps/full_combined.tsv") # # ## Combining clean files -# cln_combnd <- combine_files(inpath, +# cln_combnd <- combineFiles(inpath, # pattern="^.*cln.txt", skip=0, # col_names=T) # @@ -86,14 +86,14 @@ combine_files <- function(inpath = c("../molevol_data/project_data/phage_defense # ## Less helpful examples! # ## Combining BLAST files # ## Likely makes no sense since clustering is done per query -# cl_blast_combnd <- combine_files(inpath, +# cl_blast_combnd <- combineFiles(inpath, # pattern="^.*refseq.1e-5.txt", skip=0, # col_names=cl_blast_colnames) %>% # select(-PcPositive, -ClusterID) # # ## Combining IPR files # ## Likely makes no sense since there may be repeated AccNum from indiv. files! -# ipr_combnd <- combine_files(inpath, +# ipr_combnd <- combineFiles(inpath, # pattern="*iprscan.lins*", skip=0, # col_names=ipr_colnames) # diff --git a/R/create_lineage_lookup.R b/R/create_lineage_lookup.R index e7374df3..2408c5e6 100644 --- a/R/create_lineage_lookup.R +++ b/R/create_lineage_lookup.R @@ -3,6 +3,9 @@ # library(biomartr) +#' createLineageLookup +#' +#' @description #' Create a look up table that goes from TaxID, to Lineage #' #' @author Samuel Chen @@ -26,9 +29,9 @@ #' @export #' #' @examples -create_lineage_lookup <- function(lineage_file = here("data/rankedlineage.dmp"), +createLineageLookup <- function(lineage_file = here("data/rankedlineage.dmp"), outfile, taxonomic_rank = "phylum") { - shorten_NA <- function(Lineage) { + .shortenNA <- function(Lineage) { first_NA <- str_locate(Lineage, "NA")[1] if (is.na(first_NA)) { # No NAs @@ -92,7 +95,7 @@ create_lineage_lookup <- function(lineage_file = here("data/rankedlineage.dmp"), # Takes a while (2million rows after all) rankedLinsCombined <- rankedLins %>% unite(col = "Lineage", all_of(combined_taxonomy), sep = ">") %>% - mutate(Lineage = unlist(map(Lineage, shorten_NA))) + mutate(Lineage = unlist(map(Lineage, .shortenNA))) @@ -101,7 +104,7 @@ create_lineage_lookup <- function(lineage_file = here("data/rankedlineage.dmp"), -#' CreateLineageLookup <- function(assembly_path, updateAssembly = FALSE, file_type = "tsv") +#' createLineageLookup <- function(assembly_path, updateAssembly = FALSE, file_type = "tsv") #' { #' #' Create a look up table that goes from GCA_ID, to TaxID, to Lineage #' #' @author Samuel Chen diff --git a/R/lineage.R b/R/lineage.R index d14246d7..ef4fe586 100644 --- a/R/lineage.R +++ b/R/lineage.R @@ -77,7 +77,7 @@ downloadAssemblySummary <- function(outpath, #' This file can be generated using the "downloadAssemblySummary()" function #' @param lineagelookup_path String of the path to the lineage lookup file #' (taxid to lineage mapping). This file can be generated using the -#' "create_lineage_lookup()" function +#' "createLineageLookup()" function #' @param acc_col #' #' @importFrom dplyr pull @@ -309,7 +309,7 @@ efetchIPG <- function(accessions, out_path, plan = "multicore") { #' @param genbank_assembly_path #' @param lineagelookup_path String of the path to the lineage lookup file #' (taxid to lineage mapping). This file can be generated using the -#' "create_lineage_lookup()" function +#' "createLineageLookup()" function #' #' @importFrom data.table fread setnames #' diff --git a/R/msa.R b/R/msa.R index e56cc32c..0b1b6e34 100644 --- a/R/msa.R +++ b/R/msa.R @@ -197,21 +197,21 @@ msa_pdf <- function(fasta_path, out_path = NULL, #' #' @examples generate_msa <- function(fa_file = "", outfile = "") { - prot_aa <- readAAStringSet( - path = fa_file, - format = "fasta" - ) - prot_aa + prot_aa <- readAAStringSet( + fa_file, + format = "fasta" + ) + prot_aa - ## Install kalign ?rMSA_INSTALL - ## Messed up! Reimplement from kalign.R - ## https://github.com/mhahsler/rMSA/blob/master/R/kalign.R + ## Install kalign ?rMSA_INSTALL + ## Messed up! Reimplement from kalign.R + ## https://github.com/mhahsler/rMSA/blob/master/R/kalign.R - # source("scripts/c2r.R") + # source("scripts/c2r.R") - ## align the sequences - al <- kalign(prot_aa) # !! won't work! - al + ## align the sequences + al <- kalign(prot_aa) # !! won't work! + al } ############################ diff --git a/man/GCA2Lineage.Rd b/man/GCA2Lineage.Rd index 9ec0ce56..9a2a7a30 100644 --- a/man/GCA2Lineage.Rd +++ b/man/GCA2Lineage.Rd @@ -19,7 +19,7 @@ This file can be generated using the "downloadAssemblySummary()" function} \item{lineagelookup_path}{String of the path to the lineage lookup file (taxid to lineage mapping). This file can be generated using the -"create_lineage_lookup()" function} +"createLineageLookup()" function} \item{acc_col}{} } diff --git a/man/IPG2Lineage.Rd b/man/IPG2Lineage.Rd index 282d5cbf..118812ab 100644 --- a/man/IPG2Lineage.Rd +++ b/man/IPG2Lineage.Rd @@ -29,7 +29,7 @@ file} \item{lineagelookup_path}{String of the path to the lineage lookup file (taxid to lineage mapping). This file can be generated using the -"create_lineage_lookup()" function} +"createLineageLookup()" function} \item{assembly_path}{String of the path to the assembly_summary path This file can be generated using the \link[MolEvolvR]{downloadAssemblySummary} function} @@ -39,7 +39,8 @@ A \code{data.table} with the lineage information for the provided protein accessions. } \description{ -Takes the resulting file of an efetch run on the ipg database and +Takes the resulting file +of an efetch run on the ipg database and Takes the resulting file of an efetch run on the ipg database and append lineage, and taxid columns diff --git a/man/assign_job_queue.Rd b/man/assignJobQueue.Rd similarity index 58% rename from man/assign_job_queue.Rd rename to man/assignJobQueue.Rd index ceb6fa77..de646a82 100644 --- a/man/assign_job_queue.Rd +++ b/man/assignJobQueue.Rd @@ -1,14 +1,14 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/assign_job_queue.R -\name{assign_job_queue} -\alias{assign_job_queue} -\title{Decision function to assign job queue} +\name{assignJobQueue} +\alias{assignJobQueue} +\title{assignJobQueue} \usage{ -assign_job_queue(t_sec_estimate, t_cutoff = 21600) +assignJobQueue(t_sec_estimate, t_cutoff = 21600) } \arguments{ \item{t_sec_estimate}{estimated number of seconds a job will process -(from advanced_opts2est_walltime())} +(from calculateEstimatedWallTimeFromOpts ())} \item{t_long}{threshold value that defines the lower bound for assigning a job to the "long queue"} @@ -17,8 +17,9 @@ job to the "long queue"} a string of "short" or "long" example: -advanced_opts2est_walltime(c("homology_search", "domain_architecture"), 3) |> -assign_job_queue() +calculateEstimatedWallTimeFromOpts (c("homology_search", +"domain_architecture"), 3) |> +assignJobQueue() } \description{ Decision function to assign job queue diff --git a/man/advanced_opts2est_walltime.Rd b/man/calculateEstimatedWallTimeFromOpts.Rd similarity index 58% rename from man/advanced_opts2est_walltime.Rd rename to man/calculateEstimatedWallTimeFromOpts.Rd index ea4b29e6..d5361001 100644 --- a/man/advanced_opts2est_walltime.Rd +++ b/man/calculateEstimatedWallTimeFromOpts.Rd @@ -1,11 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/assign_job_queue.R -\name{advanced_opts2est_walltime} -\alias{advanced_opts2est_walltime} -\title{Given MolEvolvR advanced options and number of inputs, -calculate the total estimated walltime for the job} +\name{calculateEstimatedWallTimeFromOpts} +\alias{calculateEstimatedWallTimeFromOpts} +\title{calculateEstimatedWallTimeFromOpts} \usage{ -advanced_opts2est_walltime( +calculateEstimatedWallTimeFromOpts( advanced_opts, n_inputs = 1L, n_hits = NULL, @@ -14,14 +13,16 @@ advanced_opts2est_walltime( } \arguments{ \item{advanced_opts}{character vector of MolEvolvR advanced options -(see make_opts2procs for the options)} +(see mapOption2Process for the options)} \item{n_inputs}{total number of input proteins} } \value{ total estimated number of seconds a job will process (walltime) -example: advanced_opts2est_walltime(c("homology_search", "domain_architecture"), n_inputs = 3, n_hits = 50L) +example: calculateEstimatedWallTimeFromOpts (c("homology_search", +"domain_architecture"), +n_inputs = 3, n_hits = 50L) } \description{ Given MolEvolvR advanced options and number of inputs, diff --git a/man/get_proc_medians.Rd b/man/calculateProcessRuntime.Rd similarity index 72% rename from man/get_proc_medians.Rd rename to man/calculateProcessRuntime.Rd index b6db0b56..579ea2b6 100644 --- a/man/get_proc_medians.Rd +++ b/man/calculateProcessRuntime.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/assign_job_queue.R -\name{get_proc_medians} -\alias{get_proc_medians} -\title{Scrape MolEvolvR logs and calculate median processes} +\name{calculateProcessRuntime} +\alias{calculateProcessRuntime} +\title{calculateProcessRuntime} \usage{ -get_proc_medians(dir_job_results) +calculateProcessRuntime(dir_job_results) } \arguments{ \item{dir_job_results}{\link{chr} path to MolEvolvR job_results @@ -21,12 +21,12 @@ examples: } dir_job_results <- "/data/scratch/janani/molevolvr_out" -list_proc_medians <- get_proc_medians(dir_job_results) +list_proc_medians <- calculateProcessRuntime(dir_job_results) \enumerate{ \item from outside container environment common_root <- "/data/molevolvr_transfer/molevolvr_dev" dir_job_results <- "/data/molevolvr_transfer/molevolvr_dev/job_results" -list_proc_medians <- get_proc_medians(dir_job_results) +list_proc_medians <- calculateProcessRuntime(dir_job_results) } } \description{ diff --git a/man/clean_clust_file.Rd b/man/cleanClusterFile.Rd similarity index 82% rename from man/clean_clust_file.Rd rename to man/cleanClusterFile.Rd index bba3072e..d2818662 100644 --- a/man/clean_clust_file.Rd +++ b/man/cleanClusterFile.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/clean_clust_file.R -\name{clean_clust_file} -\alias{clean_clust_file} +\name{cleanClusterFile} +\alias{cleanClusterFile} \title{Clean Cluster File} \usage{ -clean_clust_file(path, writepath = NULL, query) +cleanClusterFile(path, writepath = NULL, query) } \arguments{ \item{path}{A character to the path of the cluster file to be cleaned} @@ -24,6 +24,6 @@ This function reads a space-separated cluster file and converts it to a cleaned } \examples{ \dontrun{ -clean_clust_file("data/pspa.op_ins_cls", writepath = NULL, query = "pspa") +cleanClusterFile("data/pspa.op_ins_cls", writepath = NULL, query = "pspa") } } diff --git a/man/combine_files.Rd b/man/combineFiles.Rd similarity index 92% rename from man/combine_files.Rd rename to man/combineFiles.Rd index 4126eb9e..3b56b923 100644 --- a/man/combine_files.Rd +++ b/man/combineFiles.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/combine_files.R -\name{combine_files} -\alias{combine_files} +\name{combineFiles} +\alias{combineFiles} \title{Download the combined assembly summaries of genbank and refseq} \usage{ -combine_files( +combineFiles( inpath = c("../molevol_data/project_data/phage_defense/"), pattern = "*full_analysis.tsv", delim = "\\t", diff --git a/man/combine_full.Rd b/man/combineFullAnalysis.Rd similarity index 69% rename from man/combine_full.Rd rename to man/combineFullAnalysis.Rd index f4e6597b..35925e86 100644 --- a/man/combine_full.Rd +++ b/man/combineFullAnalysis.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/combine_analysis.R -\name{combine_full} -\alias{combine_full} +\name{combineFullAnalysis} +\alias{combineFullAnalysis} \title{Combining full_analysis files} \usage{ -combine_full(inpath, ret = FALSE) +combineFullAnalysis(inpath, ret = FALSE) } \arguments{ \item{ret}{} diff --git a/man/combine_ipr.Rd b/man/combineIPR.Rd similarity index 74% rename from man/combine_ipr.Rd rename to man/combineIPR.Rd index 52aa3057..035c4274 100644 --- a/man/combine_ipr.Rd +++ b/man/combineIPR.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/combine_analysis.R -\name{combine_ipr} -\alias{combine_ipr} +\name{combineIPR} +\alias{combineIPR} \title{Combining clean ipr files} \usage{ -combine_ipr(inpath, ret = FALSE) +combineIPR(inpath, ret = FALSE) } \arguments{ \item{ret}{} diff --git a/man/create_lineage_lookup.Rd b/man/createLineageLookup.Rd similarity index 85% rename from man/create_lineage_lookup.Rd rename to man/createLineageLookup.Rd index 51670f35..132019ce 100644 --- a/man/create_lineage_lookup.Rd +++ b/man/createLineageLookup.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/create_lineage_lookup.R -\name{create_lineage_lookup} -\alias{create_lineage_lookup} -\title{Create a look up table that goes from TaxID, to Lineage} +\name{createLineageLookup} +\alias{createLineageLookup} +\title{createLineageLookup} \usage{ -create_lineage_lookup( +createLineageLookup( lineage_file = here("data/rankedlineage.dmp"), outfile, taxonomic_rank = "phylum" diff --git a/man/get_proc_weights.Rd b/man/getProcessRuntimeWeights.Rd similarity index 64% rename from man/get_proc_weights.Rd rename to man/getProcessRuntimeWeights.Rd index 0f4beb57..de0e2ea6 100644 --- a/man/get_proc_weights.Rd +++ b/man/getProcessRuntimeWeights.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/assign_job_queue.R -\name{get_proc_weights} -\alias{get_proc_weights} -\title{Quickly get the runtime weights for MolEvolvR backend processes} +\name{getProcessRuntimeWeights} +\alias{getProcessRuntimeWeights} +\title{getProcessRuntimeWeights} \usage{ -get_proc_weights(medians_yml_path = NULL) +getProcessRuntimeWeights(medians_yml_path = NULL) } \arguments{ \item{dir_job_results}{\link{chr} path to MolEvolvR job_results @@ -13,7 +13,7 @@ directory} \value{ \link{list} names: processes; values: median runtime (seconds) -example: get_proc_weights() +example: writeProcessRuntime2YML() } \description{ Quickly get the runtime weights for MolEvolvR backend processes diff --git a/man/map_advanced_opts2procs.Rd b/man/mapAdvOption2Process.Rd similarity index 66% rename from man/map_advanced_opts2procs.Rd rename to man/mapAdvOption2Process.Rd index 631708b4..6a210a20 100644 --- a/man/map_advanced_opts2procs.Rd +++ b/man/mapAdvOption2Process.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/assign_job_queue.R -\name{map_advanced_opts2procs} -\alias{map_advanced_opts2procs} -\title{Use MolEvolvR advanced options to get associated processes} +\name{mapAdvOption2Process} +\alias{mapAdvOption2Process} +\title{mapAdvOption2Process} \usage{ -map_advanced_opts2procs(advanced_opts) +mapAdvOption2Process(advanced_opts) } \arguments{ \item{advanced_opts}{character vector of MolEvolvR advanced options} @@ -15,7 +15,7 @@ the advanced options example: advanced_opts <- c("homology_search", "domain_architecture") -procs <- map_advanced_opts2procs(advanced_opts) +procs <- mapAdvOption2Process(advanced_opts) } \description{ Use MolEvolvR advanced options to get associated processes diff --git a/man/make_opts2procs.Rd b/man/mapOption2Process.Rd similarity index 58% rename from man/make_opts2procs.Rd rename to man/mapOption2Process.Rd index 07e208b2..9645617b 100644 --- a/man/make_opts2procs.Rd +++ b/man/mapOption2Process.Rd @@ -1,15 +1,15 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/assign_job_queue.R -\name{make_opts2procs} -\alias{make_opts2procs} -\title{Construct list where names (MolEvolvR advanced options) point to processes} +\name{mapOption2Process} +\alias{mapOption2Process} +\title{mapOption2Process} \usage{ -make_opts2procs() +mapOption2Process() } \value{ list where names (MolEvolvR advanced options) point to processes -example: list_opts2procs <- make_opts2procs +example: list_opts2procs <- mapOption2Process } \description{ Construct list where names (MolEvolvR advanced options) point to processes diff --git a/man/plotEstimatedWallTimes.Rd b/man/plotEstimatedWallTimes.Rd new file mode 100644 index 00000000..36b0ecd5 --- /dev/null +++ b/man/plotEstimatedWallTimes.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/assign_job_queue.R +\name{plotEstimatedWallTimes} +\alias{plotEstimatedWallTimes} +\title{plotEstimatedWallTimes} +\usage{ +plotEstimatedWallTimes() +} +\value{ +line plot object + +example: +p <- plotEstimatedWallTimes() +ggplot2::ggsave(filename = "/data/molevolvr_transfer/molevolvr_ +dev/molevol_scripts/docs/estimate_walltimes.png", plot = p) +} +\description{ +Plot the estimated runtimes for different advanced options and number +of inputs + +this function was just for fun; very, very messy code +} diff --git a/man/plot_estimated_walltimes.Rd b/man/plot_estimated_walltimes.Rd deleted file mode 100644 index 3669e0e0..00000000 --- a/man/plot_estimated_walltimes.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/assign_job_queue.R -\name{plot_estimated_walltimes} -\alias{plot_estimated_walltimes} -\title{Plot the estimated runtimes for different advanced options and number -of inputs} -\usage{ -plot_estimated_walltimes() -} -\value{ -line plot object - -example: -p <- plot_estimated_walltimes() -ggplot2::ggsave(filename = "/data/molevolvr_transfer/molevolvr_dev/molevol_scripts/docs/estimate_walltimes.png", plot = p) -} -\description{ -this function was just for fun; very, very messy code -} diff --git a/man/write_proc_medians_table.Rd b/man/writeProcessRuntime2TSV.Rd similarity index 67% rename from man/write_proc_medians_table.Rd rename to man/writeProcessRuntime2TSV.Rd index 2ae7a97b..0e045a5c 100644 --- a/man/write_proc_medians_table.Rd +++ b/man/writeProcessRuntime2TSV.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/assign_job_queue.R -\name{write_proc_medians_table} -\alias{write_proc_medians_table} -\title{Write a table of 2 columns: 1) process and 2) median seconds} +\name{writeProcessRuntime2TSV} +\alias{writeProcessRuntime2TSV} +\title{writeProcessRuntime2TSV} \usage{ -write_proc_medians_table(dir_job_results, filepath) +writeProcessRuntime2TSV(dir_job_results, filepath) } \arguments{ \item{dir_job_results}{\link{chr} path to MolEvolvR job_results} @@ -14,7 +14,7 @@ write_proc_medians_table(dir_job_results, filepath) \value{ \link{tbl_df} 2 columns: 1) process and 2) median seconds -example: write_proc_medians_table( +example: writeProcessRuntime2TSV( "/data/scratch/janani/molevolvr_out/", "/data/scratch/janani/molevolvr_out/log_tbl.tsv" ) diff --git a/man/write_proc_medians_yml.Rd b/man/writeProcessRuntime2YML.Rd similarity index 50% rename from man/write_proc_medians_yml.Rd rename to man/writeProcessRuntime2YML.Rd index a3d8ee5f..5e0a05a4 100644 --- a/man/write_proc_medians_yml.Rd +++ b/man/writeProcessRuntime2YML.Rd @@ -1,25 +1,28 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/assign_job_queue.R -\name{write_proc_medians_yml} -\alias{write_proc_medians_yml} -\title{Compute median process runtimes, then write a YAML list of the processes and -their median runtimes in seconds to the path specified by 'filepath'.} +\name{writeProcessRuntime2YML} +\alias{writeProcessRuntime2YML} +\title{writeProcessRuntime2YML} \usage{ -write_proc_medians_yml(dir_job_results, filepath = NULL) +writeProcessRuntime2YML(dir_job_results, filepath = NULL) } \arguments{ \item{dir_job_results}{\link{chr} path to MolEvolvR job_results directory} -\item{filepath}{\link{chr} path to save YAML file; if NULL, uses ./molevol_scripts/log_data/job_proc_weights.yml} +\item{filepath}{\link{chr} path to save YAML file; if NULL, +uses ./molevol_scripts/log_data/job_proc_weights.yml} } \description{ +Compute median process runtimes, then write a YAML list of the processes and +their median runtimes in seconds to the path specified by 'filepath'. + The default value of filepath is the value of the env var -MOLEVOLVR_PROC_WEIGHTS, which get_proc_weights() also uses as its default +MOLEVOLVR_PROC_WEIGHTS, which getProcessRuntimeWeights() also uses as its default read location. } \examples{ \dontrun{ -write_proc_medians_yml( +writeProcessRuntime2YML( "/data/scratch/janani/molevolvr_out/", "/data/scratch/janani/molevolvr_out/log_tbl.yml" )