Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parameter definitions to tree.R #40

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading