### Load Example Data Source: https://genentech.github.io/midasHLA/articles/MiDAS_vignette.html Loads example HLA, KIR, and phenotypic data shipped with the package for demonstration purposes. ```R HLA <- reduceHlaCalls(MiDAS_tut_HLA, resolution = 4) KIR <- MiDAS_tut_KIR pheno <- MiDAS_tut_pheno ``` -------------------------------- ### Example: Performing Association Analysis Source: https://genentech.github.io/midasHLA/reference/analyzeAssociations.html Demonstrates how to prepare MiDAS data, define a linear model, and then use analyzeAssociations to test for allele associations with a disease outcome. Requires prior setup of MiDAS object and data frame conversion. ```R midas <- prepareMiDAS(hla_calls = MiDAS_tut_HLA, colData = MiDAS_tut_pheno, experiment = "hla_alleles") # analyzeAssociations expects model data to be a data.frame midas_data <- as.data.frame(midas) # define base model object <- lm(disease ~ term, data = midas_data) # test for alleles associations analyzeAssociations(object = object, variables = c("B*14:02", "DRB1*11:01")) ``` -------------------------------- ### Get KIR Calls Example Source: https://genentech.github.io/midasHLA/reference/getKirCalls.html This snippet demonstrates how to use the getKirCalls function with a sample object. The output displays the KIR calls for each ID. ```r getKirCalls(object = MiDAS_tut_object) #> ID KIR3DL3 KIR2DS2 KIR2DL2 KIR2DL3 KIR2DP1 KIR2DL1 KIR3DP1 KIR2DL4 #> 1 C001 1 0 0 1 1 1 1 1 #> 2 C002 1 0 0 1 1 1 1 1 #> 3 C003 1 0 0 1 1 1 1 1 #> 4 C004 1 0 0 1 1 1 1 1 #> 5 C005 1 0 0 1 1 1 1 1 #> 6 C006 1 0 0 1 1 1 1 1 #> 7 C007 1 0 0 1 1 1 1 1 #> 8 C008 1 0 0 1 1 1 1 1 #> 9 C009 1 1 1 0 1 1 1 1 #> 10 C010 1 1 1 1 1 1 1 1 #> 11 C011 NA NA NA NA NA NA NA NA #> 12 C012 1 1 1 1 1 1 1 1 #> 13 C013 1 1 1 1 1 0 1 1 #> 14 C014 1 1 1 1 1 1 1 1 #> 15 C015 NA NA NA NA NA NA NA NA #> 16 C016 1 0 0 1 1 1 1 1 #> 17 C017 1 1 1 1 1 1 1 1 #> 18 C018 1 0 0 1 1 1 1 1 #> 19 C019 1 0 0 1 1 1 1 1 #> 20 C020 1 1 1 1 1 1 1 1 #> 21 C021 1 1 1 1 1 1 1 1 #> 22 C022 1 1 1 1 1 1 1 1 #> 23 C023 1 1 1 1 1 1 1 1 #> 24 C024 1 1 1 1 1 1 1 1 #> 25 C025 1 1 1 1 1 1 1 1 #> 26 C026 NA NA NA NA NA NA NA NA #> 27 C027 1 1 1 0 1 1 1 1 #> 28 C028 1 1 1 0 1 1 1 1 #> 29 C029 1 0 0 1 1 1 1 1 #> 30 C030 1 1 1 1 1 1 1 1 #> 31 C031 1 1 1 1 1 1 1 1 #> 32 C032 1 1 1 1 1 1 1 1 #> 33 C033 1 0 0 1 1 1 1 1 #> 34 C034 1 0 0 1 1 1 1 1 #> 35 C035 1 1 1 1 1 1 1 1 #> 36 C036 1 0 0 1 1 1 1 1 #> 37 C037 1 1 1 1 1 1 1 1 #> 38 C038 1 1 1 1 1 1 1 1 #> 39 C039 1 1 1 1 1 1 1 1 #> 40 C040 1 1 1 1 1 1 1 1 #> 41 C041 1 0 0 1 1 1 1 1 #> 42 C042 1 1 1 1 1 1 1 1 #> 43 C043 1 0 0 1 1 1 1 1 #> 44 C044 1 0 0 1 1 1 1 1 #> 45 C045 1 0 0 1 1 1 1 1 #> 46 C046 1 0 0 1 1 1 1 1 #> 47 C047 1 1 1 1 1 1 1 1 #> 48 C048 1 1 1 0 1 1 1 1 #> 49 C049 1 1 1 1 1 1 1 1 #> 50 C050 1 1 1 1 1 1 1 1 #> 51 C051 1 1 1 1 1 0 1 1 #> 52 C052 1 1 1 1 1 1 1 1 #> 53 C053 1 0 0 1 1 1 1 1 #> 54 C054 1 1 1 1 1 1 1 1 #> 55 C055 1 0 0 1 1 1 1 1 #> 56 C056 1 1 1 1 1 1 1 1 #> 57 C057 1 1 1 1 1 1 1 1 #> 58 C058 1 1 1 1 1 1 1 1 #> 59 C059 1 1 1 1 1 1 1 1 #> 60 C060 1 1 1 1 1 1 1 1 #> 61 C061 1 1 1 1 1 1 1 1 #> 62 C062 1 1 1 0 1 1 1 1 #> 63 C063 1 1 1 0 1 1 1 1 ``` -------------------------------- ### Read HLA Calls Example Source: https://genentech.github.io/midasHLA/reference/readHlaCalls.html Example of how to use the `readHlaCalls` function to read HLA allele calls from a file. Ensure the example file path is correctly specified. ```R file <- system.file("extdata", "MiDAS_tut_HLA.txt", package = "midasHLA") hla_calls <- readHlaCalls(file) ``` -------------------------------- ### Example Usage of formatResults Source: https://genentech.github.io/midasHLA/reference/formatResults.html Demonstrates how to use the formatResults function with custom filtering, sorting, column selection, and output format. ```r if (FALSE) { midas <- prepareMiDAS(hla_calls = MiDAS_tut_HLA, colData = MiDAS_tut_pheno, experiment = "hla_alleles") object <- lm(disease ~ term, data = midas) res <- runMiDAS(object, experiment = "hla_alleles", inheritance_model = "dominant") formatResults(res, filter_by = c("p.value <= 0.05", "estimate > 0"), arrange_by = c("p.value * estimate"), select_cols = c("allele", "p-value" = "p.value"), format = "html", header = "HLA allelic associations") } ``` -------------------------------- ### Prepare MiDAS Object for HWETest Source: https://genentech.github.io/midasHLA/reference/HWETest.html Example of creating a MiDAS object using prepareMiDAS, which is a prerequisite for using the HWETest function. ```R # create MiDAS object midas <- prepareMiDAS(hla_calls = MiDAS_tut_HLA, colData = MiDAS_tut_pheno, experiment = "hla_alleles" ) ``` -------------------------------- ### Example of analyzeConditionalAssociations Usage Source: https://genentech.github.io/midasHLA/reference/analyzeConditionalAssociations.html This example demonstrates how to use the `analyzeConditionalAssociations` function. It first prepares MiDAS data, converts it to a data frame, defines a linear model, and then applies the function to test associations between specific HLA alleles and disease status, using a significance threshold of 0.05. ```R midas <- prepareMiDAS (hla_calls = MiDAS_tut_HLA, colData = MiDAS_tut_pheno, experiment = "hla_alleles") # analyzeConditionalAssociations expects model data to be a data.frame midas_data <- as.data.frame(midas) # define base model object <- lm(disease ~ term, data = midas_data) analyzeConditionalAssociations(object, variables = c("B*14:02", "DRB1*11:01"), th = 0.05) #> Warning: No significant variables found. Returning empty table. #> # A tibble: 0 × 9 #> # ℹ 9 variables: term , estimate , std.error , statistic , #> # p.value , conf.low , conf.high , p.adjusted , #> # covariates ``` -------------------------------- ### Install MiDAS R Package Source: https://genentech.github.io/midasHLA/index.html Provides R code for installing the MiDAS package from Bioconductor and the development version from GitHub. ```r # Install from Bioconductor BiocManager::install("midasHLA") # Install development version from GitHub devtools::install_github("Genentech/MiDAS") ``` -------------------------------- ### Get HLA-KIR Interactions Example Source: https://genentech.github.io/midasHLA/reference/getHlaKirInteractions.html This snippet shows a basic usage of the getHlaKirInteractions function. It requires pre-defined HLA and KIR call datasets and an interaction dictionary file. Be aware of potential warnings regarding ambiguous cases like Bw4 assignment. ```R getHlaKirInteractions( hla_calls = MiDAS_tut_HLA, kir_calls = MiDAS_tut_KIR, interactions_dict = system.file( "extdata", "Match_counts_hla_kir_interactions.txt", package = "midasHLA") ) #> Warning: In ambiguous cases Bw4 will be assigned! See 'hlaToVariable' documentation for more details. #> ID C2_KIR2DL1 C1_KIR2DL2 B*46:01_KIR2DL2 B*73:01_KIR2DL2 C2_KIR2DL2 #> 1 C001 0 0 0 0 0 #> 2 C002 1 0 0 0 0 #> 3 C003 1 0 0 0 0 #> 4 C004 0 0 0 0 0 #> 5 C005 0 0 0 0 0 #> 6 C006 0 0 0 0 0 #> 7 C007 0 0 0 0 0 #> 8 C008 1 0 0 0 0 #> 9 C009 0 1 0 0 0 #> 10 C010 1 1 0 0 1 #> 11 C011 NA NA 0 0 NA #> 12 C012 1 1 0 0 1 #> 13 C013 0 1 0 0 0 #> 14 C014 1 0 0 0 1 #> 15 C015 0 NA 0 0 0 #> 16 C016 0 0 0 0 0 #> 17 C017 1 1 0 0 1 #> 18 C018 1 0 0 0 0 #> 19 C019 0 0 0 0 0 #> 20 C020 0 1 0 0 0 #> 21 C021 1 1 0 0 1 #> 22 C022 1 0 0 0 1 #> 23 C023 1 0 0 0 1 #> 24 C024 1 1 0 0 1 #> 25 C025 0 1 0 0 0 #> 26 C026 0 NA 0 0 0 #> 27 C027 1 0 0 0 1 #> 28 C028 0 1 0 0 0 #> 29 C029 0 0 0 0 0 #> 30 C030 1 1 0 0 1 #> 31 C031 1 0 0 0 1 #> 32 C032 0 1 0 0 0 #> 33 C033 1 0 0 0 0 #> 34 C034 1 0 0 0 0 #> 35 C035 1 1 0 0 1 #> 36 C036 0 0 0 0 0 #> 37 C037 1 1 0 0 1 #> 38 C038 0 1 0 0 0 #> 39 C039 1 0 0 0 1 #> 40 C040 0 1 0 0 0 #> 41 C041 0 0 0 0 0 #> 42 C042 1 0 0 0 1 #> 43 C043 1 0 0 0 0 #> 44 C044 1 0 0 0 0 #> 45 C045 1 0 0 0 0 #> 46 C046 0 0 0 0 0 #> 47 C047 1 0 0 0 1 #> 48 C048 1 1 0 0 1 #> 49 C049 0 1 0 0 0 #> 50 C050 1 1 0 0 1 #> 51 C051 0 0 0 0 1 #> 52 C052 0 1 0 0 0 #> 53 C053 1 0 0 0 0 #> 54 C054 0 1 0 0 0 #> 55 C055 1 0 0 0 0 #> 56 C056 0 1 0 0 0 #> 57 C057 1 0 0 0 1 #> 58 C058 1 1 0 0 1 ``` -------------------------------- ### Prepare MiDAS Object and Run Basic Analysis Source: https://genentech.github.io/midasHLA/reference/runMiDAS.html This snippet demonstrates the initial setup by creating a MiDAS object and then running a basic statistical model using the 'dominant' inheritance model. It's useful for a standard analysis of 'hla_alleles' experiment. ```r midas <- prepareMiDAS(hla_calls = MiDAS_tut_HLA, colData = MiDAS_tut_pheno, experiment = c("hla_alleles", "hla_aa") ) # construct statistical model object <- lm(disease ~ term, data = midas) # run analysis runMiDAS(object, experiment = "hla_alleles", inheritance_model = "dominant") ``` -------------------------------- ### Example Usage of filterByFrequency Source: https://genentech.github.io/midasHLA/reference/filterByFrequency.html Demonstrates how to use the filterByFrequency function to filter a MiDAS object. It specifies the object, experiment, and frequency cutoffs. ```R filterByFrequency(object = MiDAS_tut_object, experiment = "hla_alleles", lower_frequency_cutoff = 0.05, upper_frequency_cutoff = 0.95, carrier_frequency = TRUE) ``` -------------------------------- ### Example Usage of reduceAlleleResolution Source: https://genentech.github.io/midasHLA/reference/reduceAlleleResolution.html Demonstrates how to use reduceAlleleResolution to reduce the resolution of a character vector of HLA allele numbers to level 2. ```r reduceAlleleResolution(c("A*01", "A*01:24", "C*05:24:55:54"), 2) #> [1] "A*01" "A*01" "C*05" ``` -------------------------------- ### Example Kir Call Data Source: https://genentech.github.io/midasHLA/reference/getKirCalls.html Displays sample data representing Kir calls, formatted as a numerical table. This format is useful for understanding the structure and content of the data. ```text #> 991 1 0 0 0 0 1 0 1 #> 992 1 0 0 0 0 1 0 1 #> 993 0 1 1 1 1 0 1 1 #> 994 1 0 0 0 0 1 0 1 #> 995 1 0 0 0 0 1 0 1 #> 996 1 0 0 0 0 1 0 1 #> 997 1 0 0 0 0 1 0 1 #> 998 1 1 1 1 1 1 1 1 #> 999 1 1 1 0 1 1 1 1 #> 1000 1 0 1 0 1 1 1 1 ``` -------------------------------- ### Example Usage of omnibusTest Source: https://genentech.github.io/midasHLA/reference/omnibusTest.html Demonstrates how to use the omnibusTest function after preparing MiDAS data and defining a base linear model. It shows the definition of omnibus groups and the function call. ```R midas <- prepareMiDAS(hla_calls = MiDAS_tut_HLA, colData = MiDAS_tut_pheno, experiment = "hla_aa") # define base model object <- lm(disease ~ term, data = midas) omnibusTest(object, omnibus_groups = list( A_29 = c("A_29_D", "A_29_A"), A_43 = c("A_43_Q", "A_43_R") )) ``` -------------------------------- ### Get Experiment Population Multiplicator Function Signature Source: https://genentech.github.io/midasHLA/reference/getExperimentPopulationMultiplicator.html Shows the generic function signature and its S3 method specializations for matrix and SummarizedExperiment objects. ```R getExperimentPopulationMultiplicator(experiment) # S3 method for matrix getExperimentPopulationMultiplicator(experiment) # S3 method for SummarizedExperiment getExperimentPopulationMultiplicator(experiment) ``` -------------------------------- ### Example Usage of summariseAAPosition Source: https://genentech.github.io/midasHLA/reference/summariseAAPosition.html Demonstrates how to use the summariseAAPosition function with provided HLA call data and a specific amino acid position. The output shows the amino acid residue and its frequency across different HLA alleles. ```r summariseAAPosition(MiDAS_tut_HLA, "A_9") #> HLA-A (9) #> 1 F #> 2 S #> 3 T #> 4 Y #> HLA-A alleles #> 1 *01:01, *01:234, *01:237, *01:274, *01:98, *02:01, *02:02, *02:03, *02:07, *02:211, *02:22, *02:60, *02:614, *02:642, *02:686, *02:753, *02:763, *03:01, *03:02, *03:24, *03:312, *24:104, *31:21, *32:01, *32:02, *32:116, *74:01 #> 2 *01:02, *03:72, *11:88, *23:01, *23:17, *23:18, *24:02, *24:03, *24:04, *24:07, *24:20, *24:95, *26:16, *30:01, *30:02, *30:04 #> 3 *03:205, *11:43, *29:01, *29:02, *29:119, *31:01, *31:08, *33:01, *33:03, *33:05, *33:125, *33:163 #> 4 *01:43, *02:05, *02:06, *02:08, *02:10, *02:324, *11:01, *11:02, *11:03, *11:12, *11:306, *11:50, *24:50, *25:01, *25:09, *25:25, *26:01, *26:02, *26:03, *26:08, *33:51, *34:01, *34:02, *66:01, *68:01, *68:02, *68:04, *68:16, *68:164, *68:17, *68:23, *68:66, *69:01 #> count frequency #> 1 1037 51.85% #> 2 379 18.95% #> 3 155 7.75% #> 4 429 21.45% ``` -------------------------------- ### Get Frequencies with Custom Reference Populations Source: https://genentech.github.io/midasHLA/reference/getFrequencies.html This snippet shows how to call getFrequencies to compare sample frequencies against a custom set of reference populations. It specifies the object, experiment type, and custom reference populations with their corresponding allele frequencies. ```r getFrequencies( object = MiDAS_tut_object, experiment = "hla_alleles", compare = TRUE, ref_pop = list( hla_alleles = c("USA NMDP Chinese", "USA NMDP European Caucasian") ), ref = list(hla_alleles = allele_frequencies) ) ``` -------------------------------- ### Prepare MiDAS Data and Run Analysis Source: https://genentech.github.io/midasHLA/reference/kableResults.html This snippet shows the typical workflow for preparing MiDAS data, running a linear model, and then executing the MiDAS analysis. It requires the MiDAS_tut_HLA and MiDAS_tut_pheno datasets, and specifies an additive inheritance model. ```R midas <- prepareMiDAS(hla_calls = MiDAS_tut_HLA, colData = MiDAS_tut_pheno, experiment = "hla_alleles") object <- lm(disease ~ term, data = midas) res <- runMiDAS(object, experiment = "hla_alleles", inheritance_model = "additive") ``` -------------------------------- ### R S3 Method: getExperimentFrequencies for SummarizedExperiment Source: https://genentech.github.io/midasHLA/reference/getExperimentFrequencies.html Demonstrates the S3 method signature for getExperimentFrequencies when the input 'experiment' is a SummarizedExperiment object. ```R # S3 method for SummarizedExperiment getExperimentFrequencies( experiment, pop_mul = NULL, carrier_frequency = FALSE, ref = NULL ) ``` -------------------------------- ### Get Experiments from MiDAS Object Source: https://genentech.github.io/midasHLA/reference/MiDAS-class.html Retrieves the experiments stored within a MiDAS object. ```R getExperiments(object) ``` -------------------------------- ### getExperiments Source: https://genentech.github.io/midasHLA/reference/MiDAS-class.html Retrieves the experiments contained within a MiDAS object. ```APIDOC ## getExperiments ### Description Retrieves the experiments contained within a MiDAS object. ### Method S4 method ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response Instance of class MiDAS #### Response Example N/A ``` -------------------------------- ### Get KIR Calls from MiDAS Object Source: https://genentech.github.io/midasHLA/reference/MiDAS-class.html Retrieves KIR call data from a MiDAS object. ```R getKirCalls(object) ``` -------------------------------- ### Get HLA Calls from MiDAS Object Source: https://genentech.github.io/midasHLA/reference/MiDAS-class.html Retrieves HLA call data from a MiDAS object. ```R getHlaCalls(object) ``` -------------------------------- ### Get Omnibus Groups from MiDAS Object Source: https://genentech.github.io/midasHLA/reference/MiDAS-class.html Retrieves omnibus groups for a specified experiment from a MiDAS object. ```R getOmnibusGroups(object, experiment) ``` -------------------------------- ### R S3 Method: getExperimentFrequencies for matrix Source: https://genentech.github.io/midasHLA/reference/getExperimentFrequencies.html Illustrates the S3 method signature for getExperimentFrequencies when the input 'experiment' is a matrix. ```R # S3 method for matrix getExperimentFrequencies( experiment, pop_mul = NULL, carrier_frequency = FALSE, ref = NULL ) ``` -------------------------------- ### Basic usage of hlaCallsToCounts Source: https://genentech.github.io/midasHLA/reference/hlaCallsToCounts.html Demonstrates the basic call to the `hlaCallsToCounts` function with HLA calls data and an option to check the format. ```r hlaCallsToCounts(hla_calls, check_hla_format = TRUE) ``` -------------------------------- ### Get Alleles for Amino Acid Position Source: https://genentech.github.io/midasHLA/reference/MiDAS-class.html Retrieves alleles associated with a specific amino acid position from a MiDAS object. ```R getAllelesForAA(object, aa_pos) ``` -------------------------------- ### Call prepareMiDAS_hla_alleles Function Source: https://genentech.github.io/midasHLA/reference/prepareMiDAS_hla_alleles.html This snippet shows the basic syntax for calling the prepareMiDAS_hla_alleles function with the required hla_calls argument and other unspecified arguments. ```r prepareMiDAS_hla_alleles(hla_calls, ...) ``` -------------------------------- ### Get Placeholder Name Source: https://genentech.github.io/midasHLA/reference/getPlaceholder.html Retrieves the placeholder name from a MiDAS object. This function is useful for identifying the default term used in the object. ```R getPlaceholder(object = MiDAS_tut_object) #> [1] "term" ``` -------------------------------- ### experimentMatToDf Source: https://genentech.github.io/midasHLA/reference/experimentMatToDf.html Transforms an experiment matrix into a data frame by transposing it and adding a column for the original matrix's column names. ```APIDOC ## Function: experimentMatToDf ### Description Transposes the input matrix `mat` and inserts the column names of the input `mat` as an 'ID' column. This function is useful for converting experiment matrices into a more manageable data frame format. ### Arguments * **mat** (Matrix) - Required - The input matrix to be transformed. ### Value * Data Frame - A data frame representation of the input `mat` after transposition and the addition of an 'ID' column. ### Example ```r # Assuming 'my_matrix' is a matrix with column names # result_df <- experimentMatToDf(my_matrix) ``` ``` -------------------------------- ### Get Placeholder Column Name from MiDAS Object Source: https://genentech.github.io/midasHLA/reference/MiDAS-class.html Retrieves the name of the placeholder column used for statistical modeling from a MiDAS object. ```R getPlaceholder(object) ``` -------------------------------- ### Get HLA allele resolution Source: https://genentech.github.io/midasHLA/reference/getAlleleResolution.html Demonstrates how to use getAlleleResolution to determine the resolution of HLA allele strings. Requires a character vector of allele names. ```R allele <- c("A*01:01", "A*01:02") getAlleleResolution(allele) #> [1] 4 4 ``` -------------------------------- ### Apply Inheritance Model Function Signature Source: https://genentech.github.io/midasHLA/reference/applyInheritanceModel.html Shows the function signature for applyInheritanceModel, including its arguments for experiment data and the desired inheritance model. Supports S3 methods for matrix and SummarizedExperiment. ```R applyInheritanceModel( experiment, inheritance_model = c("dominant", "recessive", "additive", "overdominant") ) # S3 method for matrix applyInheritanceModel( experiment, inheritance_model = c("dominant", "recessive", "additive", "overdominant") ) # S3 method for SummarizedExperiment applyInheritanceModel( experiment, inheritance_model = c("dominant", "recessive", "additive", "overdominant") ) ``` -------------------------------- ### readHlaAlignments Source: https://genentech.github.io/midasHLA/reference/readHlaAlignments.html Reads HLA allele alignments from a file or a specified gene. It supports trimming sequences to the start codon and defining characters for unknown sequences. ```APIDOC ## readHlaAlignments ### Description Reads HLA allele alignments from a file or a specified gene. It supports trimming sequences to the start codon and defining characters for unknown sequences. ### Arguments * **file** (string) - Path to the input file. * **gene** (string, optional) - Character vector of length one specifying the name of a gene for which alignment is required. If NULL, the `file` parameter is used. * **trim** (boolean, optional) - Logical indicating if alignment should be trimmed to the start codon of the mature protein. Defaults to FALSE. * **unkchar** (string, optional) - Character to be used to represent positions with unknown sequence. Defaults to "". ### Value Matrix containing HLA allele alignments. Rownames correspond to allele numbers and columns to positions in the alignment. Sequences following the termination codon are marked as empty character (`""`). Unknown sequences are marked with a character of choice, by default `""`. Stop codons are represented by a hash (X). Insertion and deletions are marked with period (.). ### Details HLA allele alignment files should follow the EBI database format. Protein alignment files from the EBI database are shipped with the package and can be accessed using the `gene` parameter. If `gene` is set to `NULL`, the `file` parameter is used. Alignments for DRB1, DRB3, DRB4 and DRB5 genes are provided as a single file in the EBI database but are separated here. For alleles without sequence defined in the original alignment files, their sequence has been inferred based on known higher resolution alleles. ### Examples ```R hla_alignments <- readHlaAlignments(gene = "A") ``` ``` -------------------------------- ### Get HLA Allele Frequencies Source: https://genentech.github.io/midasHLA/articles/MiDAS_vignette.html Retrieves HLA allele frequencies from a MiDAS object and compares them with published data. Use this function to explore allele distributions. ```r freq <- getFrequencies( object = midas, carrier_frequency = FALSE, experiment = "hla_alleles", compare = TRUE ) ``` -------------------------------- ### Basic Usage of checkAlleleFormat Source: https://genentech.github.io/midasHLA/reference/checkAlleleFormat.html Demonstrates how to use the `checkAlleleFormat` function with a vector of HLA allele strings. Returns a logical vector indicating validity. ```R allele <- c("A*01:01", "A*01:02") checkAlleleFormat(allele) #> [1] TRUE TRUE ``` -------------------------------- ### Get Frequencies from MiDAS Object Source: https://genentech.github.io/midasHLA/reference/MiDAS-class.html Calculates and retrieves allele or gene frequencies for a specified experiment from a MiDAS object. Can optionally compare frequencies to reference populations. ```R getFrequencies( object, experiment, carrier_frequency = FALSE, compare = FALSE, ref_pop = list(hla_alleles = c("USA NMDP African American pop 2", "USA NMDP Chinese", "USA NMDP European Caucasian", "USA NMDP Hispanic South or Central American", "USA NMDP Japanese", "USA NMDP North American Amerindian", "USA NMDP South Asian Indian"), kir_genes = c("USA California African American KIR", "USA California Asian American KIR", "USA California Caucasians KIR", "USA California Hispanic KIR")), ref = list(hla_alleles = allele_frequencies, kir_genes = kir_frequencies) ) ``` -------------------------------- ### Prepare and Run MiDAS for KIR Genes Source: https://genentech.github.io/midasHLA/articles/MiDAS_tutorial.html This snippet prepares MiDAS data including KIR genes and HLA-KIR interactions, then runs the MiDAS analysis specifically for KIR gene associations. It sets frequency cutoffs and exponentiates the results for easier interpretation. ```r HLAKIR <- prepareMiDAS( hla_calls = dat_HLA, kir_calls = dat_KIR, colData = dat_pheno, experiment = c("hla_NK_ligands","kir_genes", "hla_kir_interactions") ) KIR_model <- glm(disease ~ term, data = HLAKIR, family = binomial()) KIR_results <- runMiDAS( KIR_model, experiment = "kir_genes", lower_frequency_cutoff = 0.02, upper_frequency_cutoff = 0.98, exponentiate = TRUE ) kableResults(KIR_results) ``` -------------------------------- ### Prepare MiDAS Data for HLA Heterozygosity and Divergence Source: https://genentech.github.io/midasHLA/articles/MiDAS_tutorial.html Prepares the MiDAS object for analysis of HLA heterozygosity and divergence. Ensure 'dat_HLA' and 'dat_pheno' are loaded and 'experiment' is set to 'hla_het' and 'hla_divergence'. ```r HLA_het <- prepareMiDAS( hla_calls = dat_HLA, colData = dat_pheno, experiment = c("hla_het","hla_divergence") ) ``` -------------------------------- ### Get Genes from HLA Calls Source: https://genentech.github.io/midasHLA/reference/getHlaCallsGenes.html Use this function to extract a character vector of gene names from an HLA calls data frame. Ensure the input `hla_calls` is correctly formatted as returned by the `readHlaCalls` function. ```r getHlaCallsGenes(hla_calls) ``` -------------------------------- ### Get HLA Calls from MiDAS Object Source: https://genentech.github.io/midasHLA/reference/getHlaCalls.html This snippet demonstrates how to use the getHlaCalls function to extract HLA typing data from a MiDAS object. The output is a data frame containing HLA alleles for multiple loci. ```r getHlaCalls(object = MiDAS_tut_object) ``` -------------------------------- ### Get Variable Amino Acid Positions Source: https://genentech.github.io/midasHLA/reference/getVariableAAPos.html Finds variable amino acid positions in an alignment. By default, it considers only standard amino acid characters (A-Z) and excludes indels or unknown characters from being counted as variability. ```r alignment <- readHlaAlignments(gene = "TAP1") getVariableAAPos(alignment) ``` -------------------------------- ### Call prepareMiDAS_hla_het Function Source: https://genentech.github.io/midasHLA/reference/prepareMiDAS_hla_het.html This snippet shows the basic usage of the prepareMiDAS_hla_het function. Ensure hla_calls is properly formatted from readHlaCalls. ```r prepareMiDAS_hla_het(hla_calls, hla_het_resolution = 8, ...) ``` -------------------------------- ### R Function Signature: getExperimentFrequencies Source: https://genentech.github.io/midasHLA/reference/getExperimentFrequencies.html Shows the base function signature for getExperimentFrequencies, including its arguments and default values. ```R getExperimentFrequencies( experiment, pop_mul = NULL, carrier_frequency = FALSE, ref = NULL ) ```