From ae5837220512489107fa7316ae144307c4dbaec2 Mon Sep 17 00:00:00 2001 From: Waldir Leoncio Date: Fri, 26 Feb 2021 10:01:01 +0100 Subject: [PATCH 1/5] Changed dataset used for testing greedyMix --- tests/testthat/test-greedyMix.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-greedyMix.R b/tests/testthat/test-greedyMix.R index 21a5d6d..ae80496 100644 --- a/tests/testthat/test-greedyMix.R +++ b/tests/testthat/test-greedyMix.R @@ -2,7 +2,7 @@ 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", + tietue = "inst/ext/ExamplesDataFormatting/Example data in BAPS format for clustering of diploid individuals.txt", format = "GenePop", savePreProcessed = FALSE ) # Upper bounds 100 100 From f70277cd6a3790e44ff572a87ac273f88f83f50a Mon Sep 17 00:00:00 2001 From: Waldir Leoncio Date: Tue, 30 Mar 2021 08:22:24 +0200 Subject: [PATCH 2/5] Fixed delimiter for BAPS-formatted file --- R/greedyMix.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/greedyMix.R b/R/greedyMix.R index 058df21..ca38551 100644 --- a/R/greedyMix.R +++ b/R/greedyMix.R @@ -68,7 +68,7 @@ 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') From 76861c9027300b3915a0fdaca27a43ecda5e1c15 Mon Sep 17 00:00:00 2001 From: Waldir Leoncio Date: Tue, 30 Mar 2021 08:23:07 +0200 Subject: [PATCH 3/5] Fixed BAPS format in test unit --- tests/testthat/test-greedyMix.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-greedyMix.R b/tests/testthat/test-greedyMix.R index ae80496..b833456 100644 --- a/tests/testthat/test-greedyMix.R +++ b/tests/testthat/test-greedyMix.R @@ -3,7 +3,7 @@ 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 data in BAPS format for clustering of diploid individuals.txt", - format = "GenePop", + format = "BAPS", savePreProcessed = FALSE ) # Upper bounds 100 100 From 231e0ff501dd195e3aae7ae829ca69ffe0894742 Mon Sep 17 00:00:00 2001 From: Waldir Leoncio Date: Tue, 30 Mar 2021 08:23:21 +0200 Subject: [PATCH 4/5] Fixed syntax --- R/testaaOnkoKunnollinenBapsData.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) } From c7720f33b4f18ad34483d46f24a9e1dda8bdad2e Mon Sep 17 00:00:00 2001 From: Waldir Leoncio Date: Tue, 30 Mar 2021 08:23:37 +0200 Subject: [PATCH 5/5] Fixed output formatting --- R/greedyMix.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/greedyMix.R b/R/greedyMix.R index ca38551..ab2928e 100644 --- a/R/greedyMix.R +++ b/R/greedyMix.R @@ -75,12 +75,12 @@ greedyMix <- function( # 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(