Function to perform allele flip QC and harmonization on the weights and GWAS against LD for a region. FIXME: GWAS loading function from Haochen for both tabix & column-mapping yml application
Source:R/twas.R
harmonize_twas.RdFunction Conditions: - processes data in the format of either the output from load_twas_weights/generate_twas_db or refined_twas_weights_data from twas pipeline. - For the first format, we expect there is only one gene/events's information, that can be accessed through `region_info_obj` and refined_twas_weights_data contains per region multiple gene/event's refined weights data.
Usage
harmonize_twas(
twas_weights_data,
ld_meta_file_path,
gwas_meta_file,
ld_reference_sample_size,
column_file_path = NULL,
comment_string = "#"
)Arguments
- twas_weights_data
List of list of twas weights output from from generate_twas_db function.
- ld_meta_file_path
Path to LD reference: either a PLINK2/PLINK1 prefix, or a tab-delimited metadata file with columns "#chrom", "start", "end", "path" (auto-detected).
- gwas_meta_file
A file path for a dataframe table with column of "study_id", "chrom" (integer), "file_path", "column_mapping_file". Each file in "file_path" column is tab-delimited dataframe of GWAS summary statistics with column name "chrom" (or #chrom" if tabix-indexed), "pos", "A2", "A1".
- ld_reference_sample_size
Sample size of the LD reference panel (integer). Required. Used to compute per-variant variance as 2*p*(1-p)*n/(n-1). For ADSP R4, use 17000.