Aligned processing of Genepop with MATLAB code

This commit is contained in:
Waldir Leoncio 2024-09-13 13:53:01 +02:00
parent 31575a5b9e
commit 9e554d5d4b

View file

@ -27,6 +27,7 @@ greedyMix <- function(
inp = NULL, popnames = NULL, fixedK = FALSE, verbose = FALSE inp = NULL, popnames = NULL, fixedK = FALSE, verbose = FALSE
) { ) {
# Importing and handling data ================================================ # Importing and handling data ================================================
# TODO: use format as class and make handling data a generic
if (tolower(format) %in% "fasta") { if (tolower(format) %in% "fasta") {
data <- convert_FASTA_to_BAPS(data) data <- convert_FASTA_to_BAPS(data)
format <- "baps" format <- "baps"
@ -42,6 +43,17 @@ greedyMix <- function(
Z = data[["Z"]], Z = data[["Z"]],
dist = data[["dist"]] 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 { } else {
data <- importFile(data, format, verbose) data <- importFile(data, format, verbose)
data <- handleData(data, tolower(format)) data <- handleData(data, tolower(format))
@ -68,7 +80,7 @@ greedyMix <- function(
# Generating partition summary =============================================== # Generating partition summary ===============================================
ekat <- seq(1L, ninds * c[["rowsFromInd"]], c[["rowsFromInd"]]) ekat <- seq(1L, ninds * c[["rowsFromInd"]], c[["rowsFromInd"]])
c[["rows"]] <- cbind(ekat, ekat + c[["rowsFromInd"]] - 1L) 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"]] logml <- logml_npops_partitionSummary[["logml"]]
npops <- logml_npops_partitionSummary[["npops"]] npops <- logml_npops_partitionSummary[["npops"]]
partitionSummary <- logml_npops_partitionSummary[["partitionSummary"]] partitionSummary <- logml_npops_partitionSummary[["partitionSummary"]]