Merge branch 'testaaGenePopData' into dev
This commit is contained in:
commit
16ecea429c
11 changed files with 134 additions and 54 deletions
|
|
@ -21,14 +21,18 @@ export(questdlg)
|
|||
export(rand)
|
||||
export(randdir)
|
||||
export(repmat)
|
||||
export(rivinSisaltamienMjonojenLkm)
|
||||
export(simulateAllFreqs)
|
||||
export(simulateIndividuals)
|
||||
export(simuloiAlleeli)
|
||||
export(size)
|
||||
export(strcmp)
|
||||
export(suoritaMuutos)
|
||||
export(testaaOnkoKunnollinenBapsData)
|
||||
export(testaaPop)
|
||||
export(times)
|
||||
export(uigetfile)
|
||||
export(uiputfile)
|
||||
importFrom(methods,is)
|
||||
importFrom(stats,runif)
|
||||
importFrom(utils,read.delim)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
#' @title Clustering of individuals
|
||||
#' @param tietue Record
|
||||
#' @param tietue File
|
||||
#' @param format Format of the data ("BAPS", "GenePop" or "Preprocessed")
|
||||
#' @param savePreProcessed Save the pre-processed data?
|
||||
#' @param filePreProcessed Is the file already processed?
|
||||
#' @importFrom utils read.delim
|
||||
#' @export
|
||||
greedyMix <- function(
|
||||
tietue,
|
||||
|
|
@ -51,7 +53,9 @@ greedyMix <- function(
|
|||
stop('Invalid alternative')
|
||||
} else if (input_type_name == 'BAPS-format') {
|
||||
if (!is(tietue, "character")) {
|
||||
pathname_filename <- uigetfile("*.txt", "Loaddata in BAPS-format")
|
||||
pathname_filename <- uigetfile(
|
||||
"*.txt", "Load data in BAPS-format"
|
||||
)
|
||||
} else {
|
||||
pathname_filename <- tietue
|
||||
}
|
||||
|
|
@ -62,8 +66,8 @@ greedyMix <- function(
|
|||
# end
|
||||
|
||||
data <- read.delim(pathname_filename) # ASK: what is the delimiter?
|
||||
# ninds <- testaaOnkoKunnollinenBapsData(data) #TESTAUS # TODO: trans
|
||||
# if (ninds == 0) stop('Incorrect Data-file')
|
||||
ninds <- testaaOnkoKunnollinenBapsData(data) # testing
|
||||
if (ninds == 0) stop('Incorrect Data-file')
|
||||
|
||||
# ASK: remove?
|
||||
# h0 = findobj('Tag','filename1_text');
|
||||
|
|
@ -1542,30 +1546,6 @@ greedyMix <- function(
|
|||
|
||||
# %-------------------------------------------------------
|
||||
|
||||
# function pal = testaaPop(rivi)
|
||||
# % pal=1, mik<69>li rivi alkaa jollain seuraavista
|
||||
# % kirjainyhdistelmist? Pop, pop, POP. Kaikissa muissa
|
||||
# % tapauksissa pal=0.
|
||||
|
||||
# if length(rivi)<3
|
||||
# pal = 0;
|
||||
# return
|
||||
# end
|
||||
# if (all(rivi(1:3)=='Pop') | ...
|
||||
# all(rivi(1:3)=='pop') | ...
|
||||
# all(rivi(1:3)=='POP'))
|
||||
# pal = 1;
|
||||
# return
|
||||
# else
|
||||
# pal = 0;
|
||||
# return
|
||||
# end
|
||||
|
||||
|
||||
|
||||
# %----------------------------------------------------------------------------
|
||||
|
||||
|
||||
# function dist2 = laskeOsaDist(inds2, dist, ninds)
|
||||
# % Muodostaa dist vektorista osavektorin, joka sis<69>lt<6C><74> yksil<69>iden inds2
|
||||
# % v<>liset et<65>isyydet. ninds=kaikkien yksil<69>iden lukum<75><6D>r?
|
||||
|
|
@ -1706,30 +1686,6 @@ greedyMix <- function(
|
|||
|
||||
# %------------------------------------------------------
|
||||
|
||||
|
||||
# function count = rivinSisaltamienMjonojenLkm(line)
|
||||
# % Palauttaa line:n sis<69>lt<6C>mien mjonojen lukum<75><6D>r<EFBFBD>n.
|
||||
# % Mjonojen v<>liss?t<>ytyy olla v<>lily<6C>nti.
|
||||
# count = 0;
|
||||
# pit = length(line);
|
||||
# tila = 0; %0, jos odotetaan v<>lily<6C>ntej? 1 jos odotetaan muita merkkej?
|
||||
# for i=1:pit
|
||||
# merkki = line(i);
|
||||
# if (isspace(merkki) & tila==0)
|
||||
# %Ei tehd?mit<69><74>n.
|
||||
# elseif (isspace(merkki) & tila==1)
|
||||
# tila = 0;
|
||||
# elseif (~isspace(merkki) & tila==0)
|
||||
# tila = 1;
|
||||
# count = count+1;
|
||||
# elseif (~isspace(merkki) & tila==1)
|
||||
# %Ei tehd?mit<69><74>n
|
||||
# end
|
||||
# end
|
||||
|
||||
|
||||
# %-------------------------------------------------------
|
||||
|
||||
# function nimi = lueNimi(line)
|
||||
# %Palauttaa line:n alusta sen osan, joka on ennen pilkkua.
|
||||
# n = 1;
|
||||
|
|
|
|||
25
R/rivinSisaltamienMjonojenLkm.R
Normal file
25
R/rivinSisaltamienMjonojenLkm.R
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#' @title Number of M queues
|
||||
#' @param line line number
|
||||
#' @return count
|
||||
#' @export
|
||||
rivinSisaltamienMjonojenLkm <- function(line) {
|
||||
# Palauttaa line:n sis<69>lt<6C>mien mjonojen lukum<75><6D>r<EFBFBD>n.
|
||||
# Mjonojen v<>liss?t<>ytyy olla v<>lily<6C>nti.
|
||||
count <- 0
|
||||
pit <- length(line)
|
||||
tila <- 0 # 0, jos odotetaan v<>lily<6C>ntej? 1 jos odotetaan muita merkkej?
|
||||
for (i in seq_len(pit)) {
|
||||
merkki <- line[i]
|
||||
if (merkki == " " & tila == 0) {
|
||||
# Ei tehd?mit<69><74>n.
|
||||
} else if (merkki == " " & tila == 1) {
|
||||
tila <- 0
|
||||
} else if (merkki != " " & tila == 0) {
|
||||
tila <- 1
|
||||
count <- count + 1
|
||||
} else if (merkki != " " & tila == 1) {
|
||||
# %Ei tehd?mit<69><74>n
|
||||
}
|
||||
}
|
||||
return(count)
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
#' @title Tests GenePop data
|
||||
#' @param tiedostonNimi Filename
|
||||
testaaGenePopData <- function(tiedostonNimi) {
|
||||
# kunnossa == 0, jos data ei ole kelvollinen genePop data.
|
||||
# Muussa tapauksessa kunnossa == 1.
|
||||
|
|
@ -16,7 +17,7 @@ testaaGenePopData <- function(tiedostonNimi) {
|
|||
if (line1 == -1 | line2 == -1 | line3 == -1) {
|
||||
stop('Incorrect file format 1168')
|
||||
}
|
||||
if (testaaPop(line1) == 1 | testaaPop(line2) == 1) { # TODO: translate function
|
||||
if (testaaPop(line1) == 1 | testaaPop(line2) == 1) {
|
||||
stop('Incorrect file format 1172')
|
||||
}
|
||||
if (testaaPop(line3) == 1) {
|
||||
|
|
|
|||
27
R/testaaPop.R
Normal file
27
R/testaaPop.R
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#' @title Test population
|
||||
#' @description Test a line in the population
|
||||
#' @param rivi Line
|
||||
#' @return pal
|
||||
#' @export
|
||||
testaaPop <- function(rivi) {
|
||||
# pal=1, mik<69>li rivi alkaa jollain seuraavista
|
||||
# kirjainyhdistelmist? Pop, pop, POP. Kaikissa muissa
|
||||
# tapauksissa pal=0.
|
||||
|
||||
if (length(rivi) < 3) {
|
||||
pal <- 0
|
||||
return(pal)
|
||||
}
|
||||
if (
|
||||
all(rivi[1:3] == 'Pop') |
|
||||
all(rivi[1:3] == 'pop') |
|
||||
all(rivi(1:3)=='POP')
|
||||
) {
|
||||
pal <- 1
|
||||
return(pal)
|
||||
} else {
|
||||
pal <- 0;
|
||||
return(pal)
|
||||
}
|
||||
return(pal)
|
||||
}
|
||||
|
|
@ -12,11 +12,13 @@ greedyMix(
|
|||
)
|
||||
}
|
||||
\arguments{
|
||||
\item{tietue}{Record}
|
||||
\item{tietue}{File}
|
||||
|
||||
\item{format}{Format of the data ("BAPS", "GenePop" or "Preprocessed")}
|
||||
|
||||
\item{savePreProcessed}{Save the pre-processed data?}
|
||||
|
||||
\item{filePreProcessed}{Is the file already processed?}
|
||||
}
|
||||
\description{
|
||||
Clustering of individuals
|
||||
|
|
|
|||
17
man/rivinSisaltamienMjonojenLkm.Rd
Normal file
17
man/rivinSisaltamienMjonojenLkm.Rd
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/rivinSisaltamienMjonojenLkm.R
|
||||
\name{rivinSisaltamienMjonojenLkm}
|
||||
\alias{rivinSisaltamienMjonojenLkm}
|
||||
\title{Number of M queues}
|
||||
\usage{
|
||||
rivinSisaltamienMjonojenLkm(line)
|
||||
}
|
||||
\arguments{
|
||||
\item{line}{line number}
|
||||
}
|
||||
\value{
|
||||
count
|
||||
}
|
||||
\description{
|
||||
Number of M queues
|
||||
}
|
||||
|
|
@ -6,6 +6,9 @@
|
|||
\usage{
|
||||
testaaGenePopData(tiedostonNimi)
|
||||
}
|
||||
\arguments{
|
||||
\item{tiedostonNimi}{Filename}
|
||||
}
|
||||
\description{
|
||||
Tests GenePop data
|
||||
}
|
||||
|
|
|
|||
17
man/testaaOnkoKunnollinenBapsData.Rd
Normal file
17
man/testaaOnkoKunnollinenBapsData.Rd
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/testaaOnkoKunnollinenBapsData.R
|
||||
\name{testaaOnkoKunnollinenBapsData}
|
||||
\alias{testaaOnkoKunnollinenBapsData}
|
||||
\title{TestBAPS data}
|
||||
\usage{
|
||||
testaaOnkoKunnollinenBapsData(data)
|
||||
}
|
||||
\arguments{
|
||||
\item{data}{dataset}
|
||||
}
|
||||
\value{
|
||||
ninds
|
||||
}
|
||||
\description{
|
||||
Test if loaded BAPS data is proper
|
||||
}
|
||||
17
man/testaaPop.Rd
Normal file
17
man/testaaPop.Rd
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/testaaPop.R
|
||||
\name{testaaPop}
|
||||
\alias{testaaPop}
|
||||
\title{Test population}
|
||||
\usage{
|
||||
testaaPop(rivi)
|
||||
}
|
||||
\arguments{
|
||||
\item{rivi}{Line}
|
||||
}
|
||||
\value{
|
||||
pal
|
||||
}
|
||||
\description{
|
||||
Test a line in the population
|
||||
}
|
||||
11
tests/testthat/test.greedyMix.R
Normal file
11
tests/testthat/test.greedyMix.R
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# library(devtools)#TEMP
|
||||
# library(testthat)#TEMP
|
||||
# library(rBAPS)#TEMP
|
||||
|
||||
context("Opening files on greedyMix")
|
||||
|
||||
# greedyMix(
|
||||
# tietue = "data/ExamplesDataFormatting/Example baseline data in GENEPOP format for Trained clustering.txt",
|
||||
# format = "GenePop",
|
||||
# savePreProcessed = FALSE
|
||||
# )
|
||||
Loading…
Add table
Reference in a new issue