Merge branch 'issue-15' into develop
This commit is contained in:
commit
75df74cb2c
4 changed files with 45 additions and 19 deletions
|
|
@ -12,7 +12,7 @@
|
||||||
#' msa <- system.file("ext", "seqs.fa", package="rBAPS")
|
#' msa <- system.file("ext", "seqs.fa", package="rBAPS")
|
||||||
#' snp.matrix <- load_fasta(msa)
|
#' snp.matrix <- load_fasta(msa)
|
||||||
#'
|
#'
|
||||||
#' @author Gerry Tonkin-Hill
|
#' @author Gerry Tonkin-Hill, Waldir Leoncio
|
||||||
#' @seealso rhierbaps::load_fasta
|
#' @seealso rhierbaps::load_fasta
|
||||||
#' @importFrom ape read.FASTA as.DNAbin
|
#' @importFrom ape read.FASTA as.DNAbin
|
||||||
#' @export
|
#' @export
|
||||||
|
|
@ -37,8 +37,11 @@ load_fasta <- function(msa, keep.singletons=FALSE) {
|
||||||
rownames(seqs) <- seq_names
|
rownames(seqs) <- seq_names
|
||||||
seqs[is.na(seqs)] <- "-"
|
seqs[is.na(seqs)] <- "-"
|
||||||
|
|
||||||
if (nrow(seqs)<3) stop("Less than 3 sequences!")
|
# Validation -----------------------------------------------------------------
|
||||||
warning("Characters not in acgtnACGTN- will be treated as missing (-)...")
|
if (nrow(seqs) < 3) stop("Less than 3 sequences!")
|
||||||
|
if (any(!(as.vector(tolower(seqs)) %in% c("a", "c", "g", "t", "n", "-")))) {
|
||||||
|
warning("Characters not in acgtnACGTN- will be treated as missing (-)...")
|
||||||
|
}
|
||||||
|
|
||||||
#Remove conserved columns
|
#Remove conserved columns
|
||||||
conserved <- colSums(t(t(seqs)==seqs[1,]))==nrow(seqs)
|
conserved <- colSums(t(t(seqs)==seqs[1,]))==nrow(seqs)
|
||||||
|
|
|
||||||
20
inst/ext/FASTA_clustering_haploid.fasta
Normal file
20
inst/ext/FASTA_clustering_haploid.fasta
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
>1
|
||||||
|
AACGAAACGATCGCGTCACCGGAACGTTGTCCGTCTCGAATAGCACTGTGGGAACGTGTTTTACATTCGT
|
||||||
|
TAGTAACATGGTCAGCTGCTCATCCGTATT
|
||||||
|
|
||||||
|
>2
|
||||||
|
ATCAGCAAACGAGAAGTTGCAGAGGTCTTTGGTTTGAGCATTGCCCCCATACAATCGACTTCTGGCCTGG
|
||||||
|
AATGCACCACAAACATACCCCACAGGCTCG
|
||||||
|
|
||||||
|
>3
|
||||||
|
GCTTTTACTAAGGCCTATCGGATTCAACGTCACTAAGACTCGGCACTAACAGGCCGTTGTAAGCCGCTCT
|
||||||
|
GTCTGAGTATGGATGGTGGAGGCGGAGCCG
|
||||||
|
|
||||||
|
>4
|
||||||
|
ACCTGGACCTCTGTATTAACGGCTGTGATTCTGAGGGGGGTATCGCAGCGCACTTTCTAGCTATATCACG
|
||||||
|
CAAGGATAAAGTTCACCCATCACGTTGACC
|
||||||
|
|
||||||
|
>5
|
||||||
|
ACAATACGTCATCCACACCGCGCCTATGGAAGAATTTGCCCTTTCGGCGACAGCCCATGCTGTCAAGGAG
|
||||||
|
GTAACATAGCTACCAGGTCCCATTCCAGGA
|
||||||
|
|
||||||
|
|
@ -27,5 +27,5 @@ snp.matrix <- load_fasta(msa)
|
||||||
rhierbaps::load_fasta
|
rhierbaps::load_fasta
|
||||||
}
|
}
|
||||||
\author{
|
\author{
|
||||||
Gerry Tonkin-Hill
|
Gerry Tonkin-Hill, Waldir Leoncio
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
context("Auxiliary functions to greedyMix")
|
context("Auxiliary functions to greedyMix")
|
||||||
|
|
||||||
# Defining the relative path to current inst ------------- #
|
# Defining the relative path to current inst -----------------------------------
|
||||||
if (interactive()) {
|
if (interactive()) {
|
||||||
path_inst <- "../../inst/ext/BAPS_format_clustering_diploid.txt"
|
path_inst <- "../../inst/ext"
|
||||||
} else {
|
} else {
|
||||||
path_inst <- system.file(
|
path_inst <- system.file("ext", "", package="rBAPS")
|
||||||
"ext", "BAPS_format_clustering_diploid.txt", package="rBAPS"
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Reading datasets -------------------------------------------------------------
|
||||||
baps_diploid <- read.delim(
|
baps_diploid <- read.delim(
|
||||||
file = path_inst,
|
file = paste(path_inst, "BAPS_format_clustering_diploid.txt", sep="/"),
|
||||||
sep = " ",
|
sep = " ",
|
||||||
header = FALSE
|
header = FALSE
|
||||||
)
|
)
|
||||||
|
|
@ -35,15 +35,18 @@ test_that("handleData works as expected", {
|
||||||
expect_equal(data_obs, data_exp)
|
expect_equal(data_obs, data_exp)
|
||||||
})
|
})
|
||||||
|
|
||||||
context("Opening files on greedyMix/load_fasta")
|
context("Opening files on greedyMix")
|
||||||
|
|
||||||
# # TODO: needs #12 to be fixed before this can be done without user intervention
|
df_fasta <- greedyMix(
|
||||||
# greedyMix(
|
data = paste(path_inst, "FASTA_clustering_haploid.fasta", sep="/"),
|
||||||
# tietue = "inst/ext/ExamplesDataFormatting/Example data in BAPS format for clustering of diploid individuals.txt",
|
format ="fasta"
|
||||||
# format = "BAPS",
|
)
|
||||||
# savePreProcessed = FALSE
|
# TODO: add example reading VCF
|
||||||
# ) # Upper bounds 100 100
|
# TODO: add example reading SAM
|
||||||
# TODO #16: replace with load_fasta()
|
# TODO: add example reading Genpop
|
||||||
|
test_that("Files are imported correctly", {
|
||||||
|
expect_equal(dim(df_fasta), c(5, 99))
|
||||||
|
})
|
||||||
|
|
||||||
context("Linkage")
|
context("Linkage")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue