Skip to content
Snippets Groups Projects
Commit 2bf3dc44 authored by Luke Zappia's avatar Luke Zappia
Browse files

Use fitdist for means

Need to do some more comparisons to check if these is the best approach...
parent f9d4f54e
No related branches found
No related tags found
No related merge requests found
...@@ -57,7 +57,8 @@ estimateParams.matrix <- function(counts, params = NULL) { ...@@ -57,7 +57,8 @@ estimateParams.matrix <- function(counts, params = NULL) {
#' Estimate mean parameters #' Estimate mean parameters
#' #'
#' Estimate rate and shape parameters for the gamma distribution used to #' Estimate rate and shape parameters for the gamma distribution used to
#' simulate gene expression means. Uses a method of moments approach. #' simulate gene expression means using the 'moment matching estimation' method
#' of \code{\link{fitdist}}.
#' #'
#' @param norm.counts library size normalised counts matrix. #' @param norm.counts library size normalised counts matrix.
#' @param params splatParams object to store estimated values in. #' @param params splatParams object to store estimated values in.
...@@ -75,15 +76,10 @@ estMeanParams <- function(norm.counts, params) { ...@@ -75,15 +76,10 @@ estMeanParams <- function(norm.counts, params) {
means <- rowMeans(norm.counts) means <- rowMeans(norm.counts)
means <- means[means != 0] means <- means[means != 0]
z <- log(means) fit <- fitdistrplus::fitdist(means, "gamma", method = "mme")
mean.z <- mean(z) params <- setParams(params, mean.shape = unname(fit$estimate["shape"]),
var.z <- var(z) mean.rate = unname(fit$estimate["rate"]))
alpha <- limma::trigammaInverse(var.z)
beta <- exp(digamma(alpha) - mean.z)
params <- setParams(params, mean.shape = alpha, mean.rate = beta)
return(params) return(params)
} }
......
...@@ -16,7 +16,8 @@ splatParams object with estimated values. ...@@ -16,7 +16,8 @@ splatParams object with estimated values.
} }
\description{ \description{
Estimate rate and shape parameters for the gamma distribution used to Estimate rate and shape parameters for the gamma distribution used to
simulate gene expression means. Uses a method of moments approach. simulate gene expression means using the 'moment matching estimation' method
of \code{\link{fitdist}}.
} }
\examples{ \examples{
data("sc_example_counts") data("sc_example_counts")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment