File: fitTrendPoisson.Rd

package info (click to toggle)
r-bioc-scran 1.26.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,692 kB
  • sloc: cpp: 733; makefile: 2
file content (74 lines) | stat: -rw-r--r-- 2,949 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/fitTrendPoisson.R
\name{fitTrendPoisson}
\alias{fitTrendPoisson}
\title{Generate a trend for Poisson noise}
\usage{
fitTrendPoisson(
  means,
  size.factors,
  npts = 1000,
  dispersion = 0,
  pseudo.count = 1,
  BPPARAM = SerialParam(),
  ...
)
}
\arguments{
\item{means}{A numeric vector of length 2 or more, containing the range of mean counts observed in the dataset.}

\item{size.factors}{A numeric vector of size factors for all cells in the dataset.}

\item{npts}{An integer scalar specifying the number of interpolation points to use.}

\item{dispersion}{A numeric scalar specifying the dispersion for the NB distribution.
If zero, a Poisson distribution is used.}

\item{pseudo.count}{A numeric scalar specifying the pseudo-count to be added to the scaled counts before log-transformation.}

\item{BPPARAM}{A \linkS4class{BiocParallelParam} object indicating how parallelization should be performed across interpolation points.}

\item{...}{Further arguments to pass to \code{\link{fitTrendVar}} for trend fitting.}
}
\value{
A named list is returned containing:
\describe{
\item{\code{trend}:}{A function that returns the fitted value of the trend at any value of the mean.}
\item{\code{std.dev}:}{A numeric scalar containing the robust standard deviation of the ratio of \code{var} to the fitted value of the trend across all features used for trend fitting.}
}
}
\description{
Create a mean-variance trend for log-normalized expression values derived from Poisson-distributed counts.
}
\details{
This function is useful for modelling technical noise in highly diverse datasets without spike-ins,
where fitting a trend to the endogenous genes would not be appropriate given the strong biological heterogeneity.
It is mostly intended for UMI datasets where the technical noise is close to Poisson-distributed.

This function operates by simulating Poisson or negative binomial-distributed counts,
computing log-transformed normalized expression values from those counts,
calculating the mean and variance and then passing those metrics to \code{\link{fitTrendVar}}.
The log-transformation ensures that variance is modelled in the same space that is used for downstream analyses like PCA.

Simulations are performed across a range of values in \code{means} to achieve reliable interpolation,
with the stability of the trend determined by the number of simulation points in \code{npts}.
The number of cells is determined from the length of \code{size.factors},
which are used to scale the distribution means prior to sampling counts.
}
\examples{
# Mocking up means and size factors:
sf <- 2^rnorm(1000, sd=0.1)
sf <- sf/mean(sf)
means <- rexp(100, 0.1)

# Using these to construct a Poisson trend:
out <- fitTrendPoisson(means, sf)
curve(out$trend(x), xlim=c(0, 10))

}
\seealso{
\code{\link{fitTrendVar}}, which is used to fit the trend.
}
\author{
Aaron Lun
}