% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plots.R
\name{dfdr_plot_p_density_by_decoy}
\alias{dfdr_plot_p_density_by_decoy}
\title{Plot (pseudo-)p-value density by decoy/target}
\usage{
dfdr_plot_p_density_by_decoy(
  x,
  p_max = 1,
  bw = "nrd0",
  adjust = 1,
  title = "(Pseudo-)p-value distribution (density): targets vs decoys",
  log10_x = FALSE,
  eps = 1e-300
)
}
\arguments{
\item{x}{A \code{dfdr_tbl} with columns \code{p} and \code{is_decoy}.}

\item{p_max}{Numeric. Maximum p-value displayed (default 1).}

\item{bw}{Bandwidth passed to \code{ggplot2::geom_density()}.}

\item{adjust}{Numeric smoothing adjustment passed to \code{geom_density()}.}

\item{title}{Character. Plot title.}

\item{log10_x}{Logical. If \code{TRUE}, plot \eqn{-\log_{10}(p)} instead of \code{p}.}

\item{eps}{Numeric. Lower bound used to avoid \code{Inf} when \code{log10_x = TRUE}.}
}
\value{
A \link[ggplot2:ggplot]{ggplot} object.
}
\description{
Plots density curves of (pseudo-)p-values for targets vs decoys. Optionally
plots \eqn{-\log_{10}(p)} to emphasise small p-values.
}
\examples{
library(tibble)

set.seed(1)
n <- 4000
df <- tibble(
  id = as.character(seq_len(n)),
  run = "run1",
  is_decoy = sample(c(FALSE, TRUE), n, replace = TRUE, prob = c(0.95, 0.05)),
  score = rnorm(n),
  q = stats::runif(n, 0, 0.05),
  pep = NA_real_,
  p = stats::runif(n)
)
x <- as_dfdr_tbl(df, unit = "psm", scope = "global", q_source = "toy", p_source = "toy")
dfdr_plot_p_density_by_decoy(x, log10_x = TRUE)

}
