Skip to content

Commit 853fb52

Browse files
committed
fix batch null rs in twas pipeline
1 parent 03d9c92 commit 853fb52

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

R/file_utils.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,7 @@ batch_load_twas_weights <- function(twas_weights_results, meta_data_df, max_memo
11631163
)
11641164

11651165
# Merge with meta_data_df to get TSS information
1166+
meta_data_df <- meta_data_df[!duplicated(meta_data_df[, c("region_id", "TSS")]), ]
11661167
gene_memory_df <- merge(gene_memory_df, meta_data_df[, c("region_id", "TSS")],
11671168
by.x = "gene_name",
11681169
by.y = "region_id", all.x = TRUE

R/twas.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ twas_pipeline <- function(twas_weights_data,
576576
}
577577
}
578578
if (length(twas_weights_data)==0) {
579-
return(NULL)
579+
return(list(NULL))
580580
}
581581

582582
# harmonize twas weights and gwas sumstats against LD
@@ -686,7 +686,7 @@ twas_pipeline <- function(twas_weights_data,
686686
gc()
687687
twas_results_db <- twas_results_db[!sapply(twas_results_db, function(x) is.null(x) || (is.list(x) && all(sapply(x, is.null))))]
688688
if (length(twas_results_db) == 0) {
689-
return(NULL)
689+
return(list(NULL))
690690
}
691691
twas_results_table <- do.call(rbind, lapply(twas_results_db, function(x) x$twas_table))
692692
mr_results <- do.call(rbind, lapply(twas_results_db, function(x) x$mr_result))

0 commit comments

Comments
 (0)