### Install HaploVar from GitHub Source: https://github.com/tessamacnish/haplovar/blob/main/vignettes/introduction.html Install the development version of HaploVar from GitHub using the devtools package. Ensure devtools is installed first. ```r #install.packages("devtools") #devtools::install_github("TessaMacNish/HaploVar") ``` -------------------------------- ### Install HaploVar Package Source: https://github.com/tessamacnish/haplovar/blob/main/README.md Installs the development version of HaploVar from GitHub or directly from CRAN. Requires the devtools package for GitHub installation. ```r install.packages("devtools") devtools::install_github("TessaMacNish/HaploVar") ``` ```r install.packages("HaploVar") ``` ```r library(HaploVar) ``` -------------------------------- ### Complete GWAS Pipeline Example Source: https://context7.com/tessamacnish/haplovar/llms.txt Demonstrates a full workflow for GWAS analysis using HaploVar, including VCF preprocessing and haplotype definition. This example uses built-in data for demonstration purposes. ```r library(HaploVar) data("vcf") data("LD") ``` -------------------------------- ### Install HaploVar from CRAN Source: https://github.com/tessamacnish/haplovar/blob/main/vignettes/introduction.html Install the HaploVar package directly from CRAN. This is the recommended method for stable releases. ```r install.packages("HaploVar") ``` -------------------------------- ### Install HaploVar Source: https://context7.com/tessamacnish/haplovar/llms.txt Install the package from CRAN or the development version from GitHub. ```r # Install from CRAN install.packages("HaploVar") # Or install development version from GitHub install.packages("devtools") devtools::install_github("TessaMacNish/HaploVar") library(HaploVar) ``` -------------------------------- ### Load HaploVar Package Source: https://github.com/tessamacnish/haplovar/blob/main/vignettes/introduction.html Load the HaploVar package into your R session to access its functions. This should be done after installation. ```r library(HaploVar) ``` -------------------------------- ### Read VCF and LD Matrix in R Source: https://github.com/tessamacnish/haplovar/blob/main/README.md Reads VCF and LD matrix files into R using the crosshap package. Ensure crosshap is installed and loaded. ```r install.packages("crosshap") library(crosshap) VCF <- read_vcf("vcf") LD <- read_LD("output.ld",vcf = VCF) ``` -------------------------------- ### define_haplotypes Source: https://context7.com/tessamacnish/haplovar/llms.txt Defines local haplotypes from VCF and LD matrix inputs using DBSCAN clustering. Returns a list of haplotype tables where each table contains SNP genotypes for all individuals within that haplotype. Haplotypes are named based on their genomic start and end positions. ```APIDOC ## define_haplotypes ### Description Defines local haplotypes from VCF and LD matrix inputs using DBSCAN clustering. Returns a list of haplotype tables where each table contains SNP genotypes for all individuals within that haplotype. Haplotypes are named based on their genomic start and end positions. ### Method R function ### Endpoint N/A (R function) ### Parameters #### Arguments - **vcf** (data.frame) - VCF file with SNP genotypes. - **LD** (matrix) - Linkage disequilibrium matrix. - **epsilon** (numeric) - DBSCAN density parameter (0-1, higher = larger haplotypes). Default is 0.6. - **MGmin** (integer) - Minimum SNPs required for a cluster to form a haplotype. - **hetmiss_as** (character) - How to treat heterozygous missing alleles. Options: "allele" (treat as heterozygous), "missing" (treat as missing). - **keep_outliers** (logical) - Whether to remove outlier SNPs. ### Request Example ```r library(HaploVar) # Load example data data("vcf") # VCF file with SNP genotypes data("LD") # Linkage disequilibrium matrix # Define haplotypes with custom parameters haplotype_list <- define_haplotypes( vcf = vcf, LD = LD, epsilon = 0.8, MGmin = 30, hetmiss_as = "allele", keep_outliers = FALSE ) # Access individual haplotype tables haplotype_table <- haplotype_list[[1]] print(names(haplotype_list)) # Shows haplotype names like "hap_1234_5678" head(haplotype_table[, 1:5]) ``` ### Response #### Success Response A list of haplotype tables. Each table contains SNP genotypes for all individuals within a specific haplotype. Haplotypes are named based on their genomic start and end positions (e.g., "hap_1234_5678"). #### Response Example ```r # Output: Each row is a SNP, each column is an individual # R4155_R4155 R4156_R4156 R4157_R4157 R4158_R4158 R4159_R4159 # snp_001 0|0 0|1 0|0 1|1 0|0 # snp_002 0|0 0|1 0|0 1|1 0|0 ``` ``` -------------------------------- ### Genomic Selection Pipeline Workflow Source: https://context7.com/tessamacnish/haplovar/llms.txt Full workflow for defining haplotypes and generating marker matrices for genomic selection models. ```r library(HaploVar) data("vcf") data("LD") # Step 1: Define haplotypes with optimized parameters # Test different epsilon values for your data for (eps in c(0.6, 0.7, 0.8, 0.9)) { haps <- define_haplotypes(vcf, LD, epsilon = eps) print(paste("epsilon =", eps, ":", length(haps), "haplotypes")) } # Step 2: Generate genomic selection format (format 3) gs_data <- haplotype_variants( vcf = vcf, LD = LD, epsilon = 0.8, MGmin = 30, minFreq = 2, format = 3 # Transposed dosage: individuals as rows ) # Step 3: Save marker matrix for genomic selection write.csv( gs_data, "genomic_selection_markers.csv", row.names = TRUE, quote = FALSE ) # Step 4: Use with genomic selection tools # Example with rrBLUP: # library(rrBLUP) # marker_matrix <- as.matrix(gs_data) # phenotypes <- read.csv("phenotypes.csv") # model <- mixed.solve(y = phenotypes$trait, Z = marker_matrix) # gebv <- marker_matrix %*% model$u # Genomic estimated breeding values ``` -------------------------------- ### Define Haplotypes Globally Source: https://github.com/tessamacnish/haplovar/blob/main/vignettes/introduction.html Runs `define_haplotypes` on multiple VCF and LD matrix file pairs and collates the results. Requires lists of VCF files, LD matrices, and a list of epsilon values, one for each VCF file. ```R vcf2 <- vcf vcf_list <- list(vcf, vcf2) LD2 <- LD LD_list <- list(LD, LD2) epsilon_list <- c(0.8, 0.8) haplotype_list_global <- define_haplotypes_globally(vcf_list, LD_list, epsilon = epsilon_list) ``` -------------------------------- ### Define Haplotypes using HaploVar Source: https://github.com/tessamacnish/haplovar/blob/main/vignettes/introduction.html Run the `define_haplotypes` function with a VCF and LD matrix. The epsilon parameter controls haplotype density and should be tuned for your data. ```r haplotype_list <- define_haplotypes(vcf, LD, epsilon = 0.8) #this produces a list of haplotype tables ``` -------------------------------- ### Inspect Haplotype Data Formats Source: https://github.com/tessamacnish/haplovar/blob/main/vignettes/introduction.html Display the structure of different haplotype data formats using the head function. ```R head(format4, c(5,6)) ``` ```R head(format5, c(5,3)) ``` ```R head(format6, c(5,10)) ``` -------------------------------- ### Display Head of Haplotype Table Source: https://github.com/tessamacnish/haplovar/blob/main/vignettes/introduction.html Shows the first 5 rows and 5 columns of a haplotype table. This table contains all SNPs within a defined haplotype and their genotypes. ```r head(haplotype_table, c(5,5)) ``` -------------------------------- ### Display Head of LD Matrix Source: https://github.com/tessamacnish/haplovar/blob/main/vignettes/introduction.html Displays the first 5 rows and 5 columns of an LD (Linkage Disequilibrium) matrix. This format is required for haplotype calculations. ```r head(LD, c(5,5)) ``` -------------------------------- ### Identify Haplotype Variants (Format 1) Source: https://github.com/tessamacnish/haplovar/blob/main/vignettes/introduction.html Defines local haplotypes and identifies variants, outputting in format 1, which is the default. This format shows haplotype variants represented by letters (A-ZZ) for each haplotype, with '0' indicating absence. ```R format1 <- haplotype_variants(vcf, LD, epsilon = 0.8, format = 1) head(format1, c(5,6)) ``` -------------------------------- ### Identify Haplotype Variants (Format 3) Source: https://github.com/tessamacnish/haplovar/blob/main/vignettes/introduction.html Identifies haplotype variants and formats output for genomic selection tools. ```R format3 <- haplotype_variants(vcf, LD, epsilon = 0.8, format = 3) head(format3, c(5,3)) ``` -------------------------------- ### Identify Haplotype Variants (Format 5) Source: https://github.com/tessamacnish/haplovar/blob/main/vignettes/introduction.html Identifies haplotype variants and formats output in format 5. ```R format5 <- haplotype_variants(vcf, LD, epsilon = 0.8, format = 5) ``` -------------------------------- ### Identify Haplotype Variants (Format 6) Source: https://github.com/tessamacnish/haplovar/blob/main/vignettes/introduction.html Identifies haplotype variants and formats output in format 6. ```R format6 <- haplotype_variants(vcf, LD, epsilon = 0.8, format = 6) ``` -------------------------------- ### Identify Haplotype Variants (Format 4) Source: https://github.com/tessamacnish/haplovar/blob/main/vignettes/introduction.html Identifies haplotype variants and formats output in format 4. ```R format4 <- haplotype_variants(vcf, LD, epsilon = 0.8, format = 4) ``` -------------------------------- ### Format Haplotype Variants for Genomic Prediction Source: https://github.com/tessamacnish/haplovar/blob/main/README.md Identifies haplotype variants and formats the output for genomic selection pipelines (format = 3). ```r format3 <- haplotype_variants(VCF, LD, epsilon = 0.8, format = 3) ``` -------------------------------- ### Collate Define Haplotypes Results Source: https://github.com/tessamacnish/haplovar/blob/main/vignettes/introduction.html Use this function to combine results from multiple `define_haplotypes` runs into a single list of haplotype tables. Ensure inputs are lists of VCF files and corresponding LD matrices. ```R haplotype_list2 <- haplotype_list list_outputs <- list(haplotype_list, haplotype_list2) collate_haplotype_list <- collate_define_haplotypes(list_outputs) ``` -------------------------------- ### Identify Haplotypes Variants Globally Source: https://github.com/tessamacnish/haplovar/blob/main/vignettes/introduction.html Run haplotype_variants across a list of VCF files, LD matrices, and epsilon values using the haplotype_variants_global function. ```R format1_global <- haplotype_variants_global(vcf_list, LD_list, epsilon = epsilon_list, format = 1) format2_global <- haplotype_variants_global(vcf_list, LD_list, epsilon = epsilon_list, format = 2) format3_global <- haplotype_variants_global(vcf_list, LD_list, epsilon = epsilon_list, format = 3) format4_global <- haplotype_variants_global(vcf_list, LD_list, epsilon = epsilon_list, format = 4) format5_global <- haplotype_variants_global(vcf_list, LD_list, epsilon = epsilon_list, format = 5) format6_global <- haplotype_variants_global(vcf_list, LD_list, epsilon = epsilon_list, format = 6) ``` -------------------------------- ### Define Haplotypes Globally Source: https://context7.com/tessamacnish/haplovar/llms.txt Process multiple VCF files and LD matrices across genomic regions. ```r library(HaploVar) data("vcf") data("LD") ``` -------------------------------- ### Define Local Haplotypes Source: https://context7.com/tessamacnish/haplovar/llms.txt Use define_haplotypes to identify haplotype groups based on VCF and LD matrix inputs. ```r library(HaploVar) # Load example data data("vcf") # VCF file with SNP genotypes data("LD") # Linkage disequilibrium matrix # Define haplotypes with custom parameters # epsilon: DBSCAN density parameter (0-1, higher = larger haplotypes) # MGmin: minimum SNPs required for a cluster to form a haplotype haplotype_list <- define_haplotypes( vcf = vcf, LD = LD, epsilon = 0.8, # Default is 0.6 MGmin = 30, # Minimum SNPs per haplotype hetmiss_as = "allele", # Treat missing alleles as heterozygous keep_outliers = FALSE # Remove outlier SNPs ) # Access individual haplotype tables haplotype_table <- haplotype_list[[1]] print(names(haplotype_list)) # Shows haplotype names like "hap_1234_5678" head(haplotype_table[, 1:5]) ``` -------------------------------- ### Define Haplotypes Globally Source: https://context7.com/tessamacnish/haplovar/llms.txt Use define_haplotypes_globally to process multiple VCF files and LD matrices for genome-wide haplotype analysis. Ensure epsilon values are optimized per region. ```r vcf_chr1 <- vcf vcf_chr2 <- vcf vcf_list <- list(vcf_chr1, vcf_chr2) LD_chr1 <- LD LD_chr2 <- LD LD_list <- list(LD_chr1, LD_chr2) epsilon_list <- c(0.8, 0.7) haplotype_list_global <- define_haplotypes_globally( vcf_list = vcf_list, LD_list = LD_list, epsilon = epsilon_list, MGmin = 30, hetmiss_as = "allele", keep_outliers = FALSE ) print(length(haplotype_list_global)) print(names(haplotype_list_global)) ``` -------------------------------- ### Define Haplotypes Source: https://github.com/tessamacnish/haplovar/blob/main/README.md Calculates local haplotypes from VCF and LD data. The epsilon parameter controls the threshold for haplotype definition. ```r haplotype_list <- define_haplotypes(VCF, LD, epsilon = 0.8) ``` -------------------------------- ### Display Head of VCF Data Source: https://github.com/tessamacnish/haplovar/blob/main/vignettes/introduction.html Shows the first 5 rows and 10 columns of a VCF data structure, illustrating the expected format for biallelic SNPs. ```r head(vcf, c(5,10)) ``` -------------------------------- ### Calculate Linkage Disequilibrium with PLINK Source: https://github.com/tessamacnish/haplovar/blob/main/README.md Calculates the linkage disequilibrium (LD) matrix from VCF data using PLINK. Ensure the output is square. ```bash plink --allow-extra-chr --r2 square --vcf vcf --out output.ld ``` -------------------------------- ### Format Haplotype Variants for GWAS Source: https://github.com/tessamacnish/haplovar/blob/main/README.md Formats haplotype variants for GWAS (format = 6) and saves the output to a VCF file. ```r write.table(format6, "output.vcf", sep = "\t", row.names = FALSE, col.names = TRUE, quote = FALSE) ``` -------------------------------- ### define_haplotypes_globally Source: https://context7.com/tessamacnish/haplovar/llms.txt Processes multiple VCF files and LD matrices across chromosomes or genomic regions. Allows different epsilon values for each region and returns a combined list of all haplotype tables. ```APIDOC ## define_haplotypes_globally ### Description Processes multiple VCF files and LD matrices across chromosomes or genomic regions. Allows different epsilon values for each region and returns a combined list of all haplotype tables. ### Method R function ### Endpoint N/A (R function) ### Parameters #### Arguments - **vcf_list** (list) - A list of VCF data frames, one for each chromosome or region. - **LD_list** (list) - A list of LD matrices, corresponding to the VCF files. - **epsilon_list** (list or numeric) - A list of epsilon values, one for each chromosome/region, or a single numeric value to apply globally. - **MGmin** (integer) - Minimum SNPs required for a cluster to form a haplotype. - **hetmiss_as** (character) - How to treat heterozygous missing alleles. Options: "allele" (treat as heterozygous), "missing" (treat as missing). - **keep_outliers** (logical) - Whether to remove outlier SNPs. ### Request Example ```r library(HaploVar) data("vcf") data("LD") # Assuming vcf and LD are already loaded and potentially split by chromosome # For demonstration, we'll use the same data multiple times vcf_list <- list(vcf, vcf) LD_list <- list(LD, LD) epsilon_list <- c(0.7, 0.9) # Different epsilon for each region combined_haplotypes <- define_haplotypes_globally( vcf_list = vcf_list, LD_list = LD_list, epsilon_list = epsilon_list, MGmin = 25, hetmiss_as = "missing", keep_outliers = TRUE ) # Accessing results print(names(combined_haplotypes)) # Shows names for haplotypes across all regions ``` ### Response #### Success Response A single list containing all defined haplotype tables from all processed VCF files and LD matrices. Haplotypes are named to indicate their origin (e.g., chromosome/region and position). #### Response Example ```r # Example output structure (names will vary based on input data) # [[1]] # snp_001 snp_002 snp_003 # R4155_R4155 0|0 0|1 0|0 # R4156_R4156 0|1 0|0 1|0 # # [[2]] # snp_004 snp_005 # R4155_R4155 1|1 0|0 # R4156_R4156 0|0 1|1 ``` ``` -------------------------------- ### Extract First Haplotype Table Source: https://github.com/tessamacnish/haplovar/blob/main/vignettes/introduction.html Extracts the first haplotype table from the list generated by `define_haplotypes`. Each table is named by the position of its first and last SNP. ```r haplotype_table <- haplotype_list[[1]] #this is the first haplotype tables ``` -------------------------------- ### haplotype_variants Source: https://context7.com/tessamacnish/haplovar/llms.txt Defines local haplotypes and identifies haplotype variants for each individual. Outputs formatted data compatible with GWAS and genomic selection tools. Supports six output formats for different downstream analysis requirements. ```APIDOC ## haplotype_variants ### Description Defines local haplotypes and identifies haplotype variants for each individual. Outputs formatted data compatible with GWAS and genomic selection tools. Supports six output formats for different downstream analysis requirements. ### Method R function ### Endpoint N/A (R function) ### Parameters #### Arguments - **vcf** (data.frame) - VCF file with SNP genotypes. - **LD** (matrix) - Linkage disequilibrium matrix. - **epsilon** (numeric) - DBSCAN density parameter (0-1, higher = larger haplotypes). Default is 0.6. - **MGmin** (integer) - Minimum SNPs required for a cluster to form a haplotype. - **minFreq** (integer) - Minimum number of individuals with a variant for it to be included. - **hetmiss_as** (character) - How to treat heterozygous missing alleles. Options: "allele" (treat as heterozygous), "missing" (treat as missing). - **keep_outliers** (logical) - Whether to remove outlier SNPs. - **format** (integer) - The desired output format (1-6). ### Request Example ```r library(HaploVar) data("vcf") data("LD") # Format 1: Default haplotype variant labels (A, B, C, etc.) format1 <- haplotype_variants( vcf = vcf, LD = LD, epsilon = 0.8, MGmin = 30, minFreq = 2, hetmiss_as = "allele", keep_outliers = FALSE, format = 1 ) head(format1[, 1:6]) # Format 2: Dosage format for GWAS (0, 1, 2 copies) format2 <- haplotype_variants(vcf, LD, epsilon = 0.8, format = 2) head(format2[, 1:6]) # Format 3: Transposed dosage for genomic selection (individuals as rows) format3 <- haplotype_variants(vcf, LD, epsilon = 0.8, format = 3) head(format3[, 1:3]) # Format 4: Centered dosage for GWAS (-1, 0, 1) format4 <- haplotype_variants(vcf, LD, epsilon = 0.8, format = 4) # Format 5: Transposed centered dosage for genomic selection format5 <- haplotype_variants(vcf, LD, epsilon = 0.8, format = 5) # Format 6: VCF-compatible format for GWAS tools format6 <- haplotype_variants(vcf, LD, epsilon = 0.8, format = 6) head(format6[, 1:10]) # Save output for downstream analysis write.csv(format3, "genomic_selection_input.csv", row.names = TRUE, quote = FALSE) write.table(format6, "gwas_input.vcf", sep = "\t", row.names = FALSE, quote = FALSE) ``` ### Response #### Success Response Returns data formatted according to the specified `format` argument. The structure varies based on the format: - **Format 1**: Haplotype variant labels (e.g., A, B, C). - **Format 2**: Dosage format (0, 1, 2 copies) for GWAS. - **Format 3**: Transposed dosage (individuals as rows) for genomic selection. - **Format 4**: Centered dosage (-1, 0, 1) for GWAS. - **Format 5**: Transposed centered dosage for genomic selection. - **Format 6**: VCF-compatible format for GWAS tools. #### Response Example ```r # Example for Format 1: # MARKER CHROM POS R4155_R4155 R4156_R4156 R4157_R4157 # hap_1234_5678 C01 1234 A|A A|B A|A # Example for Format 6: # #CHROM POS ID REF ALT QUAL FILTER INFO FORMAT R4155_R4155 # C01 1234 hap_1234_5678_A . . . PASS . GT 1|1 ``` ``` -------------------------------- ### Identify Haplotype Variants (Format 2) Source: https://github.com/tessamacnish/haplovar/blob/main/vignettes/introduction.html Identifies haplotype variants and formats output for GWAS tools. Numbers represent the count of each haplotype variant (0, 1, or 2 copies). ```R format2 <- haplotype_variants(vcf, LD, epsilon = 0.8, format = 2) head(format2, c(5,6)) ``` -------------------------------- ### Identify Haplotype Variants Source: https://context7.com/tessamacnish/haplovar/llms.txt Generate formatted haplotype variant data for downstream GWAS or genomic selection tools using six different output formats. ```r library(HaploVar) data("vcf") data("LD") # Format 1: Default haplotype variant labels (A, B, C, etc.) format1 <- haplotype_variants( vcf = vcf, LD = LD, epsilon = 0.8, MGmin = 30, minFreq = 2, # Minimum individuals with variant hetmiss_as = "allele", keep_outliers = FALSE, format = 1 ) head(format1[, 1:6]) # Format 2: Dosage format for GWAS (0, 1, 2 copies) format2 <- haplotype_variants(vcf, LD, epsilon = 0.8, format = 2) head(format2[, 1:6]) # Format 3: Transposed dosage for genomic selection (individuals as rows) format3 <- haplotype_variants(vcf, LD, epsilon = 0.8, format = 3) head(format3[, 1:3]) # Format 4: Centered dosage for GWAS (-1, 0, 1) format4 <- haplotype_variants(vcf, LD, epsilon = 0.8, format = 4) # Format 5: Transposed centered dosage for genomic selection format5 <- haplotype_variants(vcf, LD, epsilon = 0.8, format = 5) # Format 6: VCF-compatible format for GWAS tools format6 <- haplotype_variants(vcf, LD, epsilon = 0.8, format = 6) head(format6[, 1:10]) # Save output for downstream analysis write.csv(format3, "genomic_selection_input.csv", row.names = TRUE, quote = FALSE) write.table(format6, "gwas_input.vcf", sep = "\t", row.names = FALSE, quote = FALSE) ``` -------------------------------- ### Define and Export Haplotypes for GWAS Source: https://context7.com/tessamacnish/haplovar/llms.txt Defines haplotypes from VCF and LD data, then exports them in VCF format for GWAS tools. ```r haplotype_list <- define_haplotypes(vcf, LD, epsilon = 0.8) print(paste("Found", length(haplotype_list), "haplotypes")) # Step 4: Generate GWAS-compatible output (format 6 = VCF) gwas_input <- haplotype_variants( vcf = vcf, LD = LD, epsilon = 0.8, MGmin = 30, minFreq = 2, format = 6 ) # Step 5: Save for GWAS analysis write.table( gwas_input, "haplotype_gwas.vcf", sep = "\t", row.names = FALSE, col.names = TRUE, quote = FALSE ) ``` -------------------------------- ### Save Formatted Haplotype Variants Source: https://github.com/tessamacnish/haplovar/blob/main/README.md Saves the formatted haplotype variants to a CSV file for use in genomic selection pipelines. ```r write.csv(format3, "output.csv", row.names=TRUE, quote = FALSE ) ``` -------------------------------- ### Generate Haplotype Variants Globally Source: https://context7.com/tessamacnish/haplovar/llms.txt Utilize haplotype_variants_global to generate genome-wide haplotype variants in various formats. Specify the desired format (1, 2, 3, or 6) for the output table. ```r library(HaploVar) data("vcf") data("LD") vcf_list <- list(vcf, vcf) LD_list <- list(LD, LD) epsilon_list <- c(0.8, 0.8) format1_global <- haplotype_variants_global( vcf_list = vcf_list, LD_list = LD_list, epsilon = epsilon_list, MGmin = 30, minFreq = 2, format = 1 ) format2_global <- haplotype_variants_global(vcf_list, LD_list, epsilon_list, format = 2) format3_global <- haplotype_variants_global(vcf_list, LD_list, epsilon_list, format = 3) format6_global <- haplotype_variants_global(vcf_list, LD_list, epsilon_list, format = 6) write.csv(format3_global, "genome_wide_genomic_selection.csv", row.names = TRUE) write.table(format6_global, "genome_wide_gwas.vcf", sep = "\t", row.names = FALSE) ``` -------------------------------- ### Collate Haplotype Variants Source: https://context7.com/tessamacnish/haplovar/llms.txt Combine multiple haplotype variant tables into a single table using collate_haplotype_variants. Ensure the format parameter matches the format used for the input tables. ```r library(HaploVar) data("vcf") data("LD") format1_chr1 <- haplotype_variants(vcf, LD, epsilon = 0.8, format = 1) format1_chr2 <- haplotype_variants(vcf, LD, epsilon = 0.7, format = 1) format3_chr1 <- haplotype_variants(vcf, LD, epsilon = 0.8, format = 3) format3_chr2 <- haplotype_variants(vcf, LD, epsilon = 0.7, format = 3) format6_chr1 <- haplotype_variants(vcf, LD, epsilon = 0.8, format = 6) format6_chr2 <- haplotype_variants(vcf, LD, epsilon = 0.7, format = 6) format1_list <- list(format1_chr1, format1_chr2) format1_combined <- collate_haplotype_variants(format1_list, format = 1) format3_list <- list(format3_chr1, format3_chr2) format3_combined <- collate_haplotype_variants(format3_list, format = 3) format6_list <- list(format6_chr1, format6_chr2) format6_combined <- collate_haplotype_variants(format6_list, format = 6) write.csv(format3_combined, "combined_genomic_selection.csv", row.names = TRUE) write.table(format6_combined, "combined_gwas.vcf", sep = "\t", row.names = FALSE) ``` -------------------------------- ### Collate Define Haplotypes Results Source: https://context7.com/tessamacnish/haplovar/llms.txt Use collate_define_haplotypes to combine multiple haplotype lists generated from separate calls to define_haplotypes. This is useful for merging results from different chromosomes or regions. ```r library(HaploVar) data("vcf") data("LD") haplotype_list_chr1 <- define_haplotypes(vcf, LD, epsilon = 0.8) haplotype_list_chr2 <- define_haplotypes(vcf, LD, epsilon = 0.7) haplotype_list_chr3 <- define_haplotypes(vcf, LD, epsilon = 0.8) list_of_haplotype_lists <- list( haplotype_list_chr1, haplotype_list_chr2, haplotype_list_chr3 ) all_haplotypes <- collate_define_haplotypes(list_of_haplotype_lists) print(length(all_haplotypes)) print(names(all_haplotypes)) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.