Skip to content

Commit

Permalink
Merge pull request #153 from GRealesM/main
Browse files Browse the repository at this point in the history
added function to extract credible sets
  • Loading branch information
chr1swallace authored Mar 21, 2024
2 parents 0afe607 + dfa887c commit e7e5d67
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions R/claudia.R
Original file line number Diff line number Diff line change
Expand Up @@ -361,3 +361,20 @@ coloc.abf <- function(dataset1, dataset2, MAF=NULL,
return(output)
}

##' Finemapping credible sets
##'
##' @title Find credible sets in finemap.abf results
##' @param datasets data frame output of \code{\link{finemap.abf}}
##' @param credible.size threshold of the credible set (Default: 0.95)
##' @return SNP ids of the credible set
##' @author Guillermo Reales
##' @export
credible.sets <- function(dataset, credible.size = 0.95){
if(!"SNP.PP" %in% names(dataset)) stop("Input must be finemap.abf() output and have a SNP.PP column.")
t2 <- dataset[ order(dataset$SNP.PP, decreasing = TRUE),]
t2$csum <- cumsum(t2$SNP.PP)
t2[ t2$csum < credible.size,c("snp","SNP.PP")]
}



0 comments on commit e7e5d67

Please sign in to comment.