From 3537f18d2ccaefa1c5ed551802fbe24d35e71f7c Mon Sep 17 00:00:00 2001 From: Waldir Leoncio Date: Fri, 11 Aug 2023 11:18:03 +0200 Subject: [PATCH] Incorporated handleData() on greedyMix() (#25) --- R/greedyMix.R | 30 ++++++++++++++---------------- man/greedyMix.Rd | 15 ++++++--------- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/R/greedyMix.R b/R/greedyMix.R index 6715145..1826d50 100644 --- a/R/greedyMix.R +++ b/R/greedyMix.R @@ -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) diff --git a/man/greedyMix.Rd b/man/greedyMix.Rd index 74242b8..dc26245 100644 --- a/man/greedyMix.Rd +++ b/man/greedyMix.Rd @@ -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