Skip to content

Commit

Permalink
fix bug in EM 'shared_all' option
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinlkx committed Dec 13, 2024
1 parent 82833a1 commit a28f2d6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions R/ctwas_EM.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ fit_EM <- function(
tmp_EM_susie_res <- EM_susie_res[EM_susie_res$group!="SNP",]
V_prior[names(V_prior)!="SNP"] <- sum(tmp_EM_susie_res$susie_pip*tmp_EM_susie_res$mu2)/sum(tmp_EM_susie_res$susie_pip)
} else if (group_prior_var_structure=="shared_all") {
tmp_EM_susie_res <- EM_susie_res
V_prior[names(V_prior)] <- sum(tmp_EM_susie_res$susie_pip*tmp_EM_susie_res$mu2)/sum(tmp_EM_susie_res$susie_pip)
} else if (group_prior_var_structure=="shared_type") {
tmp_EM_susie_res <- EM_susie_res[EM_susie_res$group=="SNP",]
Expand Down
3 changes: 2 additions & 1 deletion R/ctwas_weights.R
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ create_predictdb_from_QTLs <- function(weight_table,
loginfo("Makes PredictDB weights from QTL data")

# check and clean the QTL data
weight_table <- as.data.frame(weight_table)
required_cols <- c("gene", "rsid", "varID", "ref_allele", "eff_allele", "weight")
if (!all(required_cols %in% colnames(weight_table))){
stop("QTL_data needs to contain the following columns: ",
Expand All @@ -342,7 +343,7 @@ create_predictdb_from_QTLs <- function(weight_table,
weight_table <- weight_table[!duplicated(weight_table$gene), ]
}

weight_table <- weight_table[weight_table[, "weight"] != 0, ,drop = FALSE]
weight_table <- weight_table[weight_table$weight != 0, ,drop = FALSE]
weight_table <- weight_table[complete.cases(weight_table), ,drop = FALSE]

# if NULL, create a simply extra_table based on weight_table
Expand Down

0 comments on commit a28f2d6

Please # to comment.