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