From 323a06f69109f0e9369df5879bf91f14b887001d Mon Sep 17 00:00:00 2001 From: Awa Synthia Date: Sat, 5 Oct 2024 08:33:38 +0300 Subject: [PATCH] Add parameter definitions to tree.R Signed-off-by: Awa Synthia --- R/tree.R | 38 ++++++++++++++++++++++++++++---------- man/convert_fa2tre.Rd | 20 +++++++++++++++++++- man/generate_fa2tre.Rd | 12 +++++++++--- man/generate_trees.Rd | 12 +++++++++++- 4 files changed, 67 insertions(+), 15 deletions(-) diff --git a/R/tree.R b/R/tree.R index 01e9ead5..a4501b7d 100755 --- a/R/tree.R +++ b/R/tree.R @@ -37,14 +37,23 @@ ## !! FastTree will only work if there are unique sequence names!! #' convert_fa2tre #' -#' @param fa_path -#' @param tre_path -#' @param fasttree_path +#' @param fa_path Path to the input FASTA alignment file (.fa). Default is the +#' path to "data/alns/pspa_snf7.fa". +#' @param tre_path Path to the output file where the generated tree (.tre) will +#' be saved. Default is the path to "data/alns/pspa_snf7.tre". +#' @param fasttree_path Path to the FastTree executable, which is used to +#' generate the phylogenetic tree. Default is "src/FastTree". #' -#' @return +#' @return No return value. The function generates a tree file (.tre) from the +#' input FASTA file. #' @export #' #' @examples +#' \dontrun{ +#' convert_fa2tre(here("data/alns/pspa_snf7.fa"), +#' here("data/alns/pspa_snf7.tre"), +#' here("src/FastTree") +#' } convert_fa2tre <- function(fa_path = here("data/alns/pspa_snf7.fa"), tre_path = here("data/alns/pspa_snf7.tre"), fasttree_path = here("src/FastTree")) { @@ -72,16 +81,22 @@ convert_fa2tre <- function(fa_path = here("data/alns/pspa_snf7.fa"), #' @description #' Generate Trees for ALL fasta files in "data/alns" #' -#' @param aln_path +#' @param aln_path Path to the directory containing all the alignment FASTA +#' files (.fa) for which trees will be generated. Default is "data/alns/". +#' #' #' @importFrom here here #' @importFrom purrr pmap #' @importFrom stringr str_replace_all #' -#' @return +#' @return No return value. The function generates tree files (.tre) for each +#' alignment file in the specified directory. #' @export #' #' @examples +#' \dontrun{ +#' generate_trees(here("data/alns/")) +#' } generate_trees <- function(aln_path = here("data/alns/")) { # finding all fasta alignment files fa_filenames <- list.files(path = aln_path, pattern = "*.fa") @@ -111,16 +126,19 @@ generate_trees <- function(aln_path = here("data/alns/")) { #' @description #' Generating phylogenetic tree from alignment file '.fa' #' -#' @param fa_file Character. Path to file. -#' Default is 'pspa_snf7.fa' -#' @param out_file +#' @param fa_file Character. Path to the alignment FASTA file (.fa) from which +#' the phylogenetic tree will be generated. Default is 'pspa_snf7.fa'. +#' @param out_file Path to the output file where the generated tree (.tre) will +#' be saved. Default is "data/alns/pspa_snf7.tre". #' #' @importFrom ape write.tree #' @importFrom phangorn bootstrap.pml dist.ml NJ modelTest phyDat plotBS pml pml.control pratchet optim.parsimony optim.pml read.phyDat upgma #' @importFrom seqinr dist.alignment read.alignment #' @importFrom stats logLik #' -#' @return +#' @return No return value. The function generates a phylogenetic tree file +#' (.tre) based on different approaches like Neighbor Joining, UPGMA, and +#' Maximum Likelihood. #' @export #' #' @details The alignment file would need two columns: 1. accession + diff --git a/man/convert_fa2tre.Rd b/man/convert_fa2tre.Rd index 87c59d67..e86ea812 100644 --- a/man/convert_fa2tre.Rd +++ b/man/convert_fa2tre.Rd @@ -11,8 +11,26 @@ convert_fa2tre( ) } \arguments{ -\item{fasttree_path}{} +\item{fa_path}{Path to the input FASTA alignment file (.fa). Default is the +path to "data/alns/pspa_snf7.fa".} + +\item{tre_path}{Path to the output file where the generated tree (.tre) will +be saved. Default is the path to "data/alns/pspa_snf7.tre".} + +\item{fasttree_path}{Path to the FastTree executable, which is used to +generate the phylogenetic tree. Default is "src/FastTree".} +} +\value{ +No return value. The function generates a tree file (.tre) from the +input FASTA file. } \description{ convert_fa2tre } +\examples{ +\dontrun{ +convert_fa2tre(here("data/alns/pspa_snf7.fa"), + here("data/alns/pspa_snf7.tre"), + here("src/FastTree") +} +} diff --git a/man/generate_fa2tre.Rd b/man/generate_fa2tre.Rd index b70848bb..ca7bce5e 100644 --- a/man/generate_fa2tre.Rd +++ b/man/generate_fa2tre.Rd @@ -10,10 +10,16 @@ generate_fa2tre( ) } \arguments{ -\item{fa_file}{Character. Path to file. -Default is 'pspa_snf7.fa'} +\item{fa_file}{Character. Path to the alignment FASTA file (.fa) from which +the phylogenetic tree will be generated. Default is 'pspa_snf7.fa'.} -\item{out_file}{} +\item{out_file}{Path to the output file where the generated tree (.tre) will +be saved. Default is "data/alns/pspa_snf7.tre".} +} +\value{ +No return value. The function generates a phylogenetic tree file +(.tre) based on different approaches like Neighbor Joining, UPGMA, and +Maximum Likelihood. } \description{ Generating phylogenetic tree from alignment file '.fa' diff --git a/man/generate_trees.Rd b/man/generate_trees.Rd index 43bd7243..0f1180ea 100644 --- a/man/generate_trees.Rd +++ b/man/generate_trees.Rd @@ -7,8 +7,18 @@ generate_trees(aln_path = here("data/alns/")) } \arguments{ -\item{aln_path}{} +\item{aln_path}{Path to the directory containing all the alignment FASTA +files (.fa) for which trees will be generated. Default is "data/alns/".} +} +\value{ +No return value. The function generates tree files (.tre) for each +alignment file in the specified directory. } \description{ Generate Trees for ALL fasta files in "data/alns" } +\examples{ +\dontrun{ +generate_trees(here("data/alns/")) +} +}