Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
slowkow committed Feb 6, 2025
1 parent 08a5d6f commit ca8878c
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 9 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ paper/
^vignettes/articles$
^optimize-figures.sh$
^R/GranthamDist/
^inst/extdata/
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Description: Fetch sequence alignment data from the IMGTHLA database by Robinson
License: GPL (>= 3)
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
URL: https://github.com/slowkow/hlabud, https://slowkow.github.io/hlabud/
BugReports: https://github.com/slowkow/hlabud/issues
Depends:
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@ importFrom(utils,download.file)
importFrom(utils,head)
importFrom(utils,read.delim)
importFrom(utils,read.table)
importFrom(utils,tail)
importFrom(utils,untar)
15 changes: 10 additions & 5 deletions R/hla_divergence.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,27 @@ V 64 96 133 152 192 96 121 109 84 29 32 97 21 50 68 124 69 88 55 0")
#' @param alleles A character vector of comma-delimited alleles for each individual. We usually expect two alleles per individual, but it is possible to have more (or fewer) copies due to copy number alterations. This function still works when each individual has a different number of alleles.
#' @param method A pairwise amino acid matrix, or a method name: `"grantham"` or `"uniform"` to indicate which pairwise amino acid distance matrix to use. If you choose to pass a matrix, then it should be a 20x20 symmetric matrix with zeros on the diagonal, and the rownames and colnames should be the one-letter amino acid codes `A R N D C Q E G H I L K M F P S T W Y V`.
#' @param release Default is "latest". Should be a release name like "3.51.0".
#' @param positions Only use these positions in the calculation. Should be column names from the `hla_alignments()$alleles` matrix.
#' @param verbose If TRUE, print messages along the way.
#' @seealso [hla_releases()] to get a complete list of all release names.
#' @seealso [amino_distance_matrix()] to get a amino acid distance matrix that you can use with `hla_divergence()`.
#' @return A dataframe with divergence for each individual.
#' @examples
#' my_genos <- c("A*23:01:12,A*24:550", "A*25:12N,A*11:27",
#' "A*24:381,A*33:85", "A*01:01:,A*01:01,A*02:01")
#' my_genos <- c("A*23:01:12,A*24:550",
#' "A*25:12N,A*11:27",
#' "A*24:381,A*33:85",
#' "A*01:01:,A*01:01,A*02:01") # this individual has 3 alleles
#' hla_divergence(my_genos, method = "grantham")
#'
#' # This is equivalent
#' hla_divergence(my_genos, method = amino_distance_matrix("grantham"))
#'
#' # Compute divergence on a subset of positions:
#' hla_divergence(my_genos, positions = c("n1", "1", "2", "3", "4"))
#' @export
hla_divergence <- function(
alleles = c("A*01:01,A*02:01"), method = "grantham", release = "latest", verbose = FALSE,
positions = NULL
alleles = c("A*01:01,A*02:01"), method = "grantham", release = "latest",
positions = NULL, verbose = FALSE
) {

aminos <- c("A", "R", "N", "D", "C", "Q", "E", "G", "H", "I", "L", "K", "M",
Expand Down Expand Up @@ -165,7 +171,6 @@ hla_divergence <- function(
}
}
}
allelePairs

my_combn <- combn(my_alleles, 2)
my_dist <- 0
Expand Down
1 change: 1 addition & 0 deletions R/hlabud.R
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ read_alignments <- function(file) {
#' @param drop_identical Drop positions where all alleles have the same amino acid. Default is false.
#' @param verbose Print messages along the way.
#' @keywords internal
#' @importFrom utils tail
get_onehot <- function(sequences, n_pre, drop_identical = FALSE, verbose = FALSE) {

# Split each string into a vector of individual characters
Expand Down
4 changes: 3 additions & 1 deletion man/get_onehot.Rd

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

12 changes: 10 additions & 2 deletions man/hla_divergence.Rd

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

0 comments on commit ca8878c

Please sign in to comment.