diff --git a/DESCRIPTION b/DESCRIPTION index f778594..61944ad 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: assigner Type: Package Title: Assignment Analysis with GBS/RADseq Data using R -Version: 0.2.2 -Date: 2016-04-15 +Version: 0.2.3 +Date: 2016-04-23 Encoding: UTF-8 Authors@R: c( person("Thierry", "Gosselin", email = "thierrygosselin@icloud.com", role = c("aut", "cre"))) diff --git a/NAMESPACE b/NAMESPACE index 0b78f5d..873d1bf 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -5,6 +5,7 @@ export(assignment_mixture) export(assignment_ngs) export(dlr) export(gsi_sim_binary) +export(import_subsamples) export(install_gsi_sim) export(plot_assignment) export(plot_assignment_dlr) diff --git a/R/assignment_ngs.R b/R/assignment_ngs.R index 9dc8486..cbd4ae7 100644 --- a/R/assignment_ngs.R +++ b/R/assignment_ngs.R @@ -2211,7 +2211,7 @@ package and update your whitelist") METHOD = rep(sampling.method, n()), MISSING_DATA = rep(missing.data, n()) ) %>% - select(INDIVIDUALS, ANALYSIS, CURRENT, INFERRED, SCORE, SECOND_BEST_POP, SECOND_BEST_SCORE, MARKER_NUMBER, METHOD, MISSING_DATA) %>% + select(INDIVIDUALS, CURRENT, INFERRED, SCORE, SECOND_BEST_POP, SECOND_BEST_SCORE, MARKER_NUMBER, METHOD, MISSING_DATA) %>% arrange(CURRENT) ) } diff --git a/R/import_subsamples.R b/R/import_subsamples.R new file mode 100644 index 0000000..15d2d57 --- /dev/null +++ b/R/import_subsamples.R @@ -0,0 +1,46 @@ +# Write a dataframe containing all the subsample individual assignment + +#' @name import_subsamples +#' @title Import individual's assignment results of different subsample folder. +#' @description This function will import all the individual's assignment results +#' of different subsample folder into R. +#' @param dir.path The path to the directory containing the subsample folders. +#' @param imputations (logical) Was the data imputed or not. +#' Default: \code{imputations = FALSE} +#' @return A data frame of all the individual's assignment, with iterations and subsample. + +#' @export +#' @rdname import_subsamples +#' @import dplyr +#' @import stringi + + +#' @examples +#' \dontrun{ +#' subsamples.data <- import_subsamples( +#' dir.path = "assignment_analysis_method_random_imputations_rf_populations", +#' imputations = TRUE +#' ) +#' } + +#' @author Thierry Gosselin \email{thierrygosselin@@icloud.com} + +import_subsamples <- function(dir.path, imputations){ + if (missing (dir.path)) stop("dir.path argument missing") + if (missing (imputations)) imputations <- FALSE + + subsample.folders <- list.files(path = dir.path, pattern = "subsample_", full.names = FALSE) + data <- list() + for (i in subsample.folders) { + sub.name <- stri_replace_all_fixed(str = i, pattern = "_", replacement = ".", vectorize_all = FALSE) + if (imputations == TRUE){ + filename <- stri_paste(i, "/","assignment.random.imputed.results.individuals.iterations.", sub.name, ".tsv") + } else { + filename <- stri_paste(i, "/","assignment.random.no.imputation.results.individuals.iterations.", sub.name, ".tsv") + } + subsample.data <- read_tsv(file = filename, col_names = TRUE) #%>% filter (MISSING_DATA == 'no.imputation') + data[[i]] <- subsample.data + } + data <- as_data_frame(bind_rows(data)) + return(data) +} diff --git a/README.md b/README.md index bb50ece..ea62589 100644 --- a/README.md +++ b/README.md @@ -140,6 +140,9 @@ The Amazon image can be imported into Google Cloud Compute Engine to start a new ## New +**v.0.2.3** +* bug fixed in the compilation results section when no pop.id.start and end are used. + **v.0.2.1** * updated the function `assignment_mixture` with `sampling.method = "ranked"` and `assignment.analysis = "adegenet"`. diff --git a/inst/CITATION b/inst/CITATION index f4a3051..bc0ebf7 100644 --- a/inst/CITATION +++ b/inst/CITATION @@ -7,5 +7,5 @@ year = "2016", author = personList(as.person("Thierry Gosselin")), url = "https://github.com/thierrygosselin/stackr", doi = "http://dx.doi.org/10.5281/zenodo.46723", -textVersion = paste("Gosselin T (2016). assigner: Assignment Analysis with GBS/RAD Data using R. R package version 0.1.9. https://github.com/thierrygosselin/assigner. doi : 10.5281/zenodo.46723") +textVersion = paste("Gosselin T (2016). assigner: Assignment Analysis with GBS/RAD Data using R. R package version 0.2.3. https://github.com/thierrygosselin/assigner. doi : 10.5281/zenodo.47452") ) diff --git a/man/import_subsamples.Rd b/man/import_subsamples.Rd new file mode 100644 index 0000000..062cc79 --- /dev/null +++ b/man/import_subsamples.Rd @@ -0,0 +1,33 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/import_subsamples.R +\name{import_subsamples} +\alias{import_subsamples} +\title{Import individual's assignment results of different subsample folder.} +\usage{ +import_subsamples(dir.path, imputations) +} +\arguments{ +\item{dir.path}{The path to the directory containing the subsample folders.} + +\item{imputations}{(logical) Was the data imputed or not. +Default: \code{imputations = FALSE}} +} +\value{ +A data frame of all the individual's assignment, with iterations and subsample. +} +\description{ +This function will import all the individual's assignment results +of different subsample folder into R. +} +\examples{ +\dontrun{ +subsamples.data <- import_subsamples( +dir.path = "assignment_analysis_method_random_imputations_rf_populations", +imputations = TRUE +) +} +} +\author{ +Thierry Gosselin \email{thierrygosselin@icloud.com} +} +