Skip to content

Commit

Permalink
added conversion functs
Browse files Browse the repository at this point in the history
  • Loading branch information
knausb committed Sep 15, 2017
1 parent d27dcd8 commit 94687e4
Show file tree
Hide file tree
Showing 14 changed files with 140 additions and 83 deletions.
5 changes: 5 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export("%>%")
export(.CM_to_NM)
export(.extract_GT_to_CM)
export(.extract_haps)
export(.grepa)
export(.gt_to_popsum)
export(.read_body_gz)
export(.read_meta_gz)
Expand Down Expand Up @@ -64,6 +65,10 @@ export(seq2rects)
export(var.win)
export(variant.table)
export(vcfR2chromR)
export(vcfR2genind)
export(vcfR2genlight)
export(vcfR2loci)
export(vcfR2migrate)
export(vcfR2tidy)
export(vcf_field_names)
export(win.table)
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This may have been addressed at 64a308ba50b9119108e8946737460de5997b805b by addi

# vcfR 1.5.0.9000
Released on CRAN 201X-XX-XX.
* removed `.Call()` statements to standardize style.
* Created `vcfR2migrate()` to output MigrateN format data.
* Addressed clang-UBSAN memory leak in `freq_peak()`.
* Created `pairwise_genetic_diff()` to calculate pairwise differentiation.
Expand Down
5 changes: 5 additions & 0 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ AD_frequency <- function(ad, delim = ",", allele = 1L, sum_type = 0L, decreasing
.Call(`_vcfR_extract_haps`, ref, alt, gt, unphased_as_NA, verbose)
}

#' @export
.grepa <- function() {
invisible(.Call(`_vcfR_grepa`))
}

#'
#' @rdname freq_peak
#'
Expand Down
2 changes: 1 addition & 1 deletion tools/R/vcfR2migrate.R → R/vcfR2migrate.R
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ vcfR2migrate <- function(vcf, pop, in_pop, out_file = "MigrateN_infile.txt", met
var_info <- as.data.frame(vcf_list[[i]]@fix[,1:2, drop = FALSE])
var_info$mask <- TRUE
gt <- extract.gt(vcf_list[[i]])
popSum <- .Call("vcfR_gt_to_popsum", PACKAGE = "vcfR", var_info = var_info, gt = gt)
popSum <- .gt_to_popsum(var_info = var_info, gt = gt)
# popSum <- matrix(unlist(strsplit(as.character(popSum$Allele_counts), split = ",", fixed = TRUE)), ncol = 2, byrow = TRUE)

# Populate matrix
Expand Down
12 changes: 6 additions & 6 deletions tools/R/vcfR_conversion.R → R/vcfR_conversion.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@
#'
#'
#' The function vcfR2genlight calls the 'new' method for the genlight object.
#' This method implements multi-threading through calls to the function \code{\link[parallel]{mclapply}}.
#' This method implements multi-threading through calls to the function \code{parallel::mclapply}.
#' Because 'forks' do not exist in the windows environment, this will only work for windows users when n.cores=1.
#' In the Unix environment, users may increase this number to allow the use of multiple threads (i.e., cores).
#'
#'
#'
#' @seealso
#' \code{\link{extract.gt}},
#' \code{\link{alleles2consensus}},
#' \code{\link[adegenet]{df2genind}},
#' \code{\link[adegenet]{genind}},
#' \code{extract.gt},
#' \code{alleles2consensus},
#' \code{adegenet::df2genind},
#' \code{adegenet::genind},
#' \href{https://cran.r-project.org/package=pegas}{pegas},
#' \href{https://cran.r-project.org/package=adegenet}{adegenet},
#' and
#' \href{https://cran.r-project.org/package=poppr}{poppr}.
#' To convert to objects of class \strong{DNAbin} see \code{\link{vcfR2DNAbin}}.
#' To convert to objects of class \strong{DNAbin} see \code{vcfR2DNAbin}.
#'


Expand Down
47 changes: 47 additions & 0 deletions man/vcfR2migrate.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions man/vcfR_conversion.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ BEGIN_RCPP
return rcpp_result_gen;
END_RCPP
}
// grepa
void grepa();
RcppExport SEXP _vcfR_grepa() {
BEGIN_RCPP
Rcpp::RNGScope rcpp_rngScope_gen;
grepa();
return R_NilValue;
END_RCPP
}
// freq_peak
Rcpp::List freq_peak(Rcpp::NumericMatrix myMat, Rcpp::NumericVector pos, int winsize, float bin_width, Rcpp::LogicalVector lhs);
RcppExport SEXP _vcfR_freq_peak(SEXP myMatSEXP, SEXP posSEXP, SEXP winsizeSEXP, SEXP bin_widthSEXP, SEXP lhsSEXP) {
Expand Down Expand Up @@ -293,6 +302,7 @@ static const R_CallMethodDef CallEntries[] = {
{"_vcfR_extract_GT_to_CM", (DL_FUNC) &_vcfR_extract_GT_to_CM, 6},
{"_vcfR_CM_to_NM", (DL_FUNC) &_vcfR_CM_to_NM, 1},
{"_vcfR_extract_haps", (DL_FUNC) &_vcfR_extract_haps, 5},
{"_vcfR_grepa", (DL_FUNC) &_vcfR_grepa, 0},
{"_vcfR_freq_peak", (DL_FUNC) &_vcfR_freq_peak, 5},
{"_vcfR_gt_to_popsum", (DL_FUNC) &_vcfR_gt_to_popsum, 2},
{"_vcfR_is_het", (DL_FUNC) &_vcfR_is_het, 2},
Expand Down
9 changes: 9 additions & 0 deletions src/extract_gt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,4 +456,13 @@ Rcpp::StringMatrix extract_haps(Rcpp::StringVector ref,
}


//' @export
// [[Rcpp::export(name=".grepa")]]
void grepa(){
Rcpp::Rcout << "Hola Javier!\n";
Rcpp::Rcout << "Eres un verdadero amigo!\n";
return;
}


// EOF.
File renamed without changes.
File renamed without changes.
6 changes: 0 additions & 6 deletions tools/src/extractGT2NM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,4 @@ Rcpp::CharacterMatrix extract_GT_to_CM(Rcpp::DataFrame x, std::string element="D



// [[Rcpp::export]]
void grepa(){
Rcout << "Hola Javier!\n";
Rcout << "Eres un verdadero amigo!\n";
return;
}

47 changes: 0 additions & 47 deletions tools/src/vcfRCommon.cpp

This file was deleted.

23 changes: 0 additions & 23 deletions tools/src/vcfRCommon.h

This file was deleted.

0 comments on commit 94687e4

Please sign in to comment.