Skip to contents

This function loads TWAS weight data from multiple RDS files, checks for the presence of specified region and condition. If variable_name_obj is provided, it aligns and consolidates weight matrices based on the object's variant names, filling missing data with zeros. If variable_name_obj is NULL, it checks that all files have the same row numbers for the condition and consolidates weights accordingly.

Usage

load_twas_weights(
  weight_db_files,
  conditions = NULL,
  variable_name_obj = c("preset_variants_result", "variant_names"),
  susie_obj = c("preset_variants_result", "susie_result_trimmed"),
  twas_weights_table = "twas_weights"
)

Arguments

variable_name_obj

The name of the variable/object to fetch from each file, if not NULL.

weight_db_file

weight_db_files Vector of file paths for RDS files containing TWAS weights.. Each element organized as region/condition/weights

condition

The specific condition to be checked and consolidated across all files.

Value

A consolidated list of weights for the specified condition and a list of SuSiE results.

Examples

# Example usage (replace with actual file paths, condition, region, and variable_name_obj):
weight_db_files <- c("path/to/file1.rds", "path/to/file2.rds")
condition <- "example_condition"
region <- "example_region"
variable_name_obj <- "example_variable" # or NULL for standard processing
consolidated_weights <- load_twas_weights(weight_db_files, condition, region, variable_name_obj)
#> Warning: cannot open compressed file 'path/to/file1.rds', probable reason 'No such file or directory'
#> Error in gzfile(file, "rb") : cannot open the connection
print(consolidated_weights)
#> [1] "Error in gzfile(file, \"rb\") : cannot open the connection\n"
#> attr(,"class")
#> [1] "try-error"
#> attr(,"condition")
#> <simpleError in gzfile(file, "rb"): cannot open the connection>