Skip to content

Commit

Permalink
new option 'all' in hlaUniqueAllele()
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengxwen committed Mar 15, 2024
1 parent bd0d457 commit 5f66532
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: HIBAG
Type: Package
Title: HLA Genotype Imputation with Attribute Bagging
Version: 1.38.4
Date: 2024-03-11
Version: 1.39.4
Date: 2024-03-14
Depends: R (>= 3.2.0)
Imports: methods, RcppParallel
Suggests: parallel, ggplot2, reshape2, gdsfmt, SNPRelate, SeqArray, knitr,
Expand Down
6 changes: 6 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
CHANGES IN VERSION 1.39.4
-------------------------

o new option 'all' in `hlaUniqueAllele()`


CHANGES IN VERSION 1.38.3
-------------------------

Expand Down
16 changes: 14 additions & 2 deletions R/DataUtilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,7 @@ hlaAlleleDigit <- function(obj, max.resolution=NA_character_, rm.suffix=FALSE)
# Get unique HLA alleles
#

hlaUniqueAllele <- function(hla)
hlaUniqueAllele <- function(hla, all=NA)
{
# check
stopifnot(is.character(hla) | inherits(hla, "hlaAlleleClass"))
Expand All @@ -1147,7 +1147,19 @@ hlaUniqueAllele <- function(hla)
hla <- unique(hla)
.Call(HIBAG_SortAlleleStr, hla)
} else {
hlaUniqueAllele(as.character(c(hla$value$allele1, hla$value$allele2)))
s <- c(hla$value$allele1, hla$value$allele2)
if (isTRUE(all))
{
if (!is.null(hla$dosage))
{
s <- rownames(hla$dosage)
} else if (!is.null(hla$postprob))
{
s <- strsplit(rownames(hla$postprob), "/", fixed=TRUE)
s <- unique(unlist(s))
}
}
hlaUniqueAllele(as.character(s))
}
}

Expand Down
10 changes: 7 additions & 3 deletions man/hlaUniqueAllele.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@
Get unique HLA alleles, which are in ascending order.
}
\usage{
hlaUniqueAllele(hla)
hlaUniqueAllele(hla, all=NA)
}
\arguments{
\item{hla}{character-type HLA alleles, or a
\code{\link{hlaAlleleClass}} object}
\item{hla}{character-type HLA alleles, or a \code{\link{hlaAlleleClass}}
object}
\item{all}{when \code{hla} is a \code{hlaAlleleClass} object and
\code{all=TRUE}, return all HLA alleles if \code{hla$dosage} or
\code{hla$postprob} exists; otherwise, only return the alleles in
\code{hla$value}}
}
\details{
Each HLA allele name has a unique number corresponding to up to four sets
Expand Down

0 comments on commit 5f66532

Please sign in to comment.