Write Haplotype Feature Matrix as Numeric Dosage Table
Source:R/haplotypes.R
write_haplotype_numeric.RdWrites the haplotype dosage matrix in a tab-delimited format with
haplotype alleles as rows and individuals as columns. Metadata columns
(hap_id, CHR, start_bp, end_bp,
n_snps, alleles, frequency) precede the individual
columns. Individual cells contain 0/1/2/NA dosage values.
Usage
write_haplotype_numeric(
hap_matrix,
out_file,
haplotypes = NULL,
snp_info = NULL,
hap_info = NULL,
sep = "\t",
na_str = "NA",
min_freq = 0.01,
missing_string = ".",
verbose = TRUE
)Arguments
- hap_matrix
Numeric matrix (individuals x haplotype alleles) from
build_haplotype_feature_matrix.- out_file
Output file path.
- haplotypes
List from
extract_haplotypes. When supplied together withsnp_info, theallelesandfrequencymetadata columns are populated.- snp_info
Data frame with
CHR,POS,REF,ALT. Required forallelescolumn.- hap_info
Data frame of exact per-column metadata from
build_haplotype_feature_matrix()\$info. When supplied, thealleles,frequency,n_snps,CHR,start_bp, andend_bpcolumns are written directly from this object without any reconstruction. Recommended - passhap_info = feat_out\$infowherefeat_outis the return value ofbuild_haplotype_feature_matrix(). DefaultNULL(falls back to legacy reconstruction fromhaplotypesandsnp_info).- sep
Field separator. Default
",".- na_str
NA string. Default
"NA".- min_freq
Minimum frequency used when computing
alleles. Default0.01.- missing_string
Missing genotype marker. Default
".".- verbose
Logical. Default
TRUE.