From dd6ee912bd0bfffaf1cc3fbc982d5b77d2c05706 Mon Sep 17 00:00:00 2001 From: Waldir Leoncio Date: Fri, 27 Sep 2024 06:59:18 +0200 Subject: [PATCH] Syntax fixes --- R/greedyMix.R | 2 +- R/laskeMuutokset12345.R | 8 ++++---- R/laskeOsaDist.R | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/R/greedyMix.R b/R/greedyMix.R index cea602b..0ac6ff1 100644 --- a/R/greedyMix.R +++ b/R/greedyMix.R @@ -80,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, GenePop + logml_npops_partitionSummary <- indMixWrapper(c, npops, counts, sumcounts, max_iter, fixedK, verbose) # FIXME: not working for FASTA logml <- logml_npops_partitionSummary[["logml"]] npops <- logml_npops_partitionSummary[["npops"]] partitionSummary <- logml_npops_partitionSummary[["partitionSummary"]] diff --git a/R/laskeMuutokset12345.R b/R/laskeMuutokset12345.R index 78c9f5c..e940324 100644 --- a/R/laskeMuutokset12345.R +++ b/R/laskeMuutokset12345.R @@ -423,7 +423,7 @@ greedyMix_muutokset <- R6Class( globals$SUMCOUNTS[i1, ] <- globals$SUMCOUNTS[i1, ] + diffInSumCounts if (i1 < npops) { - i2 <- c(1:(i1 - 1), (i1 + 1):npops) + i2 <- c(seq_len(i1 - 1), (i1 + 1):npops) } else { i2 <- 1:(i1 - 1) } @@ -458,12 +458,12 @@ greedyMix_muutokset <- R6Class( muutokset <- zeros(npops2, npops) i1_logml <- globals$POP_LOGML[i1] - for (pop2 in 1:npops2) { + for (pop2 in seq_len(npops2)) { inds <- inds2[matlab2r::find(T2 == pop2)] ninds <- length(inds) if (ninds > 0) { rows <- list() - for (i in 1:ninds) { + for (i in seq_len(ninds)) { ind <- inds[i] lisa <- globalRows[ind, 1]:globalRows[ind, 2] rows <- c(rows, t(lisa)) @@ -480,7 +480,7 @@ greedyMix_muutokset <- R6Class( globals$SUMCOUNTS[i1, ] <- globals$SUMCOUNTS[i1, ] + diffInSumCounts if (i1 < npops) { - i2 <- c(1:(i1 - 1), (i1 + 1):npops) + i2 <- c(seq_len(i1 - 1), (i1 + 1):npops) } else { i2 <- 1:(i1 - 1) } diff --git a/R/laskeOsaDist.R b/R/laskeOsaDist.R index b6c8570..e915276 100644 --- a/R/laskeOsaDist.R +++ b/R/laskeOsaDist.R @@ -11,7 +11,7 @@ laskeOsaDist <- function(inds2, dist, ninds) { ninds2 <- length(inds2) apu <- zeros(choose(ninds2, 2), 2) rivi <- 1 - for (i in 1:(ninds2 - 1)) { + for (i in seq_len(ninds2 - 1)) { for (j in (i + 1):ninds2) { apu[rivi, 1] <- inds2[i] apu[rivi, 2] <- inds2[j] @@ -20,6 +20,6 @@ laskeOsaDist <- function(inds2, dist, ninds) { } apu <- (apu[, 1] - 1) * ninds - apu[, 1] / 2 * (apu[, 1] - 1) + (apu[, 2] - apu[, 1]) - dist2 <- dist(apu) + dist2 <- dist[apu] return(dist2) }