diff --git a/R/greedyMix.R b/R/greedyMix.R index 058df21..ab2928e 100644 --- a/R/greedyMix.R +++ b/R/greedyMix.R @@ -68,19 +68,19 @@ greedyMix <- function( # fprintf(1,'Data: %s\n',[pathname filename]); # end - data <- read.delim(pathname_filename) # TODO: discover delimiter + data <- read.delim(pathname_filename, header = FALSE, sep = " ") ninds <- testaaOnkoKunnollinenBapsData(data) # testing if (ninds == 0) stop('Incorrect Data-file') # ASK: remove? # h0 = findobj('Tag','filename1_text'); # set(h0,'String',filename); clear h0; - cat( + message( 'When using data which are in BAPS-format,', 'you can specify the sampling populations of the', 'individuals by giving two additional files:', 'one containing the names of the populations,', - 'the other containing the indices of the first', + 'the other containing the indices of the first ', 'individuals of the populations.' ) input_pops <- inputdlg( diff --git a/R/testaaOnkoKunnollinenBapsData.R b/R/testaaOnkoKunnollinenBapsData.R index 8cdc5f3..0bf5c61 100644 --- a/R/testaaOnkoKunnollinenBapsData.R +++ b/R/testaaOnkoKunnollinenBapsData.R @@ -7,13 +7,13 @@ testaaOnkoKunnollinenBapsData <- function(data) { # Tarkastaa onko viimeisess?sarakkeessa kaikki # luvut 1,2,...,n johonkin n:��n asti. # Tarkastaa lis�ksi, ett?on v�hint��n 2 saraketta. - if (size[data, 1] < 2) { + if (size(data, 1) < 2) { ninds <- 0 return(ninds) } lastCol <- data[, ncol(data)] ninds <- max(lastCol) - if (t(1:ninds) != unique(lastCol)) { + if (any(1:ninds != unique(lastCol))) { ninds <- 0 return(ninds) } diff --git a/tests/testthat/test-greedyMix.R b/tests/testthat/test-greedyMix.R index 21a5d6d..b833456 100644 --- a/tests/testthat/test-greedyMix.R +++ b/tests/testthat/test-greedyMix.R @@ -2,8 +2,8 @@ context("Opening files on greedyMix") # TODO: needs #12 to be fixed before this can be done without user intervention greedyMix( - tietue = "inst/ext/ExamplesDataFormatting/Example baseline data in GENEPOP format for Trained clustering.txt", - format = "GenePop", + tietue = "inst/ext/ExamplesDataFormatting/Example data in BAPS format for clustering of diploid individuals.txt", + format = "BAPS", savePreProcessed = FALSE ) # Upper bounds 100 100