From 4a559dc3ccf80bb5ca6e734a712554f3ea687dda Mon Sep 17 00:00:00 2001 From: Luna Sare Date: Tue, 30 May 2023 17:37:08 -0700 Subject: [PATCH 1/7] update messages --- R/calibrations_match.R | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/R/calibrations_match.R b/R/calibrations_match.R index f1458633..3f0f8c0c 100644 --- a/R/calibrations_match.R +++ b/R/calibrations_match.R @@ -131,9 +131,9 @@ summary.matchedCalibrations <- function(object, ...) { if (length(not_in_phy_rows) > 0) { not_in_phy <- object[not_in_phy_rows, ] in_phy <- object[-not_in_phy_rows, ] - message1 <- c(message1, "Not all taxon name pairs are in 'phy'.") + message1 <- "Not all taxon name pairs are in 'phy'." } else { - message1 <- c(message1, "All taxon name pairs are in 'phy'.") + message1 <- "All taxon name pairs are in 'phy'." not_in_phy <- NULL in_phy <- object } @@ -141,12 +141,11 @@ summary.matchedCalibrations <- function(object, ...) { in_phy$reference <- as.factor(in_phy$reference) # is MaxAge and MinAge the same value? if (all(in_phy$MaxAge == in_phy$MinAge)) { - message1 <- c(message1, - "\n'MaxAge' and 'MinAge' columns in input 'matchedCalibrations' / - have the same values.") + message1 <- paste(message1, + "\n'MaxAge' and 'MinAge' columns from matched", + "calibrations have the same values.") } - message("Success!") - message(message1) + message(paste("Success!", message1)) return(structure(list(not_in_phy = not_in_phy, in_phy = in_phy), class = c("list", "summaryMatchedCalibrations"))) } From 1607f4ea1f27726b12bbe782cc66d7fe5ef7c686 Mon Sep 17 00:00:00 2001 From: Luna Sare Date: Mon, 5 Jun 2023 15:35:12 -0700 Subject: [PATCH 2/7] add a message when getting opentree tree fails --- R/to_phylo_all.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/R/to_phylo_all.R b/R/to_phylo_all.R index 778ba9bb..27eaedc1 100644 --- a/R/to_phylo_all.R +++ b/R/to_phylo_all.R @@ -98,6 +98,8 @@ summary_matrix_to_phylo_all <- function(summ_matrix, target_tree <- suppressMessages(get_otol_synthetic_tree(input = colnames(summ_matrix), ...)) if (!inherits(target_tree, "phylo")) { # enhance: we should find a better way to do this, but it should be ok for now: + message(paste("Obtaining a topology from Open Tree failed.")) + message(paste("... Converting patristic matrix to phylo.")) target_tree <- suppressWarnings(suppressMessages(patristic_matrix_to_phylo(summ_matrix, ultrametric = TRUE))) # target_tree <- consensus(phyloall, p = 0.5) # can't use consensus here: bc not all trees have the same number of tips } From a99276b9b8cdec0dfc7e674c1202526bbca0edb8 Mon Sep 17 00:00:00 2001 From: Luna Sare Date: Mon, 5 Jun 2023 16:38:44 -0700 Subject: [PATCH 3/7] add minimal example for function that extracts calibrations from chronograms --- tests/testthat/test_calibrations_extract.R | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 tests/testthat/test_calibrations_extract.R diff --git a/tests/testthat/test_calibrations_extract.R b/tests/testthat/test_calibrations_extract.R new file mode 100644 index 00000000..5b2342f1 --- /dev/null +++ b/tests/testthat/test_calibrations_extract.R @@ -0,0 +1,6 @@ +test_that("extract_calibrations_phylo works", { + utils::data(felid_gdr_phylo_all) + class(felid_gdr_phylo_all$phylo_all) <- "multiPhylo" + xx <- extract_calibrations_phylo(input = felid_gdr_phylo_all$phylo_all) + expect_true(inherits(xx, "data.frame")) +} From ff0cb43e0ffddb5975781949559af08e925d3a5e Mon Sep 17 00:00:00 2001 From: Luna Sare Date: Mon, 5 Jun 2023 16:40:12 -0700 Subject: [PATCH 4/7] return a data frame instead of NA when congruification fails for any chronogram --- R/calibrations_extract.R | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/R/calibrations_extract.R b/R/calibrations_extract.R index 1b39cdfa..c91cf043 100644 --- a/R/calibrations_extract.R +++ b/R/calibrations_extract.R @@ -92,19 +92,19 @@ extract_calibrations_phylo <- function(input = NULL, # Warning message: # In if (class(stock) == "phylo") { : # the condition has length > 1 and only the first element will be used - if (!inherits(local_df, "data.frame")) { - warning("Congruification failed") - return(NA) - } - local_df$reference <- names(chronograms)[i] - if (each) { - calibrations <- c(calibrations, list(local_df)) - } else { - if (i == 1) { - calibrations <- local_df + if (inherits(local_df, "data.frame")) { + local_df$reference <- names(chronograms)[i] + if (each) { + calibrations <- c(calibrations, list(local_df)) } else { - calibrations <- rbind(calibrations, local_df) + if (i == 1) { + calibrations <- local_df + } else { + calibrations <- rbind(calibrations, local_df) + } } + } else { + warning("Congruification of chronogram ", i, " failed.") } } ############################################################################## From 7543d69876fd102f159d78b8c30ae87a34e2eb07 Mon Sep 17 00:00:00 2001 From: Luna Sare Date: Fri, 16 Jun 2023 17:35:55 -0700 Subject: [PATCH 5/7] update news --- NEWS.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index a9229596..d9683e1e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,7 +4,11 @@ DONE: --> # datelife v0.6.8 -- fixed bug in function `extract_calibrations_phylo` +- fix bug in function `extract_calibrations_phylo()` +- update messages in `calibrations_match()` +- add faster function to retrieve descendants +- updates for new rotl version +- fix uri in DESCRIPTION # datelife v0.6.7 - added vignette for bold data workflow From 98b6859d444a338c0ba37e7484706b8d9445c248 Mon Sep 17 00:00:00 2001 From: Luna Sare Date: Fri, 16 Jun 2023 20:54:45 -0700 Subject: [PATCH 6/7] fix invalid http/https URIs --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 60470df8..88e7dcd2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -19,7 +19,7 @@ Authors@R: c( Description: Methods and workflows to get chronograms (i.e., phylogenetic trees with branch lengths proportional to time), using open, peer-reviewed, state-of-the-art scientific data on time of lineage divergence. This package constitutes the main underlying code of the DateLife web service - at . To obtain a single summary chronogram from a group of + at . To obtain a single summary chronogram from a group of relevant chronograms, we implement the Super Distance Matrix (SDM) method described in Criscuolo et al. (2006) . To find the grove of chronograms with a sufficiently overlapping set of taxa From 9daee6d47170028683ed31aa4444678d17906fce Mon Sep 17 00:00:00 2001 From: Luna Sare Date: Fri, 16 Jun 2023 21:00:55 -0700 Subject: [PATCH 7/7] align with outputs of new version of package rotl --- R/opentree_taxonomy_general.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/opentree_taxonomy_general.R b/R/opentree_taxonomy_general.R index b5eb13e2..3011f560 100644 --- a/R/opentree_taxonomy_general.R +++ b/R/opentree_taxonomy_general.R @@ -50,7 +50,7 @@ tnrs_match.default <- function(input, reference_taxonomy = "ott", ...) { # enhan # cat("\n") # just to make the progress bar look better # hardcoding Mus: if (sum("mus" == tolower(input)) > 0) { - if (packageVersion("rotl") >= 3.1.0) { + if (utils::packageVersion("rotl") >= "3.1.0") { df["mus" == tolower(input), ] <- list("mus", "Mus (genus in Deuterostomia)", FALSE, 1, 1068778, FALSE, "SIBLING_HIGHER", 3) } else { df["mus" == tolower(input), ] <- list("mus", "Mus (genus in Deuterostomia)", FALSE, 1068778, FALSE, "SIBLING_HIGHER", 3)