Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
sirplus
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BioCellGen-public
sirplus
Commits
7fcd183c
Commit
7fcd183c
authored
7 years ago
by
Luke Zappia
Browse files
Options
Downloads
Patches
Plain Diff
Update SplatParams
* Add batch parameters * Replace groupCells with group.prob
parent
5ce7d916
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
R/AllClasses.R
+31
-7
31 additions, 7 deletions
R/AllClasses.R
R/SplatParams-methods.R
+41
-11
41 additions, 11 deletions
R/SplatParams-methods.R
man/SplatParams.Rd
+19
-3
19 additions, 3 deletions
man/SplatParams.Rd
tests/testthat/test-SplatParams.R
+14
-8
14 additions, 8 deletions
tests/testthat/test-SplatParams.R
with
105 additions
and
29 deletions
R/AllClasses.R
+
31
−
7
View file @
7fcd183c
...
...
@@ -72,9 +72,17 @@ setClass("SimpleParams",
#' \describe{
#' \item{\code{nGenes}}{The number of genes to simulate.}
#' \item{\code{nCells}}{The number of cells to simulate.}
#' \item{\code{[nGroups]}}{The number of groups or paths to simulate.}
#' \item{\code{[groupCells]}}{Vector giving the number of cells in each
#' simulation group/path.}
#' \item{\emph{Batch parameters}}{
#' \describe{
#' \item{\code{[nBatches]}}{The number of batches to simulate.}
#' \item{\code{[batchCells]}}{Vector giving the number of cells in
#' each batch.}
#' \item{\code{[batch.facLoc]}}{Location (meanlog) parameter for the
#' batch effect factor log-normal distribution. Can be a vector.}
#' \item{\code{[batch.facScale]}}{Scale (sdlog) parameter for the
#' batch effect factor log-normal distribution. Can be a vector.}
#' }
#' }
#' \item{\code{[seed]}}{Seed to use for generating random numbers.}
#' \item{\emph{Mean parameters}}{
#' \describe{
...
...
@@ -102,6 +110,14 @@ setClass("SimpleParams",
#' expression outlier factor log-normal distribution.}
#' }
#' }
#' \item{\emph{Group parameters}}{
#' \describe{
#' \item{\code{[nGroups]}}{The number of groups or paths to
#' simulate.}
#' \item{\code{[group.prob]}}{Probability that a cell comes from a
#' group.}
#' }
#' }
#' \item{\emph{Differential expression parameters}}{
#' \describe{
#' \item{\code{[de.prob]}}{Probability that a gene is differentially
...
...
@@ -173,8 +189,10 @@ setClass("SimpleParams",
#' @exportClass SplatParams
setClass
(
"SplatParams"
,
contains
=
"Params"
,
slots
=
c
(
nGroups
=
"numeric"
,
groupCells
=
"numeric"
,
slots
=
c
(
nBatches
=
"numeric"
,
batchCells
=
"numeric"
,
batch.facLoc
=
"numeric"
,
batch.facScale
=
"numeric"
,
mean.shape
=
"numeric"
,
mean.rate
=
"numeric"
,
lib.loc
=
"numeric"
,
...
...
@@ -182,6 +200,8 @@ setClass("SplatParams",
out.prob
=
"numeric"
,
out.facLoc
=
"numeric"
,
out.facScale
=
"numeric"
,
nGroups
=
"numeric"
,
group.prob
=
"numeric"
,
de.prob
=
"numeric"
,
de.downProb
=
"numeric"
,
de.facLoc
=
"numeric"
,
...
...
@@ -196,8 +216,10 @@ setClass("SplatParams",
path.skew
=
"numeric"
,
path.nonlinearProb
=
"numeric"
,
path.sigmaFac
=
"numeric"
),
prototype
=
prototype
(
nGroups
=
1
,
groupCells
=
100
,
prototype
=
prototype
(
nBatches
=
1
,
batchCells
=
100
,
batch.facLoc
=
0
,
batch.facScale
=
0
,
mean.rate
=
0.3
,
mean.shape
=
0.6
,
lib.loc
=
11
,
...
...
@@ -205,6 +227,8 @@ setClass("SplatParams",
out.prob
=
0.05
,
out.facLoc
=
4
,
out.facScale
=
0.5
,
nGroups
=
1
,
group.prob
=
1
,
de.prob
=
0.1
,
de.downProb
=
0.5
,
de.facLoc
=
0.1
,
...
...
This diff is collapsed.
Click to expand it.
R/SplatParams-methods.R
+
41
−
11
View file @
7fcd183c
...
...
@@ -16,12 +16,16 @@ setValidity("SplatParams", function(object) {
object
<-
expandParams
(
object
)
v
<-
getParams
(
object
,
c
(
slotNames
(
object
)))
nBatches
<-
v
$
nBatches
nGroups
<-
v
$
nGroups
checks
<-
c
(
nGenes
=
checkInt
(
v
$
nGenes
,
lower
=
1
),
nCells
=
checkInt
(
v
$
nCells
,
lower
=
1
),
nGroups
=
checkInt
(
v
$
nGroups
,
lower
=
1
),
groupCells
=
checkIntegerish
(
v
$
groupCells
,
lower
=
1
,
len
=
nGroups
),
nBatches
=
checkInt
(
v
$
nBatches
,
lower
=
1
),
batchCells
=
checkIntegerish
(
v
$
batchCells
,
lower
=
1
,
len
=
nBatches
),
batch.facLoc
=
checkNumeric
(
v
$
batch.facLoc
,
len
=
nBatches
),
batch.facScale
=
checkNumeric
(
v
$
batch.facScale
,
lower
=
0
,
len
=
nBatches
),
mean.rate
=
checkNumber
(
v
$
mean.rate
,
lower
=
0
),
mean.shape
=
checkNumber
(
v
$
mean.shape
,
lower
=
0
),
lib.loc
=
checkNumber
(
v
$
lib.loc
),
...
...
@@ -29,6 +33,9 @@ setValidity("SplatParams", function(object) {
out.prob
=
checkNumber
(
v
$
out.prob
,
lower
=
0
,
upper
=
1
),
out.facLoc
=
checkNumber
(
v
$
out.facLoc
),
out.facScale
=
checkNumber
(
v
$
out.facScale
,
lower
=
0
),
nGroups
=
checkInt
(
v
$
nGroups
,
lower
=
1
),
group.prob
=
checkNumeric
(
v
$
de.prob
,
lower
=
0
,
upper
=
1
,
len
=
nGroups
),
de.prob
=
checkNumeric
(
v
$
de.prob
,
lower
=
0
,
upper
=
1
,
len
=
nGroups
),
de.downProb
=
checkNumeric
(
v
$
de.downProb
,
lower
=
0
,
upper
=
1
,
...
...
@@ -52,10 +59,15 @@ setValidity("SplatParams", function(object) {
path.sigmaFac
=
checkNumber
(
v
$
path.sigmaFac
,
lower
=
0
),
seed
=
checkInt
(
v
$
seed
,
lower
=
0
))
# Check
group
Cells matches nCells, n
Group
s
if
(
v
$
nCells
!=
sum
(
v
$
group
Cells
)
||
n
Group
s
!=
length
(
v
$
group
Cells
))
{
# Check
batch
Cells matches nCells, n
Batche
s
if
(
v
$
nCells
!=
sum
(
v
$
batch
Cells
)
||
n
Batche
s
!=
length
(
v
$
batch
Cells
))
{
checks
<-
c
(
checks
,
"nCells, nGroups and groupCells are not consistent"
)
"nCells, nBatches and batchesCells are not consistent"
)
}
# Check group.prob sums to 1
if
(
sum
(
v
$
group.prob
)
!=
1
)
{
checks
<-
c
(
checks
,
"group.probs must sum to 1"
)
}
# Check path.from
...
...
@@ -79,12 +91,20 @@ setValidity("SplatParams", function(object) {
setMethod
(
"setParam"
,
"SplatParams"
,
function
(
object
,
name
,
value
)
{
checkmate
::
assertString
(
name
)
if
(
name
==
"nCells"
||
name
==
"nGroups"
)
{
stop
(
name
,
" cannot be set directly, set groupCells instead"
)
if
(
name
==
"nCells"
||
name
==
"nBatches"
)
{
stop
(
name
,
" cannot be set directly, set batchCells instead"
)
}
if
(
name
==
"nGroups"
)
{
stop
(
name
,
" cannot be set directly, set group.prob instead"
)
}
if
(
name
==
"
group
Cells"
)
{
if
(
name
==
"
batch
Cells"
)
{
object
<-
setParamUnchecked
(
object
,
"nCells"
,
sum
(
value
))
object
<-
setParamUnchecked
(
object
,
"nBatches"
,
length
(
value
))
}
if
(
name
==
"group.prob"
)
{
object
<-
setParamUnchecked
(
object
,
"nGroups"
,
length
(
value
))
}
...
...
@@ -96,8 +116,10 @@ setMethod("setParam", "SplatParams",function(object, name, value) {
#' @importFrom methods callNextMethod
setMethod
(
"show"
,
"SplatParams"
,
function
(
object
)
{
pp
<-
list
(
"Groups:"
=
c
(
"[Groups]"
=
"nGroups"
,
"[Group Cells]"
=
"groupCells"
),
pp
<-
list
(
"Batches:"
=
c
(
"[Batches]"
=
"nBatches"
,
"[Batch Cells]"
=
"batchCells"
,
"[Location]"
=
"batch.facLoc"
,
"[Scale]"
=
"batch.facScale"
),
"Mean:"
=
c
(
"(Rate)"
=
"mean.rate"
,
"(Shape)"
=
"mean.shape"
),
"Library size:"
=
c
(
"(Location)"
=
"lib.loc"
,
...
...
@@ -105,6 +127,8 @@ setMethod("show", "SplatParams", function(object) {
"Exprs outliers:"
=
c
(
"(Probability)"
=
"out.prob"
,
"(Location)"
=
"out.facLoc"
,
"(Scale)"
=
"out.facScale"
),
"Groups:"
=
c
(
"[Groups]"
=
"nGroups"
,
"[Group Probs]"
=
"group.prob"
),
"Diff expr:"
=
c
(
"[Probability]"
=
"de.prob"
,
"[Down Prob]"
=
"de.downProb"
,
"[Location]"
=
"de.facLoc"
,
...
...
@@ -127,6 +151,12 @@ setMethod("show", "SplatParams", function(object) {
#' @rdname expandParams
setMethod
(
"expandParams"
,
"SplatParams"
,
function
(
object
)
{
n
<-
getParam
(
object
,
"nBatches"
)
vectors
<-
c
(
"batch.facLoc"
,
"batch.facScale"
)
object
<-
callNextMethod
(
object
,
vectors
,
n
)
n
<-
getParam
(
object
,
"nGroups"
)
vectors
<-
c
(
"de.prob"
,
"de.downProb"
,
"de.facLoc"
,
"de.facScale"
,
...
...
This diff is collapsed.
Click to expand it.
man/SplatParams.Rd
+
19
−
3
View file @
7fcd183c
...
...
@@ -16,9 +16,17 @@ The Splatter simulation requires the following parameters:
\describe{
\item{\code{nGenes}}{The number of genes to simulate.}
\item{\code{nCells}}{The number of cells to simulate.}
\item{\code{[nGroups]}}{The number of groups or paths to simulate.}
\item{\code{[groupCells]}}{Vector giving the number of cells in each
simulation group/path.}
\item{\emph{Batch parameters}}{
\describe{
\item{\code{[nBatches]}}{The number of batches to simulate.}
\item{\code{[batchCells]}}{Vector giving the number of cells in
each batch.}
\item{\code{[batch.facLoc]}}{Location (meanlog) parameter for the
batch effect factor log-normal distribution. Can be a vector.}
\item{\code{[batch.facScale]}}{Scale (sdlog) parameter for the
batch effect factor log-normal distribution. Can be a vector.}
}
}
\item{\code{[seed]}}{Seed to use for generating random numbers.}
\item{\emph{Mean parameters}}{
\describe{
...
...
@@ -46,6 +54,14 @@ The Splatter simulation requires the following parameters:
expression outlier factor log-normal distribution.}
}
}
\item{\emph{Group parameters}}{
\describe{
\item{\code{[nGroups]}}{The number of groups or paths to
simulate.}
\item{\code{[group.prob]}}{Probability that a cell comes from a
group.}
}
}
\item{\emph{Differential expression parameters}}{
\describe{
\item{\code{[de.prob]}}{Probability that a gene is differentially
...
...
This diff is collapsed.
Click to expand it.
tests/testthat/test-SplatParams.R
+
14
−
8
View file @
7fcd183c
context
(
"SplatParams"
)
test_that
(
"n
Group
s checks work"
,
{
test_that
(
"n
Batche
s checks work"
,
{
params
<-
newSplatParams
()
expect_error
(
setParam
(
params
,
"nCells"
,
1
),
"nCells cannot be set directly, set groupCells instead"
)
expect_error
(
setParam
(
params
,
"nGroups"
,
1
),
"nGroups cannot be set directly, set groupCells instead"
)
"nCells cannot be set directly, set batchCells instead"
)
expect_error
(
setParam
(
params
,
"nBatches"
,
1
),
"nBatches cannot be set directly, set batchCells instead"
)
})
test_that
(
"nGroups checks work"
,
{
params
<-
newSplatParams
()
expect_error
(
setParam
(
params
,
"nGroups"
,
1
),
"nGroups cannot be set directly, set group.prob instead"
)
})
test_that
(
"path.from checks work"
,
{
params
<-
newSplatParams
()
params
<-
setParams
(
params
,
group
Cells
=
c
(
10
,
10
))
params
<-
setParams
(
params
,
group
.prob
=
c
(
0.5
,
0.5
))
params
<-
setParamUnchecked
(
params
,
"path.from"
,
c
(
0
,
1
))
expect_silent
(
validObject
(
params
))
params
<-
setParamUnchecked
(
params
,
"path.from"
,
c
(
0
,
3
))
expect_error
(
validObject
(
params
),
paste
(
'invalid class
"
SplatParams
"
object: path.from:'
,
paste
(
'invalid class
“
SplatParams
”
object: path.from:'
,
"All elements must be <= 2"
))
params
<-
setParamUnchecked
(
params
,
"path.from"
,
c
(
1
,
0
))
expect_error
(
validObject
(
params
),
"path cannot begin at itself"
)
params
<-
newSplatParams
()
params
<-
setParams
(
params
,
group
Cells
=
c
(
10
,
10
,
10
))
params
<-
setParams
(
params
,
group
.prob
=
c
(
0.3
,
0.3
,
0.4
))
params
<-
setParamUnchecked
(
params
,
"path.from"
,
c
(
2
,
1
,
1
))
expect_error
(
validObject
(
params
),
"origin must be specified in path.from"
)
})
\ No newline at end of file
})
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment