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
2fb13ced
Commit
2fb13ced
authored
8 years ago
by
Luke Zappia
Browse files
Options
Downloads
Patches
Plain Diff
Add extra checks checkParams
Check that path.from has possible values
parent
203093ce
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
DESCRIPTION
+1
-1
1 addition, 1 deletion
DESCRIPTION
R/params.R
+26
-10
26 additions, 10 deletions
R/params.R
man/checkParams.Rd
+2
-0
2 additions, 0 deletions
man/checkParams.Rd
tests/testthat/test-params.R
+16
-0
16 additions, 0 deletions
tests/testthat/test-params.R
with
45 additions
and
11 deletions
DESCRIPTION
+
1
−
1
View file @
2fb13ced
Package: splatter
Type: Package
Title: Simple Simulation of Single-cell RNA Sequencing Data
Version: 0.3.1
0
Version: 0.3.1
1
Date: 2016-10-10
Author: Luke Zappia
Authors@R: as.person(c(
...
...
This diff is collapsed.
Click to expand it.
R/params.R
+
26
−
10
View file @
2fb13ced
...
...
@@ -302,6 +302,8 @@ getParams <- function(params, names) {
#' \item{Vector parameters are the correct length}
#' \item{Vector parameters do not contain NAs}
#' \item{Non-vector parameters are single values}
#' \item{nCells, nGroups and groupCells are consistent}
#' \item{path.from has possible values}
#' }
#'
#' @return Produces error if not valid otherwise nothing
...
...
@@ -321,15 +323,16 @@ checkParams <- function(params) {
# INT = Positive integer
# PROB = Positive numeric in range 0-1
# LOG = Logical
types
<-
c
(
nGenes
=
"INT"
,
nCells
=
"INT"
,
groupCells
=
"INT"
,
mean.rate
=
"POS"
,
mean.shape
=
"POS"
,
lib.loc
=
"NUM"
,
lib.scale
=
"POS"
,
out.prob
=
"PROB"
,
out.loProb
=
"PROB"
,
out.facLoc
=
"NUM"
,
out.facScale
=
"POS"
,
de.prob
=
"PROB"
,
de.downProb
=
"PROB"
,
de.facLoc
=
"NUM"
,
de.facScale
=
"POS"
,
bcv.common
=
"POS"
,
bcv.DF
=
"POS"
,
dropout.present
=
"LOG"
,
dropout.mid
=
"NUM"
,
dropout.shape
=
"NUM"
,
path.from
=
"INT"
,
path.length
=
"INT"
,
path.skew
=
"PROB"
,
path.nonlinearProb
=
"PROB"
,
path.sigmaFac
=
"POS"
)
types
<-
c
(
nGenes
=
"INT"
,
nCells
=
"INT"
,
nGroups
=
"INT"
,
groupCells
=
"INT"
,
mean.rate
=
"POS"
,
mean.shape
=
"POS"
,
lib.loc
=
"NUM"
,
lib.scale
=
"POS"
,
out.prob
=
"PROB"
,
out.loProb
=
"PROB"
,
out.facLoc
=
"NUM"
,
out.facScale
=
"POS"
,
de.prob
=
"PROB"
,
de.downProb
=
"PROB"
,
de.facLoc
=
"NUM"
,
de.facScale
=
"POS"
,
bcv.common
=
"POS"
,
bcv.DF
=
"POS"
,
dropout.present
=
"LOG"
,
dropout.mid
=
"NUM"
,
dropout.shape
=
"NUM"
,
path.from
=
"INT"
,
path.length
=
"INT"
,
path.skew
=
"PROB"
,
path.nonlinearProb
=
"PROB"
,
path.sigmaFac
=
"POS"
)
# Define which parameters are allowed to be vectors
vectors
<-
c
(
"groupCells"
,
"path.from"
,
"path.length"
,
"path.skew"
)
...
...
@@ -385,10 +388,23 @@ checkParams <- function(params) {
n.cells
<-
getParams
(
params
,
"nCells"
)
n.groups
<-
getParams
(
params
,
"nGroups"
)
group.cells
<-
getParams
(
params
,
"groupCells"
)
if
(
!
is.na
(
group.cells
)
&&
if
(
!
all
(
is.na
(
group.cells
)
)
&&
(
n.cells
!=
sum
(
group.cells
)
||
n.groups
!=
length
(
group.cells
)))
{
stop
(
"nCells, nGroups and groupCells are not consistent"
)
}
# Check path.from contains origin, has allowed values and does not reference
# itself (no loops)
path.from
<-
getParams
(
params
,
"path.from"
)
if
(
!
all
(
is.na
(
path.from
)))
{
if
(
!
(
0
%in%
path.from
))
{
stop
(
"origin must be specified in path.from"
)
}
else
if
(
any
(
path.from
>
n.groups
))
{
stop
(
"values in path.from cannot be greater than number of paths"
)
}
else
if
(
any
(
path.from
==
1
:
n.groups
))
{
stop
(
"path cannot begin at itself"
)
}
}
}
#' Merge two splatParams objects
...
...
This diff is collapsed.
Click to expand it.
man/checkParams.Rd
+
2
−
0
View file @
2fb13ced
...
...
@@ -27,6 +27,8 @@ The following checks are made:
\item{Vector parameters are the correct length}
\item{Vector parameters do not contain NAs}
\item{Non-vector parameters are single values}
\item{nCells, nGroups and groupCells are consistent}
\item{path.from has possible values}
}
}
\examples{
...
...
This diff is collapsed.
Click to expand it.
tests/testthat/test-params.R
+
16
−
0
View file @
2fb13ced
...
...
@@ -107,6 +107,22 @@ test_that("checkParams checks groupCells", {
"nCells, nGroups and groupCells are not consistent"
)
})
test_that
(
"checkParams checks path.from"
,
{
params
<-
splatParams
()
params
<-
setParams
(
params
,
groupCells
=
c
(
10
,
10
))
params
$
path
$
from
<-
c
(
0
,
1
)
expect_silent
(
checkParams
(
params
))
params
$
path
$
from
<-
c
(
0
,
3
)
expect_error
(
checkParams
(
params
),
"values in path.from cannot be greater than number of paths"
)
params
$
path
$
from
<-
c
(
1
,
0
)
expect_error
(
checkParams
(
params
),
"path cannot begin at itself"
)
params
<-
splatParams
()
params
<-
setParams
(
params
,
groupCells
=
c
(
10
,
10
,
10
))
params
$
path
$
from
<-
c
(
2
,
1
,
1
)
expect_error
(
checkParams
(
params
),
"origin must be specified in path.from"
)
})
test_that
(
"setParams sets correctly"
,
{
params
<-
splatParams
()
params
<-
setParams
(
params
,
nGenes
=
100
)
...
...
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