R/ctwas_preprocess_weights.R
preprocess_weights.Rd
Preprocess PredictDB/FUSION weights and harmonize with LD reference
preprocess_weights(
weight_file,
region_info,
gwas_snp_ids,
snp_map,
LD_map = NULL,
type,
context,
weight_name = paste0(context, "_", type),
weight_format = c("PredictDB", "FUSION"),
drop_strand_ambig = TRUE,
filter_protein_coding_genes = TRUE,
scale_predictdb_weights = TRUE,
load_predictdb_LD = TRUE,
include_weight_LD = TRUE,
fusion_method = c("lasso", "enet", "top1", "blup", "bslmm", "best.cv"),
fusion_genome_version = NA,
top_n_snps = NULL,
LD_format = c("rds", "rdata", "csv", "txt", "custom"),
LD_loader_fun = NULL,
snpinfo_loader_fun = NULL,
varID_converter_fun = NULL,
ncore = 1,
logfile = NULL,
verbose = FALSE
)
filename of the '.db' file for PredictDB weights; or the directory containing '.wgt.RDat' files for FUSION weights.
a data frame of region definitions.
a vector of SNP IDs in GWAS summary statistics (z_snp$id).
a list of SNP-to-region map for the reference.
a data frame with filenames of LD matrices and SNP information for the regions.
Required when load_predictdb_LD = FALSE
.
a string, specifying QTL type of the weight file, e.g. expression, splicing, protein.
a string, specifying context (tissue/cell type) of the weight file, e.g. Liver, Lung, Brain.
a string, specifying name of the weight file.
By default, it is weight_name = paste0(context, "_", type)
a string, specifying format of the weight file, e.g. PredictDB, FUSION.
If TRUE remove strand ambiguous variants (A/T, G/C).
If TRUE, keep protein coding genes only. This option is only for PredictDB weights.
If TRUE, scale PredictDB weights by the variance. This is because PredictDB weights assume that variant genotypes are not standardized, but our implementation assumes standardized variant genotypes. This option is only for PredictDB weights.
If TRUE, load pre-computed LD among weight SNPs. This option is only for PredictDB weights.
If TRUE, include LD of variants in weights (R_wgt) in the weights object. R_wgt is used for computing gene Z-scores. If FALSE, will skip computing R_wgt. This could save running time when using precomputed gene Z-scores.
a string, specifying the method to choose in FUSION models. "best.cv" option will use the best model (smallest p-value) under cross-validation.
a string, specifying the genome version of FUSION models
a number, specifying the top n SNPs included in weight models. By default, use all SNPs in weights.
file format for LD matrix. If "custom", use a user defined
LD_loader_fun()
function to load LD matrix.
a user defined function to load LD matrix when LD_format = "custom"
.
a user defined function to load SNP information file, if SNP information files are not in standard cTWAS reference format.
a user defined function to convert weight variant IDs to the reference variant format.
The number of cores used to parallelize computation.
The log filename. If NULL, will print log info on screen.
If TRUE, print detail messages.
a list of processed weights