diff --git a/R/pk_ontotrace.R b/R/pk_ontotrace.R index f3dae74..079c6ba 100644 --- a/R/pk_ontotrace.R +++ b/R/pk_ontotrace.R @@ -68,21 +68,23 @@ pk_ontotrace <- function(taxon, entity, relation = "part of", get_metadata = FAL nex <- nexml_read(out) + m <- get_characters(nex) # returned data.frame with taxon names as row index m[] <- lapply(m, function(x) as.numeric(as.character(x))) - ont_row_names <- row.names(m) + ont_row_names <- rownames(m) rownames(m) <- NULL m <- dplyr::mutate(m, taxon = ont_row_names) - m_re <- m[, c(ncol(m), 1:ncol(m)-1)] + m_re <- dplyr::as_data_frame(m[, c(ncol(m), 1:ncol(m)-1)]) # TODO: add ordered taxonID and entityID to the list if (get_metadata == TRUE) { - id_taxa <- get_metadata(nex, level = "otu") - id_entity <- get_metadata(nex, level = "char") + id_taxa <- get_taxa(nex) + #id_entity <- get_metadata(nex, level = "char") m_re <- list(matrix = m_re, - id_taxa = id_taxa[which(names(id_taxa) == meta_attr_taxon)], - id_entity = id_entity[which(names(id_entity) == meta_attr_entitiy)] + id_taxa = id_taxa + #id_taxa = id_taxa[which(names(id_taxa) == meta_attr_taxon)] + #id_entity = id_entity[which(names(id_entity) == meta_attr_entitiy)] ) } return(m_re) diff --git a/man/pk_ontotrace.Rd b/man/pk_ontotrace.Rd index 39ebeba..b722a9e 100644 --- a/man/pk_ontotrace.Rd +++ b/man/pk_ontotrace.Rd @@ -4,7 +4,7 @@ \alias{pk_ontotrace} \title{Returns a NeXML-format evolutionary character matrix.} \usage{ -pk_ontotrace(taxon, entity, relation = "part of", get_metadata = TRUE, +pk_ontotrace(taxon, entity, relation = "part of", get_metadata = FALSE, variable_only = TRUE) } \arguments{ diff --git a/tests/testthat/test-pk.R b/tests/testthat/test-pk.R index f034cc2..08fdd39 100644 --- a/tests/testthat/test-pk.R +++ b/tests/testthat/test-pk.R @@ -58,14 +58,19 @@ test_that("Test OnToTrace", { rel <- pk_ontotrace(taxon = c("Ictalurus", "Ameiurus"), entity = c("fin", "spine"), relation = "develops from") + + single1 <- pk_ontotrace(taxon = "Ictalurus", entity = "fin", get_metadata = TRUE) + err1 <- function() pk_ontotrace(taxon = "Ictalurus TT", entity = "fin", relation = "other relation") err2 <- function() pk_ontotrace(taxon = c("Ictalurus", "Ameiurus XXX"), entity = c("fin", "spine")) err3 <- function() pk_ontotrace("Ictalurus TT", "fin") - expect_output(str(single), "data.frame") - expect_output(str(multi), "data.frame") - expect_output(str(rel), "data.frame") + expect_output(str(single), "Classes ‘tbl_df’, ‘tbl’ and 'data.frame'") + expect_output(str(multi), "Classes ‘tbl_df’, ‘tbl’ and 'data.frame'") + expect_output(str(rel), "Classes ‘tbl_df’, ‘tbl’ and 'data.frame'") + + expect_output(str(single1), "List of 2") expect_equal(all(apply(single[,-1], 2, is.numeric)), TRUE) expect_equal(all(apply(multi[,-1], 2, is.numeric)), TRUE)