Skip to content

Commit

Permalink
use alakazam allele parser to standardize allele names and remove " or "
Browse files Browse the repository at this point in the history
  • Loading branch information
ssnn-airr committed Apr 29, 2024
1 parent c225170 commit df8bd3d
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions R/report-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,14 @@ findMissingColumns <- function(data) {
#' @export
getGeneAlleleStat <- function(repertoire, reference = NULL, call="v_call") {

repertoire <- repertoire %>%
dplyr::select(!!as.name(call)) %>%
dplyr::filter(!!as.name(call)!="") %>%
dplyr::mutate( !!as.name(call) := alakazam::getAllele(!!as.name(call), first=F, collapse=T)) %>%
dplyr::mutate("allele" = !!as.name(call))

## get allele-call proportion
allele_data <- repertoire %>% dplyr::select(!!as.name(call)) %>%
dplyr::filter(!!as.name(call)!="") %>%
dplyr::mutate("allele" = !!as.name(call)) %>%
allele_data <- repertoire %>%
tidyr::separate_rows(!!as.name("allele"), sep = ",") %>%
dplyr::rowwise() %>%
dplyr::mutate("proportion" = 1/(stringi::stri_count(!!as.name(call),regex = ",")+1)) %>%
Expand All @@ -180,9 +184,6 @@ getGeneAlleleStat <- function(repertoire, reference = NULL, call="v_call") {

## get gene-call proportion
gene_data <- repertoire %>%
dplyr::select(!!as.name(call)) %>%
dplyr::filter(!!as.name(call)!="") %>%
dplyr::rowwise() %>%
dplyr::mutate("gene" = alakazam::getGene(!!as.name(call), first = F, collapse = T,
strip_d = F, omit_nl = F)) %>%
dplyr::select(!!as.name("gene"), !!as.name(call)) %>%
Expand All @@ -196,13 +197,13 @@ getGeneAlleleStat <- function(repertoire, reference = NULL, call="v_call") {
collapse = ","),
"count_unique_alleles" = stringi::stri_count(!!as.name("unique_alleles"),regex = ",")+1)

if(!is.null(reference)){
if (!is.null(reference)) {

call_region <- substr(gene_data$gene[1],1,4)

alleles <- grep(call_region, names(reference), value=T)

if(length(alleles)!=0){
if (length(alleles)!=0) {
genes <- alakazam::getGene(alleles, first = F, collapse = T,
strip_d = F, omit_nl = F)

Expand Down

0 comments on commit df8bd3d

Please sign in to comment.