Skip to content

Commit

Permalink
add miniconda support for OrthoFinder2 calls #22
Browse files Browse the repository at this point in the history
  • Loading branch information
HajkD committed Aug 3, 2020
1 parent 020540d commit 8667ff0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion R/is_installed_orthofinder.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ is_installed_orthofinder <- function() {
# test if a valid BLAST version is installed
tryCatch({
sys_out <-
system("orthofinder", intern = TRUE)
system("/opt/miniconda3/bin/orthofinder", intern = TRUE)
}, error = function(e)
stop(
"It seems like you don't have OrthoFinder2 installed locally on your machine or the PATH variable to the OrthoFinder2 program is not set correctly.",
Expand Down
28 changes: 14 additions & 14 deletions R/orthofinder2.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#' }
#' @param comp_cores number of cores that shall be used for parallel processing. Default is \code{cores = 1}.
#' @author Hajk-Georg Drost
#' @note This function assumes that users have \code{OrthoFinder} installed via \code{miniconda} and stored at \code{~/opt/miniconda3/bin/}.
#' In addition, DIAMOND needs to be installed as executable tool (/usr/local/bin).
#' @examples \dontrun{
#' # specify species names
#' orgs <- c("Arabidopsis lyrata",
Expand All @@ -32,12 +34,14 @@
#' }
#' @export

orthofinder2 <- function(proteome_folder, use_existing_output = FALSE, import_type = "orthogroups_core", comp_cores = 1) {
orthofinder2 <- function(proteome_folder, use_existing_output = FALSE, import_type = NULL, comp_cores = 1) {

is_installed_orthofinder()

if (!is.element(import_type, c("orthogroups_core", "orthogroups_pairwise")))
stop("The specified 'import_type' is not supported by this function. Please consult the documentation to select a valid Orthofinder2 'import_type'.", call. = FALSE)
if (!is.null(import_type)) {
if (!is.element(import_type, c("orthogroups_core", "orthogroups_pairwise")))
stop("The specified 'import_type' is not supported by this function. Please consult the documentation to select a valid Orthofinder2 'import_type'.", call. = FALSE)
}

### add here a test that input sequences are amino acid sequences

Expand All @@ -60,30 +64,26 @@ orthofinder2 <- function(proteome_folder, use_existing_output = FALSE, import_ty
if (comp_cores > cores)
stop("You chose more cores than are available on your machine.", call. = FALSE)

message("Running ", system("orthofinder", intern = TRUE)[1], " using ", comp_cores, " cores ...")
message("Running OrthoFinder2 with ", comp_cores, " cores ...")
message("Do your input fasta files store unique sequences per gene locus, e.g. the longest splice variant? If not, then have a look at ?orthologr::retrieve_longest_isoforms().")

# output is stored in OrthoFinder/Results_DATE , where DATE is in format: Nov08 for 08 th November
# or in this case OrthoFinder/Results_DATE_basename(proteome_folder)

if (dirname(proteome_folder) == ".") {
system(paste0("orthofinder -f ", ws_wrap(file.path(getwd(), proteome_folder))," -t ", cores," -a ", cores," -S diamond -n ", basename(proteome_folder)))
system(paste0("/opt/miniconda3/bin/orthofinder -f ", ws_wrap(file.path(getwd(), proteome_folder))," -t ", cores," -a ", cores," -S diamond -n ", basename(proteome_folder)))
} else {
system(paste0("orthofinder -f ", ws_wrap(proteome_folder)," -t ", cores," -a ", cores," -S diamond -n ", basename(proteome_folder)))
system(paste0("/opt/miniconda3/bin/orthofinder -f ", ws_wrap(proteome_folder)," -t ", cores," -a ", cores," -S diamond -n ", basename(proteome_folder)))
}

message("Orthofinder2 finished successfully and stored all results in ", ifelse(dirname(proteome_folder) == ".", ws_wrap(file.path(getwd(), proteome_folder)), ws_wrap(proteome_folder)))

}
orthofinder2_output_folder <- file.path(proteome_folder, "OrthoFinder", paste0("Results_", basename(proteome_folder)))

if (import_type == "orthogroups_core") {
res <- orthofinder2_retrieve_core_orthologs(orthogroups_file = file.path(orthofinder2_output_folder, ""))
if (!is.null(import_type) && (import_type == "orthogroups_core")) {
res <- orthofinder2_retrieve_core_orthologs(orthogroups_file = file.path(orthofinder2_output_folder, "") , single_copy_file = file.path(orthofinder2_output_folder, ""))
return(res)
}







}
6 changes: 5 additions & 1 deletion man/orthofinder2.Rd

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

0 comments on commit 8667ff0

Please sign in to comment.