Skip to content

Commit

Permalink
Merge pull request #40 from awasyn/docstree
Browse files Browse the repository at this point in the history
Add parameter definitions to tree.R
  • Loading branch information
the-mayer authored Oct 10, 2024
2 parents 772d2b7 + 37cb53f commit b96198e
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 15 deletions.
38 changes: 28 additions & 10 deletions R/tree.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,23 @@
## !! FastTree will only work if there are unique sequence names!!
#' convertFA2Tree
#'
#' @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")
#' }
convertFA2Tree <- function(fa_path = here("data/alns/pspa_snf7.fa"),
tre_path = here("data/alns/pspa_snf7.tre"),
fasttree_path = here("src/FastTree")) {
Expand Down Expand Up @@ -72,16 +81,22 @@ convertFA2Tree <- 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/"))
#' }
convertAlignment2Trees <- function(aln_path = here("data/alns/")) {
# finding all fasta alignment files
fa_filenames <- list.files(path = aln_path, pattern = "*.fa")
Expand Down Expand Up @@ -111,16 +126,19 @@ convertAlignment2Trees <- 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 +
Expand Down
12 changes: 11 additions & 1 deletion man/convertAlignment2Trees.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 19 additions & 1 deletion man/convertFA2Tree.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions man/createFA2Tree.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b96198e

Please sign in to comment.