From 9e554d5d4bc12d348a30537ae082bd0b2896db8e Mon Sep 17 00:00:00 2001 From: Waldir Leoncio Date: Fri, 13 Sep 2024 13:53:01 +0200 Subject: [PATCH] Aligned processing of Genepop with MATLAB code --- R/greedyMix.R | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/R/greedyMix.R b/R/greedyMix.R index dd0d117..cea602b 100644 --- a/R/greedyMix.R +++ b/R/greedyMix.R @@ -27,6 +27,7 @@ greedyMix <- function( inp = NULL, popnames = NULL, fixedK = FALSE, verbose = FALSE ) { # Importing and handling data ================================================ + # TODO: use format as class and make handling data a generic if (tolower(format) %in% "fasta") { data <- convert_FASTA_to_BAPS(data) format <- "baps" @@ -42,6 +43,17 @@ greedyMix <- function( Z = data[["Z"]], dist = data[["dist"]] ) + } else if (tolower(format) %in% "genepop") { + data <- process_GenePop_data(data) + c <- list( + noalle = data[["noalle"]], + data = data[["data"]], + adjprior = data[["adjprior"]], + priorTerm = data[["priorTerm"]], + rowsFromInd = data[["rowsFromInd"]], + Z = data[["Z"]], + dist = data[["dist"]] + ) } else { data <- importFile(data, format, verbose) data <- handleData(data, tolower(format)) @@ -68,7 +80,7 @@ greedyMix <- function( # Generating partition summary =============================================== ekat <- seq(1L, ninds * c[["rowsFromInd"]], c[["rowsFromInd"]]) c[["rows"]] <- cbind(ekat, ekat + c[["rowsFromInd"]] - 1L) - logml_npops_partitionSummary <- indMixWrapper(c, npops, counts, sumcounts, max_iter, fixedK, verbose) # FIXME: not working for FASTA data + logml_npops_partitionSummary <- indMixWrapper(c, npops, counts, sumcounts, max_iter, fixedK, verbose) # FIXME: not working for FASTA, GenePop logml <- logml_npops_partitionSummary[["logml"]] npops <- logml_npops_partitionSummary[["npops"]] partitionSummary <- logml_npops_partitionSummary[["partitionSummary"]]