ourMELONS/R/greedyMix.R

32 lines
1.1 KiB
R
Raw Normal View History

2020-05-20 15:34:40 +02:00
#' @title Clustering of individuals
#' @param data data file
2021-09-03 12:50:11 +02:00
#' @param format Format of the data c("FASTA", "VCF" ,"BAM", or "GenePop")
#' @param verbose if \code{TRUE}, prints extra output information
2020-06-24 11:48:23 +02:00
#' @importFrom utils read.delim
2021-09-03 11:17:00 +02:00
#' @importFrom vcfR read.vcfR
2021-09-03 12:50:11 +02:00
#' @references Samtools: a suite of programs for interacting
#' with high-throughput sequencing data. <http://www.htslib.org/>
2020-05-20 15:34:40 +02:00
#' @export
greedyMix <- function(data, format, verbose = TRUE) {
format <- tolower(format)
if (format == "fasta") {
out <- load_fasta(data)
} else if (format == "vcf") {
out <- vcfR::read.vcfR(data, verbose = verbose)
} else if (format == "sam") {
2021-09-03 12:50:11 +02:00
stop(
"SAM files not directly supported. ",
"Install the samtools software and execute ",
"'samtools view -b in_file.sam > out_file.bam' to convert to BAM ",
"and try running this function again with 'format=BAM'"
)
} else if (format == "bam") {
out <- Rsamtools::scanBam(data)
} else if (format == "genepop") {
2021-09-03 09:14:52 +02:00
# TODO #19: implement load_genepop()
stop("GenePop files not yet supported." )
} else {
stop("Format not supported.")
}
return(out)
}