diff --git a/R/greedyMix.R b/R/greedyMix.R index 51e4e3d..b9e56f3 100644 --- a/R/greedyMix.R +++ b/R/greedyMix.R @@ -294,14 +294,15 @@ greedyMix <- function( data <- data[, seq_len(ncol(data) - 1)] # ASK: remove? - # h0 = findobj('Tag','filename1_text'); inp = get(h0,'String'); - # h0 = findobj('Tag','filename2_text'); + # h0 = findobj('Tag','filename1_text') + # inp = get(h0,'String'); + # h0 = findobj('Tag','filename2_text') # outp = get(h0,'String'); - # changesInLogml <- writeMixtureInfo( - # logml, rowsFromInd, data, adjprior, priorTerm, outp, inp, - # popnames, fixedK - # ) # TODO translate + changesInLogml <- writeMixtureInfo( + logml, rowsFromInd, data, adjprior, priorTerm, outp, inp, + popnames, fixedK + ) # FIXMEL depends on get function above # viewMixPartition(PARTITION, popnames) # ASK translate? On graph folder diff --git a/R/handleData.R b/R/handleData.R index d6a4611..40d39e7 100644 --- a/R/handleData.R +++ b/R/handleData.R @@ -53,12 +53,12 @@ handleData <- function(raw_data) { ) } - nind <- max(data[, end]) + nind <- max(data[, ncol(data)]) nrows <- size(data, 1) ncols <- size(data, 2) rowsFromInd <- zeros(nind, 1) for (i in 1:nind) { - rowsFromInd[i] <- length(find(data[, end] == i)) + rowsFromInd[i] <- length(find(data[, ncol(data)] == i)) } maxRowsFromInd <- max(rowsFromInd) a <- -999 @@ -81,7 +81,7 @@ handleData <- function(raw_data) { repmat(1 / noalle[j], c(noalle[j], 1)), ones(max(noalle) - noalle[j], 1) )) - priorTerm <- priorTerm + noalle[j] * gammaln(1 / noalle[j]) + priorTerm <- priorTerm + noalle[j] * lgamma(1 / noalle[j]) } out <- list( newData = newData, diff --git a/R/linkage.R b/R/linkage.R index 5c127fd..80d6b30 100644 --- a/R/linkage.R +++ b/R/linkage.R @@ -7,7 +7,7 @@ #' @param Y data #' @param method either 'si', 'av', 'co' 'ce' or 'wa' #' @export -linkage <- function(Y, method) { +linkage <- function(Y, method = 'co') { k <- size(Y)[1] n <- size(Y)[2] m <- (1 + sqrt(1 + 8 * n)) / 2 @@ -17,10 +17,7 @@ linkage <- function(Y, method) { 'of the PDIST function in size.' ) } - if (nargin == 1) { # set default switch to be 'co' - method <- 'co' - } - method <- lower(method[1:2]) # simplify the switch string. + method <- tolower(substr(method, 1, 2)) # simplify the switch string. monotonic <- 1 Z <- zeros(m - 1, 3) # allocate the output matrix. N <- zeros(1, 2 * m - 1) diff --git a/R/writeMixtureInfo.R b/R/writeMixtureInfo.R index 174781c..ca8efea 100644 --- a/R/writeMixtureInfo.R +++ b/R/writeMixtureInfo.R @@ -14,7 +14,6 @@ #' @param COUNTS COUNTS #' @param SUMCOUNTS SUMCOUNTS #' @param LOGDIFF LOGDIFF -#' @return changesInLogml #' @export writeMixtureInfo <- function( logml, rowsFromInd, data, adjprior, priorTerm, outPutFile, inputFile, partitionSummary, popnames, fixedK, PARTITION, COUNTS, SUMCOUNTS, @@ -100,7 +99,7 @@ writeMixtureInfo <- function( while (length(text) > 58) { # Take one line and display it. new_line <- takeLine(text, 58) - text <- (length(new_line) + 1):end + text <- (length(new_line) + 1):length(text) cat(new_line) if (fid != -1) { append(fid, new_line) @@ -228,7 +227,7 @@ writeMixtureInfo <- function( sum(dist2 * log2((dist2 + 10 ^ -10) / (dist1 + 10 ^ -10))) ) / nloci div <- (div12 + div21) / 2 - dist_mat(pop1, pop2) <- div + dist_mat[pop1, pop2] <- div } } diff --git a/man/linkage.Rd b/man/linkage.Rd index 57d5113..4f75835 100644 --- a/man/linkage.Rd +++ b/man/linkage.Rd @@ -4,7 +4,7 @@ \alias{linkage} \title{Linkage} \usage{ -linkage(Y, method) +linkage(Y, method = "co") } \arguments{ \item{Y}{data} diff --git a/man/writeMixtureInfo.Rd b/man/writeMixtureInfo.Rd index f9a1682..e973db9 100644 --- a/man/writeMixtureInfo.Rd +++ b/man/writeMixtureInfo.Rd @@ -50,9 +50,6 @@ writeMixtureInfo( \item{LOGDIFF}{LOGDIFF} } -\value{ -changesInLogml -} \description{ Writes information about the mixture }