R/PlotPIP.R

Defines functions PlotPIP

Documented in PlotPIP

#' PlotPIP
#'
#' @param pip_tibble the PIP tibble of all of the SNPs in each iteration
#' @param iter the specific iteration which will be used to plot.
#'
#' @return a plot of the PIP of each SNP.
#' @export
PlotPIP <- function(pip_tibble, iter = 1) {
  n <- dim(pip_tibble)[1]
  variable <- c(1:n)
  PIP <- pull(pip_tibble, paste0("iter", iter))
  effect <- apply(as.matrix(PIP), MARGIN = 1, FUN = Effect) %>%
    factor(levels = c(1, 2, 3))
  pip <- tibble(variable, PIP, effect)
  p <- ggplot(data = pip, aes(x = variable, y = PIP, group = effect)) +
    geom_point(aes(color = effect), size = 3, show.legend = FALSE) +
    xlab("Variable (SNP)")
  return(p)
}
statwangz/SuSiE documentation built on Nov. 22, 2022, 5:21 p.m.