Incorporated handleData() on greedyMix() (#25)

This commit is contained in:
Waldir Leoncio 2023-08-11 11:18:03 +02:00
parent f47e13d3a9
commit 3537f18d2c
2 changed files with 20 additions and 25 deletions

View file

@ -27,28 +27,26 @@
#' data <- system.file("extdata", "FASTA_clustering_haploid.fasta", package = "rBAPS")
#' greedyMix(data, "fasta")
greedyMix <- function(
data, format, partitionCompare = NULL, ninds = NULL, rowsFromInd = NULL,
noalle = NULL, adjprior = NULL, npops = 1L, priorTerm = NULL, counts = NULL,
sumcounts = NULL, max_iter = 100L, alleleCodes = NULL, inp = NULL,
popnames = NULL, fixedK = FALSE, verbose = FALSE
data, format, partitionCompare = NULL, ninds = NULL, npops = 1L,
counts = NULL, sumcounts = NULL, max_iter = 100L, alleleCodes = NULL,
inp = NULL, popnames = NULL, fixedK = FALSE, verbose = FALSE
) {
# Importing and handling data ================================================
data <- importFile(data, format, verbose)
data <- handleData(data, tolower(format))
c <- list(
# TODO: get elements from handleData()?
noalle = noalle,
rows = NA,
data = data,
adjprior = adjprior,
priorTerm = priorTerm,
rowsFromInd = rowsFromInd
noalle = data[["noalle"]],
data = data[["newData"]],
adjprior = data[["adjprior"]],
priorTerm = data[["priorTerm"]],
rowsFromInd = data[["rowsFromInd"]]
)
# Comparing partitions =======================================================
if (!is.null(partitionCompare)) {
logmls <- comparePartitions(
data, nrow(data), partitionCompare[["partitions"]], ninds, rowsFromInd,
noalle, adjprior
c[["data"]], nrow(c[["data"]]), partitionCompare[["partitions"]], ninds,
c[["rowsFromInd"]], c[["noalle"]], c[["adjprior"]]
)
}
@ -61,9 +59,9 @@ greedyMix <- function(
# Generating output object ===================================================
out <- list(
"alleleCodes" = alleleCodes, "adjprior" = adjprior, "popnames" = popnames,
"rowsFromInd" = rowsFromInd, "data" = data, "npops" = npops,
"noalle" = noalle, "mixtureType" = "mix", "logml" = logml
"alleleCodes" = alleleCodes, "adjprior" = c[["adjprior"]], "popnames" = popnames,
"rowsFromInd" = c[["rowsFromInd"]], "data" = data, "npops" = npops,
"noalle" = c[["noalle"]], "mixtureType" = "mix", "logml" = logml
)
if (logml == 1) {
return(out)

View file

@ -9,9 +9,6 @@ greedyMix(
format,
partitionCompare = NULL,
ninds = NULL,
rowsFromInd = NULL,
noalle = NULL,
adjprior = NULL,
npops = 1L,
priorTerm = NULL,
counts = NULL,
@ -33,12 +30,6 @@ greedyMix(
\item{ninds}{number of individuals}
\item{rowsFromInd}{a list of rows for each individual}
\item{noalle}{number of alleles}
\item{adjprior}{ajuster prior probabilities}
\item{npops}{number of populations}
\item{priorTerm}{prior terms}
@ -58,6 +49,12 @@ greedyMix(
\item{fixedK}{if \code{TRUE}, the number of populations is fixed}
\item{verbose}{if \code{TRUE}, prints extra output information}
\item{rowsFromInd}{a list of rows for each individual}
\item{noalle}{number of alleles}
\item{adjprior}{ajuster prior probabilities}
}
\description{
Clustering of individuals