Skip to content

Commit

Permalink
**v.0.3.7**
Browse files Browse the repository at this point in the history
* fixed a bug in `write_vcf`, the function was using REF/ALT coding in integer
not character format. This function is used inside `vcf_imputation` and
sometimes inside `genomic_converter`. Thanks to @jeansebastienmoore for
highlighting the problem.
  • Loading branch information
thierrygosselin committed Sep 12, 2016
1 parent 6266a55 commit d760d41
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: stackr
Type: Package
Title: GBS/RADseq Data Exploration, Manipulation and Visualization using R
Version: 0.3.6
Date: 2016-09-09
Version: 0.3.7
Date: 2016-09-12
Encoding: UTF-8
Authors@R: c(
person("Thierry", "Gosselin", email = "thierrygosselin@icloud.com", role = c("aut", "cre")),
Expand Down
3 changes: 2 additions & 1 deletion R/global_variables.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ if (getRversion() >= "2.15.1") {
"FASTA_REF", "BP", "Chr", "Locus", "Locus ID", "Col", "PP", "ALLELE_GROUP",
"PROBLEM", "IND_LEVEL_POLYMORPHISM", "HOM", "HET", "N_GENOT", "DIPLO",
"FREQ_ALLELES", "HOM_E", "HOM_O", "FH", "HET_O", "HET_E", "PI", "pi",
"MONOMORPHIC", "POLYMORPHIC", "CONSENSUS", "PARALOGS", "Seg Dist")
"MONOMORPHIC", "POLYMORPHIC", "CONSENSUS", "PARALOGS", "Seg Dist",
"REF.x", "ALT.x", "REF.y", "ALT.y")
)
}
# 'GL', 'GL_MAX', 'GL_MIN', 'MIN_REF', 'MIN_ALT', 'READ_DEPTH_MAX',
Expand Down
25 changes: 24 additions & 1 deletion R/write_vcf.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ write_vcf <- function(data, pop.info = FALSE, filename = NULL) {
input <- left_join(input, ref.alt.alleles.change, by = c("MARKERS", "INDIVIDUALS"))
}

# remove duplicate REF/ALT column
if (tibble::has_name(input, "REF.x")) {
input <- input %>% select(-c(REF.x, ALT.x)) %>%
rename(REF = REF.y, ALT = ALT.y)
}


# Include CHROM, LOCUS, POS --------------------------------------------------
if (!tibble::has_name(input, "CHROM")) {
input <- mutate(
Expand All @@ -90,7 +97,7 @@ write_vcf <- function(data, pop.info = FALSE, filename = NULL) {
}

# Remove the POP_ID column ---------------------------------------------------
if (tibble::has_name(input, "POP_ID") & (!pop.info)) {
if (tibble::has_name(input, "POP_ID") || (!pop.info)) {
input <- select(.data = input, -POP_ID)
}

Expand Down Expand Up @@ -137,6 +144,22 @@ write_vcf <- function(data, pop.info = FALSE, filename = NULL) {
)
}

# Transform the REF/ALT format back to A/C/G/T
output <- output %>%
mutate(
REF = stringi::stri_replace_all_fixed(
str = REF,
pattern = c("001", "002", "003", "004"),
replacement = c("A", "C", "G", "T"),
vectorize_all = FALSE),
ALT = stringi::stri_replace_all_fixed(
str = ALT,
pattern = c("001", "002", "003", "004"),
replacement = c("A", "C", "G", "T"),
vectorize_all = FALSE)
)

# Keep the required columns
output <- output %>%
arrange(CHROM, LOCUS, POS) %>%
ungroup() %>%
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ citation("stackr")
## New features
Change log, version, new features and bug history now lives in the [NEWS.md file] (https://github.com/thierrygosselin/stackr/blob/master/NEWS.md)

**v.0.3.7**
* fixed a bug in `write_vcf`, the function was using REF/ALT coding in integer
not character format. This function is used inside `vcf_imputation` and
sometimes inside `genomic_converter`. Thanks to @jeansebastienmoore for
highlighting the problem.


**v.0.3.6**
* fixed a bug in `vcf_imputation`, the function now calls `genomic_converter`
with all the bells and whistles of that function (updated vcf import and imputations modules)
Expand Down

0 comments on commit d760d41

Please sign in to comment.