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
aae77a9c
Commit
aae77a9c
authored
7 years ago
by
Luke Zappia
Browse files
Options
Downloads
Patches
Plain Diff
Add PhenoParams
parent
b4e0f76f
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
DESCRIPTION
+2
-1
2 additions, 1 deletion
DESCRIPTION
R/AllClasses.R
+40
-0
40 additions, 0 deletions
R/AllClasses.R
R/PhenoParams-methods.R
+79
-0
79 additions, 0 deletions
R/PhenoParams-methods.R
tests/testthat/test-PhenoParams.R
+15
-0
15 additions, 0 deletions
tests/testthat/test-PhenoParams.R
with
136 additions
and
1 deletion
DESCRIPTION
+
2
−
1
View file @
aae77a9c
...
...
@@ -52,7 +52,8 @@ Suggests:
S4Vectors,
scDD,
scran,
mfa
mfa,
phenopath
biocViews: SingleCell, RNASeq, Transcriptomics, GeneExpression, Sequencing,
Software
URL: https://github.com/Oshlack/splatter
...
...
This diff is collapsed.
Click to expand it.
R/AllClasses.R
+
40
−
0
View file @
aae77a9c
...
...
@@ -500,3 +500,43 @@ setClass("MFAParams",
dropout.lambda
=
"numeric"
),
prototype
=
prototype
(
trans.prop
=
0
,
zero.neg
=
TRUE
,
dropout.present
=
FALSE
,
dropout.lambda
=
1
))
#' The PhenoParams class
#'
#' S4 class that holds parameters for the PhenoPath simulation.
#'
#' @section Parameters:
#'
#' The PhenoPath simulation uses the following parameters:
#'
#' \describe{
#' \item{\code{nGenes}}{The number of genes to simulate.}
#' \item{\code{nCells}}{The number of cells to simulate.}
#' \item{\code{[seed]}}{Seed to use for generating random numbers.}
#' \item{\code{[n.de]}}{Number of genes to simulate from the differential
#' expression regime}
#' \item{\code{[n.pst]}}{Number of genes to simulate from the pseudotime
#' regime}
#' \item{\code{[n.pst.beta]}}{Number of genes to simulate from the
#' pseudotime + beta interactions regime}
#' \item{\code{[n.de.pst.beta]}}{Number of genes to simulate from the
#' differential expression + pseudotime + interactions regime}
#' }
#'
#' The parameters not shown in brackets can be estimated from real data using
#' \code{\link{phenoEstimate}}. For details of the PhenoPath simulation
#' see \code{\link{phenoSimulate}}.
#'
#' @name PhenoParams
#' @rdname PhenoParams
#' @aliases PhenoParams-class
#' @exportClass PhenoParams
setClass
(
"PhenoParams"
,
contains
=
"Params"
,
slots
=
c
(
n.de
=
"numeric"
,
n.pst
=
"numeric"
,
n.pst.beta
=
"numeric"
,
n.de.pst.beta
=
"numeric"
),
prototype
=
prototype
(
n.de
=
2500
,
n.pst
=
2500
,
n.pst.beta
=
2500
,
n.de.pst.beta
=
2500
))
This diff is collapsed.
Click to expand it.
R/PhenoParams-methods.R
0 → 100644
+
79
−
0
View file @
aae77a9c
#' @rdname newParams
#' @importFrom methods new
#' @export
newPhenoParams
<-
function
(
...
)
{
if
(
!
requireNamespace
(
"phenopath"
,
quietly
=
TRUE
))
{
stop
(
"The PhenoPath simulation requires the 'phenopath' package."
)
}
params
<-
new
(
"PhenoParams"
)
params
<-
setParams
(
params
,
...
)
return
(
params
)
}
setValidity
(
"PhenoParams"
,
function
(
object
)
{
v
<-
getParams
(
object
,
slotNames
(
object
))
checks
<-
c
(
nGenes
=
checkmate
::
checkInt
(
v
$
nGenes
,
lower
=
1
),
nCells
=
checkmate
::
checkInt
(
v
$
nCells
,
lower
=
1
),
n.de
=
checkmate
::
checkInt
(
v
$
n.de
,
lower
=
0
),
n.pst
=
checkmate
::
checkInt
(
v
$
n.pst
,
lower
=
0
),
n.pst.beta
=
checkmate
::
checkInt
(
v
$
n.pst.beta
,
lower
=
0
),
n.de.pst.beta
=
checkmate
::
checkInt
(
v
$
n.de.pst.beta
,
lower
=
0
),
seed
=
checkmate
::
checkInt
(
v
$
seed
,
lower
=
0
))
if
(
v
$
nGenes
!=
(
v
$
n.de
+
v
$
n.pst
+
v
$
n.pst.beta
+
v
$
n.de.pst.beta
))
{
checks
<-
c
(
checks
,
nGenes
=
paste
(
"nGenes is not consistent with"
,
"n.de, n.pst, n.pst.beta, n.de.pst.beta"
))
}
if
(
all
(
checks
==
TRUE
))
{
valid
<-
TRUE
}
else
{
valid
<-
checks
[
checks
!=
TRUE
]
valid
<-
paste
(
names
(
valid
),
valid
,
sep
=
": "
)
}
return
(
valid
)
})
#' @rdname setParam
setMethod
(
"setParam"
,
"PhenoParams"
,
function
(
object
,
name
,
value
)
{
checkmate
::
assertString
(
name
)
if
(
name
==
"nGenes"
)
{
stop
(
name
,
" cannot be set directly, set n.de, n.pst, n.pst.beta or "
,
"n.de.pst.beta instead"
)
}
nNames
<-
c
(
"n.de"
,
"n.pst"
,
"n.pst.beta"
,
"n.de.pst.beta"
)
if
(
name
%in%
nNames
)
{
checkmate
::
assertInt
(
value
,
lower
=
0
)
total
<-
value
for
(
nName
in
nNames
)
{
if
(
nName
!=
name
)
{
total
<-
total
+
getParam
(
object
,
nName
)
}
}
object
<-
setParamUnchecked
(
object
,
"nGenes"
,
total
)
}
object
<-
callNextMethod
()
return
(
object
)
})
setMethod
(
"show"
,
"PhenoParams"
,
function
(
object
)
{
pp
<-
list
(
"Genes:"
=
c
(
"[DE]"
=
"n.de"
,
"[PST]"
=
"n.pst"
,
"[PST + Beta]"
=
"n.pst.beta"
,
"[DE + PST + Beta]"
=
"n.de.pst.beta"
))
callNextMethod
()
showPP
(
object
,
pp
)
})
This diff is collapsed.
Click to expand it.
tests/testthat/test-PhenoParams.R
0 → 100644
+
15
−
0
View file @
aae77a9c
context
(
"PhenoParams"
)
test_that
(
"constructor is valid"
,
{
expect_true
(
validObject
(
newSCDDParams
()))
})
test_that
(
"nGenes checks work"
,
{
params
<-
newPhenoParams
()
expect_error
(
setParam
(
params
,
"nGenes"
,
1
),
"nGenes cannot be set directly"
)
params
<-
setParam
(
params
,
"n.de"
,
0
)
total
<-
getParam
(
params
,
"n.de"
)
+
getParam
(
params
,
"n.pst"
)
+
getParam
(
params
,
"n.pst.beta"
)
+
getParam
(
params
,
"n.de.pst.beta"
)
expect_equal
(
getParam
(
params
,
"nGenes"
),
total
)
})
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