Skip to content

Commit 9c85fd3

Browse files
author
Thierry Gosselin
committed
function name change: vcf2dadi -> write_dadi.
this new function is now included in `genomic_converter`
1 parent 05b47df commit 9c85fd3

17 files changed

+948
-40
lines changed

NAMESPACE

+1
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ export(write_arlequin)
207207
export(write_bayescan)
208208
export(write_betadiv)
209209
export(write_colony)
210+
export(write_dadi)
210211
export(write_fasta)
211212
export(write_faststructure)
212213
export(write_fineradstructure)

R/genomic_converter.R

+12-9
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121

2222
#' @param output 29 genomic data formats can be exported: tidy (by default),
2323
#' genepop, genind, genlight, vcf (for file format version, see details below),
24-
#' plink, structure, faststructure, arlequin, hierfstat, gtypes (strataG), bayescan, betadiv,
25-
#' pcadapt, hzar, fineradstructure, related, seqarray, snprelate, maverick,
26-
#' genepopedit, rubias and hapmap.
24+
#' plink, structure, faststructure, arlequin, hierfstat, gtypes (strataG),
25+
#' bayescan, betadiv, pcadapt, hzar, fineradstructure, related, seqarray,
26+
#' snprelate, maverick, genepopedit, rubias, hapmap and dadi.
2727
#' Use a character string,
2828
#' e.g. \code{output = c("genind", "genepop", "structure")}, to have preferred
2929
#' output formats generated. With default, only the tidy format is generated.
@@ -790,18 +790,21 @@ genomic_converter <- function(
790790
} # end MavericK output
791791

792792
# dadi -----------------------------------------------------------------------
793-
if ("dadi" %in% output) message("Under construction, use radiator::vcf2dadi")
793+
if ("dadi" %in% output) {
794+
radiator::write_dadi(
795+
data = input
796+
)
797+
message("\n\nNote: To use an outgroup, use radiator::write_dadi separately\n")
798+
}
799+
800+
794801

795802
# Writing tidy on disk -------------------------------------------------------
796803
# tidy.name <- stringi::stri_join(filename, ".rad")
797804
# message("\nWriting tidy data set:\n", tidy.name)
798805
# write_rad(data = input, path = tidy.name)
799806

800-
# if (!is.null(imputation.method)) {
801-
# tidy.name.imp <- stringi::stri_join(filename.imp, ".rad")
802-
# message("\nWriting tidy data set:\n", tidy.name)
803-
# write_rad(data = input.imp, path = tidy.name.imp)
804-
# }
807+
805808
# outout results -------------------------------------------------------------
806809
if (verbose) {
807810
n.markers <- length(unique(input$MARKERS))

R/vcf.R

+3-9
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,8 @@ read_vcf <- function(
759759
# Filters --------------------------------------------------------------------
760760
# Filter duplicated SNPs on different strands---------------------------------
761761
if (detect.strand) {
762-
blacklist.strands <- dplyr::distinct(markers.meta, VARIANT_ID, MARKERS, CHROM, LOCUS, POS) %>%
762+
blacklist.strands <- markers.meta %>%
763+
dplyr::distinct(VARIANT_ID, MARKERS, CHROM, LOCUS, POS) %>%
763764
dplyr::group_by(CHROM, POS) %>%
764765
dplyr::mutate(n = n()) %>%
765766
dplyr::ungroup(.) %>%
@@ -2530,14 +2531,7 @@ write_vcf <- function(
25302531

25312532
# REF/ALT Alleles and VCF genotype format ------------------------------------
25322533
if (!tibble::has_name(data, "GT_VCF")) {
2533-
ref.change <- radiator::calibrate_alleles(data = data)$input
2534-
data <- dplyr::left_join(data, ref.change, by = c("MARKERS", "INDIVIDUALS"))
2535-
}
2536-
2537-
# remove duplicate REF/ALT column
2538-
if (tibble::has_name(data, "REF.x")) {
2539-
data <- dplyr::select(.data = data, -c(REF.x, ALT.x)) %>%
2540-
dplyr::rename(REF = REF.y, ALT = ALT.y)
2534+
data <- radiator::calibrate_alleles(data = data)$input
25412535
}
25422536

25432537
# Include CHROM, LOCUS, POS --------------------------------------------------

0 commit comments

Comments
 (0)