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

Run checks

parent 2bf3dc44
No related branches found
No related tags found
No related merge requests found
Package: splatter
Type: Package
Title: Simple Simulation of Single-cell RNA Sequencing Data
Version: 0.2.0
Version: 0.2.3
Date: 2016-10-06
Author: Luke Zappia
Authors@R: as.person(c(
......@@ -20,7 +20,9 @@ Depends:
scater
Imports: limma,
fitdistrplus,
edgeR
edgeR,
stats,
locfit
Suggests:
testthat
biocViews: SingleCell, RNASeq, Transcriptomics, GeneExpression, Sequencing,
......
# Generated by roxygen2: do not edit by hand
S3method(estimateParams,SCESet)
S3method(estimateParams,matrix)
S3method(print,splatParams)
export(checkParams)
export(defaultParams)
......@@ -8,3 +10,6 @@ export(getParams)
export(mergeParams)
export(setParams)
export(splatParams)
importFrom(stats,dnbinom)
importFrom(stats,median)
importFrom(stats,nls)
......@@ -27,28 +27,31 @@
estimateParams <- function(x, params = NULL) UseMethod("estimateParams")
#' @rdname estimateParams
estimateParams.SCESet <- function(sce, params = NULL) {
counts <- scater::counts(sce)
#' @export
estimateParams.SCESet <- function(x, params = NULL) {
counts <- scater::counts(x)
estimateParams(counts, params)
}
#' @rdname estimateParams
estimateParams.matrix <- function(counts, params = NULL) {
#' @importFrom stats median
#' @export
estimateParams.matrix <- function(x, params = NULL) {
if (is.null(params)) {
params <- splatParams()
}
# Normalise for library size and remove all zeros
lib.sizes <- colSums(counts)
lib.sizes <- colSums(x)
lib.med <- median(lib.sizes)
norm.counts <- t(t(counts) / lib.sizes * lib.med)
norm.counts <- t(t(x) / lib.sizes * lib.med)
norm.counts <- norm.counts[rowSums(norm.counts > 0) > 1, ]
params <- estMeanParams(norm.counts, params)
params <- estLibParams(counts, params)
params <- estLibParams(x, params)
params <- estOutlierParams(norm.counts, params)
params <- estBCVParams(counts, params)
params <- estBCVParams(x, params)
params <- estDropoutParams(norm.counts, params)
return(params)
......@@ -65,12 +68,14 @@ estimateParams.matrix <- function(counts, params = NULL) {
#'
#' @return splatParams object with estimated values.
#' @examples
#' \dontrun{
#' data("sc_example_counts")
#' norm_ex_counts <- t(t(sc_example_counts) / colSums(sc_example_counts) *
#' median(colSums(sc_example_counts)))
#' params <- params()
#' params <- splatParams()
#' params <- estMeanParams(norm_ex_counts, params)
#' params
#' }
estMeanParams <- function(norm.counts, params) {
means <- rowMeans(norm.counts)
......@@ -95,10 +100,12 @@ estMeanParams <- function(norm.counts, params) {
#'
#' @return splatParams object with estimated values.
#' @examples
#' \dontrun{
#' data("sc_example_counts")
#' params <- params()
#' params <- splatParams()
#' params <- estLibParams(sc_example_counts, params)
#' params
#' }
estLibParams <- function(counts, params) {
lib.sizes <- colSums(counts)
......@@ -132,12 +139,14 @@ estLibParams <- function(counts, params) {
#'
#' @return splatParams object with estimated values.
#' @examples
#' \dontrun{
#' data("sc_example_counts")
#' norm_ex_counts <- t(t(sc_example_counts) / colSums(sc_example_counts) *
#' median(colSums(sc_example_counts)))
#' params <- params()
#' params <- splatParams()
#' params <- estOutlierParams(norm_ex_counts, params)
#' params
#' }
estOutlierParams <- function(norm.counts, params) {
means <- rowMeans(norm.counts)
......@@ -176,10 +185,12 @@ estOutlierParams <- function(norm.counts, params) {
#'
#' @return spaltParams object with estimated values.
#' @examples
#' \dontrun{
#' data("sc_example_counts")
#' params <- params()
#' params <- splatParams()
#' params <- estBCVParams(sc_example_counts, params)
#' params
#' }
estBCVParams <- function(counts, params) {
# Add dummy design matrix to avoid print statement
......@@ -218,11 +229,14 @@ estBCVParams <- function(counts, params) {
#'
#' @return Params object with estimated values.
#' @examples
#' \dontrun{
#' data("sc_example_counts")
#' norm_ex_counts <- t(t(sc_example_counts) / colSums(sc_example_counts) *
#' median(colSums(sc_example_counts)))
#' params <- params()
#' params <- splatParams()
#' params <- estMeanParams(norm_ex_counts, params)
#' }
#' @importFrom stats nls dnbinom median
estDropoutParams <- function(norm.counts, params) {
means <- rowMeans(norm.counts)
......
......@@ -7,8 +7,6 @@
#' @param k shape parameter. Gives the slope of the function.
#'
#' @return RETURN DESCRIPTION
#' @examples
#' logistic(0, 1, 1)
logistic <- function(x, x0, k) {
1 / (1 + exp(-k * (x - x0)))
}
\ No newline at end of file
......@@ -20,9 +20,11 @@ Parameters are estimated using the \code{estimateDisp} function in the
of freedom. See \code{\link{estimateDisp}} for details.
}
\examples{
\dontrun{
data("sc_example_counts")
params <- params()
params <- splatParams()
params <- estBCVParams(sc_example_counts, params)
params
}
}
......@@ -35,10 +35,12 @@ at a plot of log2 mean expression vs the difference between observed and
expected number of zeros across all genes.
}
\examples{
\dontrun{
data("sc_example_counts")
norm_ex_counts <- t(t(sc_example_counts) / colSums(sc_example_counts) *
median(colSums(sc_example_counts)))
params <- params()
params <- splatParams()
params <- estMeanParams(norm_ex_counts, params)
}
}
......@@ -20,9 +20,11 @@ parameters are added to the params object. See \code{\link{fitdist}} for
details on the fitting.
}
\examples{
\dontrun{
data("sc_example_counts")
params <- params()
params <- splatParams()
params <- estLibParams(sc_example_counts, params)
params
}
}
......@@ -20,11 +20,13 @@ simulate gene expression means using the 'moment matching estimation' method
of \code{\link{fitdist}}.
}
\examples{
\dontrun{
data("sc_example_counts")
norm_ex_counts <- t(t(sc_example_counts) / colSums(sc_example_counts) *
median(colSums(sc_example_counts)))
params <- params()
params <- splatParams()
params <- estMeanParams(norm_ex_counts, params)
params
}
}
......@@ -31,11 +31,13 @@ factors in order to estimate the outlier factor location and scale
parameters. See \code{\link{fitdist}} for details on the fitting.
}
\examples{
\dontrun{
data("sc_example_counts")
norm_ex_counts <- t(t(sc_example_counts) / colSums(sc_example_counts) *
median(colSums(sc_example_counts)))
params <- params()
params <- splatParams()
params <- estOutlierParams(norm_ex_counts, params)
params
}
}
......@@ -8,9 +8,9 @@
\usage{
estimateParams(x, params = NULL)
\method{estimateParams}{SCESet}(sce, params = NULL)
\method{estimateParams}{SCESet}(x, params = NULL)
\method{estimateParams}{matrix}(counts, params = NULL)
\method{estimateParams}{matrix}(x, params = NULL)
}
\arguments{
\item{x}{either a counts matrix or an SCESet object containing count data to
......
......@@ -19,7 +19,4 @@ RETURN DESCRIPTION
\description{
Implementation of the logistic function
}
\examples{
logistic(0, 1, 1)
}
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