Skip to content

Commit

Permalink
output to VCF
Browse files Browse the repository at this point in the history
if pos is NA, output 0.
  • Loading branch information
zhengxwen committed May 8, 2024
1 parent 5cdff0e commit 711acec
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions R/DataUtilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# HIBAG -- HLA Genotype Imputation with Attribute Bagging
#
# HIBAG R package, HLA Genotype Imputation with Attribute Bagging
# Copyright (C) 2011-2021 Xiuwen Zheng (zhengx@u.washington.edu)
# Copyright (C) 2011-2024 Xiuwen Zheng (zhengx@u.washington.edu)
# All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -1139,13 +1139,18 @@ hlaAlleleDigit <- function(obj, max.resolution=NA_character_, rm.suffix=FALSE)
hlaUniqueAllele <- function(hla, all=NA)
{
# check
stopifnot(is.character(hla) | inherits(hla, "hlaAlleleClass"))
stopifnot(is.character(hla) | inherits(hla, "hlaAlleleClass") |
inherits(hla, "hlaAttrBagClass") | inherits(hla, "hlaAttrBagObj"))

if (is.character(hla))
{
hla <- hla[!is.na(hla)]
hla <- unique(hla)
.Call(HIBAG_SortAlleleStr, hla)
} else if (inherits(hla, "hlaAttrBagClass") ||
inherits(hla, "hlaAttrBagObj"))
{
hlaUniqueAllele(hla$hla.allele)
} else {
s <- c(hla$value$allele1, hla$value$allele2)
if (isTRUE(all))
Expand Down Expand Up @@ -2698,8 +2703,9 @@ hlaAlleleToVCF <- function(hla, outfn, DS=TRUE, allele.list=FALSE,
}

# write to VCF for each allele
pos <- as.character(round(mean(c(hla$pos.start, hla$pos.end), na.rm=TRUE)))
if (is.na(pos)) pos <- "."
pos <- round(mean(c(hla$pos.start, hla$pos.end), na.rm=TRUE))
if (!is.finite(pos)) pos <- "0" # unknown position
pos <- as.character(pos)
hasDS <- DS && !is.null(hla$dosage)
if (hasDS)
ii <- match(hla$value$sample.id, colnames(hla$dosage))
Expand Down

0 comments on commit 711acec

Please sign in to comment.