### Example Output of getPopularMutationCount Source: https://github.com/immcantation/tigger/blob/master/docs/topics/getPopularMutationCount.md This is an example of the output format returned by getPopularMutationCount, showing V gene and its mutation count. ```R # A tibble: 1 x 2 v_gene mutation_count 1 IGHV1-8 1 ``` -------------------------------- ### Install TIgGER from Local Source Source: https://github.com/immcantation/tigger/blob/master/docs/install.md Install TIgGER from a downloaded source archive file (e.g., a .tar.gz file from GitHub releases). Ensure you specify repos=NULL and type="source". ```R install.packages("tigger_x.y.z.tar.gz", repos=NULL, type="source") ``` -------------------------------- ### Install TIgGER Development Version Source: https://github.com/immcantation/tigger/blob/master/docs/install.md Install development dependencies and the latest TIgGER code from GitHub using the devtools package. This method fetches the code directly from the master branch. ```R install.packages(c("devtools", "roxygen2", "testthat", "knitr", "rmarkdown")) ``` ```R library(devtools) install_github("immcantation/tigger@master") ``` -------------------------------- ### Build TIgGER from Source with Devtools Source: https://github.com/immcantation/tigger/blob/master/docs/install.md Clone the TIgGER repository and use devtools functions to install dependencies, build documentation, and install the package locally. This is for advanced development workflows. ```R library(devtools) install_deps() document() build() install() ``` -------------------------------- ### Load Required Packages Source: https://github.com/immcantation/tigger/blob/master/docs/vignettes/Tigger-Vignette.md Loads the 'tigger' and 'dplyr' packages for use in the examples. ```r # Load packages required for this example library(tigger) library(dplyr) ``` -------------------------------- ### Install TIgGER from CRAN Source: https://github.com/immcantation/tigger/blob/master/docs/install.md Use this command to install the latest stable release of TIgGER directly from the Comprehensive R Archive Network (CRAN). ```R install.packages("tigger") ``` -------------------------------- ### getMutatedPositions Output Example Source: https://github.com/immcantation/tigger/blob/master/docs/topics/getMutatedPositions.md This shows the expected output format from getMutatedPositions, which is a list of integers representing the nucleotide positions of differences for each sample compared to the reference. ```R [[1]] integer(0) [[2]] [1] 3 7 [[3]] [1] 1 ``` -------------------------------- ### Example Output of findNovelAlleles Source: https://github.com/immcantation/tigger/blob/master/docs/topics/findNovelAlleles.md This table displays the detailed output from findNovelAlleles, including information on novel alleles found, their characteristics, and comparisons to reference germlines. It helps in understanding the nature and frequency of potential new alleles. ```text germline_call note polymorphism_call nt_substitutions 1 IGHV1-8*02 Novel allele found! IGHV1-8*02_G234T 234G>T novel_imgt 1 CAGGTGCAGCTGGTGCAGTCTGGGGCT...GAGGTGAAGAAGCCTGGGGCCTCAGTGAAGGTCTCCTGCAAGGCTTCTGGATACACCTTC............ACCAGCTATGATATCAACTGGGTGCGACAGGCCACTGGACAAGGGCTTGAGTGGATGGGATGGATGAACCCTAAC......AGTGGTAACACAGGCTATGCACAGAAGTTCCAG...GGCAGAGTCACCATTACCAGGAACACCTCCATAAGCACAGCCTACATGGAGCTGAGCAGCCTGAGATCTGAGGACACGGCCGTGTATTACTGTGCGAGAGG novel_imgt_count novel_imgt_unique_j novel_imgt_unique_cdr3 1 657 6 626 perfect_match_count perfect_match_freq germline_call_count germline_call_freq 1 661 0.7295806 906 0.052 mut_min mut_max mut_pass_count 1 1 10 760 germline_imgt 1 CAGGTGCAGCTGGTGCAGTCTGGGGCT...GAGGTGAAGAAGCCTGGGGCCTCAGTGAAGGTCTCCTGCAAGGCTTCTGGATACACCTTC............ACCAGCTATGATATCAACTGGGTGCGACAGGCCACTGGACAAGGGCTTGAGTGGATGGGATGGATGAACCCTAAC......AGTGGTAACACAGGCTATGCACAGAAGTTCCAG...GGCAGAGTCACCATGACCAGGAACACCTCCATAAGCACAGCCTACATGGAGCTGAGCAGCCTGAGATCTGAGGACACGGCCGTGTATTACTGTGCGAGAGG germline_imgt_count pos_min pos_max y_intercept y_intercept_pass snp_pass 1 0 1 312 0.125 1 754 unmutated_count unmutated_freq unmutated_snp_j_gene_length_count 1 661 0.7295806 83 snp_min_seqs_j_max_pass alpha min_seqs j_max min_frac 1 1 0.05 50 0.15 0.75 ``` -------------------------------- ### Find Differences Between Sequences with getMutatedPositions Source: https://github.com/immcantation/tigger/blob/master/docs/topics/getMutatedPositions.md Example of using getMutatedPositions to find nucleotide differences between sample sequences and a reference sequence. It demonstrates basic usage with default parameters. ```R # Create strings to act as a sample sequences and a reference sequence seqs <- c("----GATA", "GAGAGAGA", "TANA") ref <- "GATAGATA" # Find the differences between the two getMutatedPositions(seqs, ref) ``` -------------------------------- ### Facet Genotype Plot by Subject Source: https://github.com/immcantation/tigger/blob/master/docs/topics/plotGenotype.md This example demonstrates how to facet a genotype plot by a subject column. It involves combining genotype data for different subjects before plotting. ```R genotype_a <- genotype_b <- SampleGenotype genotype_a$SUBJECT <- "A" genotype_b$SUBJECT <- "B" geno_sub <- rbind(genotype_a, genotype_b) plotGenotype(geno_sub, facet_by="SUBJECT", gene_sort="pos") ``` -------------------------------- ### Example Genotype Inference Output Source: https://github.com/immcantation/tigger/blob/master/docs/topics/inferGenotype.md This table displays the output of the inferGenotype function, showing inferred gene alleles, their counts, and total observations for a given subject. ```text gene alleles counts total 1 IGHV1-2 02,04 664,302 966 2 IGHV1-3 01 226 226 3 IGHV1-8 01,02_G234T 467,370 837 4 IGHV1-18 01 1005 1005 5 IGHV1-24 01 105 105 6 IGHV1-46 01 624 624 7 IGHV1-58 01,02 23,18 41 8 IGHV1-69 01,04,06 515,469,280 1279 9 IGHV1-69-2 01 31 31 note 1 2 3 4 5 6 7 8 Cannot distinguish IGHV1-69*01 and IGHV1-69D*01 9 ``` -------------------------------- ### Read Immunoglobulin FASTA File Source: https://github.com/immcantation/tigger/blob/master/docs/topics/readIgFasta.md Reads a FASTA file of immunoglobulin sequences into a named vector. Use this function to load germline sequences for further analysis. The example is not run by default. ```R ### Not run: germlines <- readIgFasta("ighv.fasta") ``` -------------------------------- ### generateEvidence Source: https://github.com/immcantation/tigger/blob/master/docs/topics/generateEvidence.md Builds a table of evidence metrics for novel V allele detection and genotyping inferences. ```APIDOC ## generateEvidence ### Description `generateEvidence` builds a table of evidence metrics for the final novel V allele detection and genotyping inferences. ### Usage ```R generateEvidence( data, novel, genotype, genotype_db, germline_db, j_call = "j_call", junction = "junction", fields = NULL ) ``` ### Arguments * **data** (data.frame) - Contains sequence data that has been passed through `reassignAlleles` to correct allele assignments. * **novel** (data.frame) - The data frame returned by `findNovelAlleles`. * **genotype** (data.frame) - The data frame of alleles generated with `inferGenotype`, denoting the subject's genotype. * **genotype_db** (vector) - A vector of named nucleotide germline sequences in the genotype, returned by `genotypeFasta`. * **germline_db** (vector) - The original uncorrected germline database used by `findNovelAlleles` to identify novel alleles. * **j_call** (string) - Name of the column in `data` with J allele calls. Default is `j_call`. * **junction** (string) - Junction region nucleotide sequence, including the CDR3 and the two flanking conserved codons. Default is `junction`. * **fields** (character vector or NULL) - Column names used to split the data to identify novel alleles. If `NULL`, the data is not divided by grouping variables. ### Value Returns the `genotype` input data.frame with additional columns providing supporting evidence for each inferred allele: * `field_id`: Data subset identifier, defined with the input parameter `fields`. * A variable number of columns, specified with the input parameter `fields`. * `polymorphism_call`: The novel allele call. * `novel_imgt`: The novel allele sequence. * `closest_reference`: The closest reference gene and allele in the `germline_db` database. * `closest_reference_imgt`: Sequence of the closest reference gene and allele in the `germline_db` database. * `germline_call`: The input (uncorrected) V call. * `germline_imgt`: Germline sequence for `germline_call`. * `nt_diff`: Number of nucleotides differing between the new allele and the closest reference in the `germline_db` database. * `nt_substitutions`: A comma-separated list of specific nucleotide differences (e.g., `112G>A`) in the novel allele. * `aa_diff`: Number of amino acids differing between the new allele and the closest reference in the `germline_db` database. * `aa_substitutions`: A comma-separated list with specific amino acid differences (e.g., `96A>N`) in the novel allele. * `sequences`: Number of sequences unambiguously assigned to this allele. * `unmutated_sequences`: Number of records with the unmutated novel allele sequence. * `unmutated_frequency`: Proportion of records with the unmutated novel allele sequence (`unmutated_sequences / sequences`). * `allelic_percentage`: Percentage at which the (unmutated) allele is observed in the sequence dataset compared to other (unmutated) alleles. * `unique_js`: Number of unique J sequences found associated with the novel allele. * `unique_cdr3s`: Number of unique CDR3s associated with the inferred allele. * `mut_min`: Minimum mutation considered by the algorithm. * `mut_max`: Maximum mutation considered by the algorithm. * `pos_min`: First position of the sequence considered by the algorithm (IMGT numbering). * `pos_max`: Last position of the sequence considered by the algorithm (IMGT numbering). * `y_intercept`: The y-intercept above which positions were considered potentially polymorphic. * `alpha`: Significance threshold for constructing the confidence interval for the y-intercept. * `min_seqs`: Input `min_seqs`. Minimum number of total sequences required for samples to be considered. * `j_max`: Input `j_max`. Maximum fraction of sequences perfectly aligning to a potential novel allele that are allowed to utilize a particular combination of junction length and J gene. * `min_frac`: Input `min_frac`. Minimum fraction of sequences that must have usable nucleotides in a given position for that position to be considered. * `note`: Comments regarding the novel allele inference. ``` -------------------------------- ### Generate Input Data for Genotype Inference Source: https://github.com/immcantation/tigger/blob/master/docs/topics/generateEvidence.md This R code block demonstrates the sequence of operations to prepare data for genotype inference. It involves finding novel alleles, inferring genotypes, creating a genotype database, and reassigning alleles based on the inferred genotypes. Ensure that AIRRDb, SampleGermlineIGHV, and other specified parameters are correctly defined before execution. ```R novel <- findNovelAlleles(AIRRDb, SampleGermlineIGHV, v_call="v_call", j_call="j_call", junction="junction", junction_length="junction_length", seq="sequence_alignment") genotype <- inferGenotype(AIRRDb, find_unmutated=TRUE, germline_db=SampleGermlineIGHV, novel=novel, v_call="v_call", seq="sequence_alignment") genotype_db <- genotypeFasta(genotype, SampleGermlineIGHV, novel) data_db <- reassignAlleles(AIRRDb, genotype_db, v_call="v_call", seq="sequence_alignment") ``` -------------------------------- ### Get Popular Mutation Count Source: https://github.com/immcantation/tigger/blob/master/docs/topics/getPopularMutationCount.md Use this function to determine the mutation count of frequently occurring sequences for each V gene. Ensure your data is in Change-O format and provide germline sequences. ```R getPopularMutationCount( data, germline_db, v_call = "v_call", seq = "sequence_alignment", gene_min = 0.001, seq_min = 50, seq_p_of_max = 1/8, full_return = FALSE ) ``` ```R getPopularMutationCount(AIRRDb, SampleGermlineIGHV) ``` -------------------------------- ### Assemble Evidence Table Source: https://github.com/immcantation/tigger/blob/master/docs/topics/generateEvidence.md This R code snippet shows how to assemble the final evidence table using the previously generated data. It requires the processed data database, novel alleles, inferred genotypes, genotype database, and germline database as input. The function `generateEvidence` consolidates this information for further analysis. ```R # Assemble evidence table evidence <- generateEvidence(data_db, novel, genotype, genotype_db, SampleGermlineIGHV, j_call = "j_call", junction = "junction") ``` -------------------------------- ### Generate Evidence Metrics for Novel Allele Detection Source: https://github.com/immcantation/tigger/blob/master/docs/vignettes/Tigger-Vignette.md This R code generates a table of evidence metrics using the generateEvidence function. It requires the sample database, novel alleles, genotype information, genotype database, and germline sequences. The output is then filtered to show key evidence details. ```r evidence <- generateEvidence(sample_db, novel, geno, genotype_db, SampleGermlineIGHV, fields = NULL) evidence %>% select(gene, allele, polymorphism_call, sequences, unmutated_frequency) ``` -------------------------------- ### Find and Select Novel Alleles Source: https://github.com/immcantation/tigger/blob/master/docs/topics/findNovelAlleles.md Use findNovelAlleles to identify potential novel alleles in your dataset and then selectNovel to filter and examine these findings. This is useful for discovering new germline variants. ```R novel <- findNovelAlleles(AIRRDb, SampleGermlineIGHV) selectNovel(novel) ``` -------------------------------- ### Plot Evidence for Novel Allele Source: https://github.com/immcantation/tigger/blob/master/docs/vignettes/Tigger-Vignette.md Visualizes the evidence supporting a novel allele call, including mutation frequency and nucleotide usage. ```r novel_row <- which(!is.na(novel$polymorphism_call))[1] plotNovel(AIRRDb, novel[novel_row, ]) ``` -------------------------------- ### Plot Genotype Visualization Source: https://github.com/immcantation/tigger/blob/master/docs/vignettes/Tigger-Vignette.md Generates a colorful visualization of the inferred genotype, where bars indicate the presence of alleles. ```r # Make a colorful visualization. Bars indicate presence, not proportion. plotGenotype(geno, text_size = 10) ``` -------------------------------- ### generateEvidence Function Signature Source: https://github.com/immcantation/tigger/blob/master/docs/topics/generateEvidence.md This is the function signature for generateEvidence. It outlines the required and optional arguments for generating evidence metrics. ```R generateEvidence( data, novel, genotype, genotype_db, germline_db, j_call = "j_call", junction = "junction", fields = NULL ) ``` -------------------------------- ### Infer Genotype with Bayesian Method Source: https://github.com/immcantation/tigger/blob/master/docs/vignettes/Tigger-Vignette.md Infers the individual's genotype using the Bayesian method. This method analyzes posterior probabilities and calculates Bayes factors for confidence in genotyping calls. It does not use the strict `fraction_to_explain` cutoff. ```r # Infer the individual's genotype, using the bayesian method geno_bayesian <- inferGenotypeBayesian(AIRRDb, germline_db=SampleGermlineIGHV, novel=novel, find_unmutated=TRUE) # Visualize the genotype and sequence counts print(geno_bayesian) ``` -------------------------------- ### Visualize Genotype Data Source: https://github.com/immcantation/tigger/blob/master/docs/vignettes/Tigger-Vignette.md Creates a colorful visualization of the genotype data. The bars in the plot indicate the presence of alleles, not their proportion. ```r # Make a colorful visualization. Bars indicate presence, not proportion. plotGenotype(geno_bayesian, text_size=10) ``` -------------------------------- ### genotypeFasta Source: https://github.com/immcantation/tigger/blob/master/docs/topics/genotypeFasta.md Converts a genotype table into a vector of nucleotide sequences. ```APIDOC ## genotypeFasta ### Description Converts a genotype table into a vector of nucleotide sequences. ### Usage ```R genotypeFasta(genotype, germline_db, novel = NA) ``` ### Arguments #### genotype - `data.frame` of alleles denoting a genotype, as returned by [inferGenotype](inferGenotype.md). #### germline_db - vector of named nucleotide germline sequences matching the alleles detailed in `genotype`. #### novel - an optional `data.frame` containing putative novel alleles of the type returned by [findNovelAlleles](findNovelAlleles.md). ### Value A named vector of strings containing the germline nucleotide sequences of the alleles in the provided genotype. ### Examples ```R # Find the sequences that correspond to the genotype genotype_db <- genotypeFasta(SampleGenotype, SampleGermlineIGHV, SampleNovel) ``` ### See also - [inferGenotype](inferGenotype.md) ``` -------------------------------- ### Clean messy nucleotide sequences with cleanSeqs Source: https://github.com/immcantation/tigger/blob/master/docs/topics/cleanSeqs.md Use cleanSeqs to clean messy nucleotide sequences. It capitalizes nucleotides and replaces invalid characters with 'N'. ```R seqs <- c("AGAT.taa-GAG...ATA", "GATACAGTXXZZAGNNPPACA") cleanSeqs(seqs) ``` ```R [1] "AGAT.TAA-GAG...ATA" "GATACAGTNNNNAGNNNNACA" ``` -------------------------------- ### Extract Genotype Database Sequences Source: https://github.com/immcantation/tigger/blob/master/docs/topics/reassignAlleles.md Extracts database sequences that correspond to the genotype. This is a prerequisite for using reassignAlleles. ```R genotype_db <- genotypeFasta(SampleGenotype, SampleGermlineIGHV, novel=SampleNovel) ``` -------------------------------- ### Convert Genotype to Nucleotide Sequences Source: https://github.com/immcantation/tigger/blob/master/docs/topics/genotypeFasta.md Use this function to retrieve the nucleotide sequences for a given genotype, referencing a germline database and optionally including novel alleles. Ensure that the germline database contains sequences matching the alleles in the genotype. ```R genotype_db <- genotypeFasta(SampleGenotype, SampleGermlineIGHV, SampleNovel) ``` -------------------------------- ### Write Sequences to FASTA File Source: https://github.com/immcantation/tigger/blob/master/docs/topics/writeFasta.md Use this function to write a named vector of sequences to a file in FASTA format. Specify the output file name and optionally control line width and append mode. ```R writeFasta(germlines, "ighv.fasta") ``` -------------------------------- ### Find Unmutated Allele Calls Source: https://github.com/immcantation/tigger/blob/master/docs/topics/findUnmutatedCalls.md Use this function to identify which sample alleles are unmutated against a germline database. Ensure `AIRRDb` and `SampleGermlineIGHV` are loaded and accessible. ```R calls <- findUnmutatedCalls(AIRRDb$v_call, AIRRDb$sequence_alignment, germline_db=SampleGermlineIGHV) ``` -------------------------------- ### Infer Genotype with Frequency Approach Source: https://github.com/immcantation/tigger/blob/master/docs/vignettes/Tigger-Vignette.md Infers an individual's genotype using a frequency-based method, optionally including unmutated sequences and novel alleles. ```r # Infer the individual's genotype, using only unmutated sequences and checking # for the use of the novel alleles inferred in the earlier step. geno <- inferGenotype(AIRRDb, germline_db=SampleGermlineIGHV, novel=novel, find_unmutated=TRUE) # Save the genotype sequences to a vector genotype_db <- genotypeFasta(geno, SampleGermlineIGHV, novel) # Visualize the genotype and sequence counts print(geno) ``` ```text ## gene alleles counts total ## 1 IGHV1-2 02,04 664,302 966 ## 2 IGHV1-3 01 226 226 ## 3 IGHV1-8 01,02_G234T 467,370 837 ## 4 IGHV1-18 01 1005 1005 ## 5 IGHV1-24 01 105 105 ## 6 IGHV1-46 01 624 624 ## 7 IGHV1-58 01,02 23,18 41 ## 8 IGHV1-69 01,04,06 515,469,280 1279 ## 9 IGHV1-69-2 01 31 31 ## note ## 1 ## 2 ## 3 ## 4 ## 5 ## 6 ## 7 ## 8 Cannot distinguish IGHV1-69*01 and IGHV1-69D*01 ## 9 ``` -------------------------------- ### IGHV Genotype Inference Results Source: https://github.com/immcantation/tigger/blob/master/docs/topics/inferGenotypeBayesian.md The output table displays gene names, associated alleles, their counts, total counts, and various statistical measures (note, kh, kd, kt, kq, k_diff) to evaluate the genotype inference. It can highlight potential ambiguities, such as distinguishing between IGHV1-69*01 and IGHV1-69D*01. ```text gene alleles counts total 1 IGHV1-2 02,04 664,302 966 2 IGHV1-3 01 226 226 3 IGHV1-8 01,02_G234T 467,370 837 4 IGHV1-18 01 1005 1005 5 IGHV1-24 01 105 105 6 IGHV1-46 01 624 624 7 IGHV1-58 01,02 23,18 41 8 IGHV1-69 01,04,06,02 515,469,280,15 1279 9 IGHV1-69-2 01 31 31 note kh 1 -1000 2 4.20089197988625 3 -1000 4 -3.76643736033536 5 4.75335701924247 6 0.457455409315221 7 -20.3932114156223 8 Cannot distinguish IGHV1-69*01 and IGHV1-69D*01 -1000 9 4.16107190423977 kd kt kq k_diff 1 -7.92846809405969 -139.556367176944 -313.583949130729 131.627899082884 2 -45.2911957825576 -84.2865868763307 -128.991761853586 49.4920877624439 3 -1.04759115960507 -102.524664723923 -247.193958844361 101.477073564318 4 -223.85293382607 -1000 -1000 220.086496465735 5 -18.2407545518045 -36.3580822723628 -57.1281856909991 22.9941115710469 6 -136.193264784335 -243.861955237939 -1000 136.65072019365 7 3.60009261357983 -1.38512929425796 -8.47869574581951 4.9852219078378 8 -277.291087469703 3.55051520054669 -143.380669247128 146.931184447674 9 -2.62766579768837 -7.97659112471034 -14.1087168959268 6.78873770192814 ``` -------------------------------- ### Select Novel Allele Rows Source: https://github.com/immcantation/tigger/blob/master/docs/vignettes/Tigger-Vignette.md Extracts rows containing successful novel allele calls from the input data. ```r novel_rows <- selectNovel(novel) ``` -------------------------------- ### Sort Alleles by Name Source: https://github.com/immcantation/tigger/blob/master/docs/topics/sortAlleles.md Sorts a vector of Ig allele names lexicographically. This is the default behavior when the method argument is not specified. ```R alleles <- c("IGHV1-69D*01","IGHV1-69*01","IGHV1-2*01","IGHV1-2*01","IGHV1-69-2*01", "IGHV2-5*01","IGHV1-NL1*01", "IGHV1-2*01,IGHV1-2*05", "IGHV1-2", "IGHV1-2*02", "IGHV1-69*02") sortAlleles(alleles) ``` ```text [1] "IGHV1-2" "IGHV1-2*01" "IGHV1-2*01,IGHV1-2*05" [4] "IGHV1-2*02" "IGHV1-69*01" "IGHV1-69D*01" [7] "IGHV1-69*02" "IGHV1-69-2*01" "IGHV1-NL1*01" [10] "IGHV2-5*01" ``` -------------------------------- ### Select Novel Alleles Source: https://github.com/immcantation/tigger/blob/master/docs/topics/selectNovel.md Use selectNovel to filter for unique, novel alleles. The keep_alleles argument can be set to TRUE to retain polymorphic allele calls. ```R novel <- selectNovel(SampleNovel) ``` -------------------------------- ### Calculate Mutation Counts with getMutCount Source: https://github.com/immcantation/tigger/blob/master/docs/topics/getMutCount.md Use this function to compare sample sequences against their assigned germline alleles and calculate the Hamming distance. Ensure germline sequences are correctly named and match the allele calls. ```R s2 <- s3 <- SampleGermlineIGHV[1] stringi::stri_sub(s2, 103, 103) <- "G" stringi::stri_sub(s3, 107, 107) <- "C" sample_seqs <- c(SampleGermlineIGHV[2], s2, s3) sample_alleles <- c(paste(names(SampleGermlineIGHV[1:2]), collapse=","), names(SampleGermlineIGHV[2]), names(SampleGermlineIGHV[1])) getMutCount(sample_seqs, sample_alleles, SampleGermlineIGHV) ``` -------------------------------- ### insertPolymorphisms Function Source: https://github.com/immcantation/tigger/blob/master/docs/topics/insertPolymorphisms.md This function inserts specified nucleotides into a nucleotide sequence at given positions. It replaces the existing nucleotides at those positions. ```APIDOC ## insertPolymorphisms ### Description Inserts polymorphisms into a nucleotide sequence by replacing nucleotides at specified locations. ### Usage ```R insertPolymorphisms(sequence, positions, nucleotides) ``` ### Arguments - **sequence** (character) - The starting nucleotide sequence. - **positions** (numeric vector) - A vector of positions within the sequence to be modified. - **nucleotides** (character vector) - A vector of nucleotides to insert at the specified positions. ### Value Returns the modified nucleotide sequence with the inserted nucleotides. ### Examples ```R insertPolymorphisms("HUGGED", c(1, 6, 2), c("T", "R", "I")) # Returns: "TIGGER" ``` ``` -------------------------------- ### Plot Novel Allele Evidence Source: https://github.com/immcantation/tigger/blob/master/docs/topics/plotNovel.md Use plotNovel to visualize evidence for a novel allele. Specify column names for V calls, J calls, sequences, and junction details. Set multiplot to TRUE to return a single combined plot. ```R novel <- selectNovel(SampleNovel) plotNovel(AIRRDb, novel[1, ], v_call="v_call", j_call="j_call", seq="sequence_alignment", junction="junction", junction_length="junction_length", multiplot=TRUE) ``` -------------------------------- ### plotNovel Function Source: https://github.com/immcantation/tigger/blob/master/docs/topics/plotNovel.md Visualizes evidence of novel V alleles found in repertoire data. This function generates plots to help analyze polymorphisms and mutation frequencies associated with potential novel alleles. ```APIDOC ## plotNovel Function ### Description Visualizes evidence of novel V alleles found in repertoire data. This function generates plots to help analyze polymorphisms and mutation frequencies associated with potential novel alleles. ### Usage ```R plotNovel( data, novel_row, v_call = "v_call", j_call = "j_call", seq = "sequence_alignment", junction = "junction", junction_length = "junction_length", pos_range_max = NULL, ncol = 1, multiplot = TRUE ) ``` ### Arguments * **data** (`data.frame`): A data frame containing repertoire data. See [findNovelAlleles](findNovelAlleles.md) for details. * **novel_row** (`data.frame`): A single row from a data frame as output by [findNovelAlleles](findNovelAlleles.md) that contains a polymorphism-containing germline allele. * **v_call** (`string`): The name of the column in `data` with V allele calls. Default is `v_call`. * **j_call** (`string`): The name of the column in `data` with J allele calls. Default is `j_call`. * **seq** (`string`): The name of the column in `data` with the aligned, IMGT-numbered, V(D)J nucleotide sequence. Default is `sequence_alignment`. * **junction** (`string`): Junction region nucleotide sequence, which includes the CDR3 and the two flanking conserved codons. Default is `junction`. * **junction_length** (`string`): Number of junction nucleotides in the junction sequence. Default is `junction_length`. * **pos_range_max** (`string`): Name of the column in `data` with the ending positions of the V alignment in the germline (usually `v_germline_end`). * **ncol** (`numeric`): Number of columns to use when laying out the plots. Default is 1. * **multiplot** (`boolean`): Whether to return one single plot (`TRUE`) or a list with the three individual plots (`FALSE`). Default is `TRUE`. ### Details The function generates three panels: 1. Mutation frequency at each position along the aligned sequence as a function of sequence-wide mutation count, for sequences aligning to a particular germline allele. Positions are color-coded based on novel allele test results (red: pass, yellow: pass y-intercept test only, blue: failed y-intercept test). 2. Nucleotide usage at polymorphic positions as a function of sequence-wide mutation count. If no polymorphisms are identified, it shows mutation count. 3. Analysis of J gene and junction length combinations among sequences matching the proposed germline allele to identify potential clonal lineages. ### Examples ```R # Plot the evidence for the first (and only) novel allele in the example data novel <- selectNovel(SampleNovel) plotNovel(AIRRDb, novel[1, ], v_call="v_call", j_call="j_call", seq="sequence_alignment", junction="junction", junction_length="junction_length", multiplot=TRUE) ``` ``` -------------------------------- ### writeFasta Source: https://github.com/immcantation/tigger/blob/master/docs/topics/writeFasta.md Writes a named vector of sequences to a file in FASTA format. This function is useful for exporting sequence data for use with other bioinformatics tools. ```APIDOC ## writeFasta ### Description Writes a named vector of sequences to a file in fasta format. ### Usage ```R writeFasta(named_sequences, file, width = 60, append = FALSE) ``` ### Arguments #### named_sequences - vector of named string representing sequences #### file - the name of the output file. #### width - the number of characters to be printed per line. if not between 1 and 255, width with be infinite. #### append - `logical` indicating if the output should be appended to `file` instead of overwriting it ### Value A named vector of strings representing Ig alleles. ### Examples ```R ### Not run: # writeFasta(germlines, "ighv.fasta") ``` ### See also [readIgFasta](readIgFasta.md) to do the inverse. ``` -------------------------------- ### readIgFasta Function Source: https://github.com/immcantation/tigger/blob/master/docs/topics/readIgFasta.md Reads a FASTA-formatted file of immunoglobulin (Ig) sequences and returns a named vector of those sequences. It provides options to control the processing of sequence names and nucleotide case. ```APIDOC ## readIgFasta ### Description Reads a FASTA-formatted file of immunoglobulin (Ig) sequences and returns a named vector of those sequences. ### Usage ```R readIgFasta(fasta_file, strip_down_name = TRUE, force_caps = TRUE) ``` ### Arguments #### `fasta_file` - **type**: file path - **description**: fasta-formatted file of immunoglobulin sequences. #### `strip_down_name` - **type**: logical - **description**: if `TRUE`, will extract only the allele name from the strings fasta file's sequence names. - **default**: TRUE #### `force_caps` - **type**: logical - **description**: if `TRUE`, will force nucleotides to uppercase. - **default**: TRUE ### Value Named vector of strings representing Ig alleles. ### Examples ```R # germlines <- readIgFasta("ighv.fasta") ``` ### See Also [writeFasta](writeFasta.md) ``` -------------------------------- ### Infer IGHV Genotype (Bayesian) Source: https://github.com/immcantation/tigger/blob/master/docs/topics/inferGenotypeBayesian.md Use this function to infer the IGHV genotype, specifying the reference database, novel allele data, and parameters for finding unmutated sequences. It requires the AIRR data, germline database, and novel allele information. ```R inferGenotypeBayesian(AIRRDb, germline_db=SampleGermlineIGHV, novel=SampleNovel, find_unmutated=TRUE, v_call="v_call", seq="sequence_alignment") ``` -------------------------------- ### Infer IGHV Genotype with Novel Alleles Source: https://github.com/immcantation/tigger/blob/master/docs/topics/inferGenotype.md Infers the IGHV genotype using unmutated sequences and includes novel alleles. Ensure germline_db and novel are provided when find_unmutated is TRUE. ```R inferGenotype(AIRRDb, germline_db=SampleGermlineIGHV, novel=SampleNovel, find_unmutated=TRUE) ``` -------------------------------- ### Summarize Allele Call Ambiguity and Genotype Mismatches Source: https://github.com/immcantation/tigger/blob/master/docs/vignettes/Tigger-Vignette.md This R code calculates and displays the proportion of ambiguous and non-genotype calls before and after processing. It helps in understanding data quality and potential issues with allele assignments. ```r data.frame(Ambiguous=c(mean(grepl(",", sample_db$v_call)), mean(grepl(",", sample_db$v_call_genotyped))), NotInGenotype=c(mean(sample_db$v_call %in% not_in_genotype), mean(sample_db$v_call_genotyped %in% not_in_genotype)), row.names=c("Before", "After")) %>% t() %>% round(3) ``` -------------------------------- ### reassignAlleles Function Signature Source: https://github.com/immcantation/tigger/blob/master/docs/topics/reassignAlleles.md Correct allele calls based on a personalized genotype. ```APIDOC ## reassignAlleles ### Description Correct allele calls based on a personalized genotype. `reassignAlleles` uses a subject-specific genotype to correct preliminary allele assignments of a set of sequences derived from a single subject. ### Arguments * **data** (`data.frame`): Containing V allele calls and sequence alignments from a single subject. * **genotype_db** (vector): Named nucleotide germline sequences matching allele calls and personalized to the subject. * **v_call** (string): Column name for V allele calls. Default is `"v_call"`. * **seq** (string): Column name for aligned, IMGT-numbered, V(D)J nucleotide sequence. Default is `SEQUENCE_IMGT`. * **method** (string): Method for realigning sequences to genotype_db. Currently, only `"hamming"` is implemented. * **path** (string): Directory containing the tool for realignment, if needed. Not required for Hamming distance. * **keep_gene** (string): Assignment level to maintain: `"gene"`, `"family"`, or `"repertoire"`. Default is `c("gene", "family", "repertoire")`. ### Value A modified input `data.frame` with the best allele call from `genotype_db` in the `v_call_genotyped` column. ### Details Initial gene assignments are preserved to save time, and allele calls are chosen from `genotype_db` based on alignment to the sample sequence. ### Example ```R # Extract the database sequences that correspond to the genotype genotype_db <- genotypeFasta(SampleGenotype, SampleGermlineIGHV, novel=SampleNovel) # Use the personalized genotype to determine corrected allele assignments output_db <- reassignAlleles(AIRRDb, genotype_db, v_call="v_call", seq="sequence_alignment") ``` ``` -------------------------------- ### findNovelAlleles Function Signature Source: https://github.com/immcantation/tigger/blob/master/docs/topics/findNovelAlleles.md This is the function signature for findNovelAlleles, outlining its parameters and their default values. Use this to understand the inputs required for analyzing repertoire sequencing data. ```R findNovelAlleles( data, germline_db, v_call = "v_call", j_call = "j_call", seq = "sequence_alignment", junction = "junction", junction_length = "junction_length", germline_min = 200, min_seqs = 50, auto_mutrange = TRUE, mut_range = 1:10, pos_range = 1:312, pos_range_max = NULL, y_intercept = 0.125, alpha = 0.05, j_max = 0.15, min_frac = 0.75, nproc = 1 ) ```