Commit 183b1b0f authored by houyun's avatar houyun
Browse files

function to adjust correlation pvalue

parent 05c3a5fd
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ export(GeomMark)
export(GeomSquare)
export(Geomshaping)
export(adjacency_matrix)
export(adjust_pvalue)
export(aes)
export(anno_link)
export(annotateGrob)

R/pvalue-adjust.R

0 → 100644
+28 −0
Original line number Diff line number Diff line
#' @title Adjust p values
#' @description Adjust correlation p values based on user-specified method.
#' @param x a correlate or md_tbl object.
#' @param .FUN adjust function, such as \code{stats::p.adjust()},
#' \code{multtest::mt.rawp2adjp()}.
#' @param ... other parameters passing on to adjust function.
#' @return a object same as x.
#' @author Hou Yun
#' @rdname adjust_pvalue
#' @export
adjust_pvalue <- function(x, .FUN = "p.adjust", ...) {
  if (!inherits(x, "cor_md_tbl") && !inherits(x, "correlate")) {
    stop("Can only adjust p-value for 'md_tbl' and 'correlate' object.",
         call. = FALSE)
  }
  if (!"p" %in% names(x)) {
    return(x)
  }

  .FUN <- match.fun(.FUN)
  if (inherits(x, "cor_md_tbl")) {
    x$p <- .FUN(x$p, ...)
  } else {
    x$p[] <- .FUN(x$p, ...)
  }
  x
}

man/adjust_pvalue.Rd

0 → 100644
+25 −0
Original line number Diff line number Diff line
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pvalue-adjust.R
\name{adjust_pvalue}
\alias{adjust_pvalue}
\title{Adjust p values}
\usage{
adjust_pvalue(x, .FUN = "p.adjust", ...)
}
\arguments{
\item{x}{a correlate or md_tbl object.}

\item{.FUN}{adjust function, such as \code{stats::p.adjust()},
\code{multtest::mt.rawp2adjp()}.}

\item{...}{other parameters passing on to adjust function.}
}
\value{
a object same as x.
}
\description{
Adjust correlation p values based on user-specified method.
}
\author{
Hou Yun
}