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
ebc0e307
Commit
ebc0e307
authored
8 years ago
by
Luke Zappia
Browse files
Options
Downloads
Patches
Plain Diff
Add getParams, change updateParams to setParams
parent
c695d501
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
NAMESPACE
+2
-1
2 additions, 1 deletion
NAMESPACE
R/params.R
+103
-54
103 additions, 54 deletions
R/params.R
man/getParams.Rd
+32
-0
32 additions, 0 deletions
man/getParams.Rd
man/setParams.Rd
+8
-8
8 additions, 8 deletions
man/setParams.Rd
man/splatParams.Rd
+1
-1
1 addition, 1 deletion
man/splatParams.Rd
with
146 additions
and
64 deletions
NAMESPACE
+
2
−
1
View file @
ebc0e307
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
S3method(print,splatParams)
S3method(print,splatParams)
export(checkParams)
export(checkParams)
export(defaultParams)
export(defaultParams)
export(getParams)
export(mergeParams)
export(mergeParams)
export(setParams)
export(splatParams)
export(splatParams)
export(updateParams)
This diff is collapsed.
Click to expand it.
R/params.R
+
103
−
54
View file @
ebc0e307
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
#' S3 class for holding Splatter simulation parameters.
#' S3 class for holding Splatter simulation parameters.
#'
#'
#' @param ... parameters to set in the new params object, passed to
#' @param ... parameters to set in the new params object, passed to
#' \code{\link{
update
Params}}.
#' \code{\link{
set
Params}}.
#'
#'
#' @details
#' @details
#' The splatParams object is a list based S3 object for holding simulation
#' The splatParams object is a list based S3 object for holding simulation
...
@@ -108,7 +108,7 @@ splatParams <- function(...) {
...
@@ -108,7 +108,7 @@ splatParams <- function(...) {
class
(
params
)
<-
"splatParams"
class
(
params
)
<-
"splatParams"
params
<-
update
Params
(
params
,
...
)
params
<-
set
Params
(
params
,
...
)
return
(
params
)
return
(
params
)
}
}
...
@@ -157,6 +157,106 @@ print.splatParams <- function(x, ...) {
...
@@ -157,6 +157,106 @@ print.splatParams <- function(x, ...) {
}
}
}
}
#' Update a splatParams object
#'
#' Set any of the parameters in a splatParams object to have a new value.
#'
#' @param params the splatParams object to update.
#' @param ... Any parameters to set.
#'
#' @details
#' This function allows multiple parameters to be updated or set using a single
#' simple function call. Parameters to update are specified by supplying
#' additional arguments that follow the levels of the splatParams data structure
#' separated by the "." character. For example
#' \code{setParams(params, nGenes = 100)} is equivalent to
#' \code{params$nGenes <- 100} and \code{update(params, mean.rate = 1)} is
#' equivalent to \code{params$mean$rate <- 1}. For more details of the available
#' parameters and the splatParams data structure see \code{\link{splatParams}}.
#'
#' @return splatParms object with updated parameters
#' @examples
#' params <- defaultParams()
#' params
#' # Set nGenes and nCells
#' params <- setParams(params, nGenes = 1000, nCells = 200)
#' params
#' # Set mean rate paramater and library size location parameter
#' params <- setParams(params, mean.rate = 1, lib.loc = 12)
#' params
#' @export
setParams
<-
function
(
params
,
...
)
{
update
<-
list
(
...
)
if
(
length
(
update
)
==
0
)
{
return
(
params
)
}
names
<-
strsplit
(
names
(
update
),
"."
,
fixed
=
TRUE
)
for
(
idx
in
seq_along
(
names
))
{
name
<-
names
[[
idx
]]
value
<-
update
[[
idx
]]
if
(
length
(
name
)
==
1
)
{
params
[[
name
]]
<-
value
}
else
{
params
[[
name
[
1
]]][[
name
[
2
]]]
<-
value
}
}
return
(
params
)
}
#' Get parameters from splatParams object
#'
#' Get values for the parameters in a splatParams object. Uses the same pattern
#' (category.parameter) as \code{\link{setParams}}.
#'
#' @param params splatParams object to get parameters from.
#' @param names vector of parameter names to extract.
#'
#' @return Vector if all selected parameters are single values, otherwise a
#' list.
#' @examples
#' params <- defaultParams()
#' # Get the number of genes
#' getParams(params, "nGenes")
#' # Get the number of genes and the mean rate parameter
#' getParams(params, c("nGenes", "mean.rate"))
#' # Returns a list if one of the selected parameters is a vector
#' params <- setParams(params, groupCells = c(100, 200))
#' getParams(parans, c("nGenes", "mean.rate", "groupCells"))
#' @export
getParams
<-
function
(
params
,
names
)
{
if
(
length
(
names
)
==
0
)
{
return
(
NULL
)
}
output
<-
list
()
keep.list
<-
FALSE
for
(
idx
in
seq_along
(
names
))
{
name
<-
names
[[
idx
]]
name.split
<-
strsplit
(
name
,
"."
,
fixed
=
TRUE
)[[
1
]]
if
(
length
(
name
)
==
1
)
{
value
<-
params
[[
name.split
]]
}
else
{
value
<-
params
[[
name.split
[
1
]]][[
name.split
[
2
]]]
}
output
[[
name
]]
<-
value
if
(
length
(
value
)
>
1
)
{
keep.list
<-
TRUE
}
}
if
(
!
keep.list
)
{
output
<-
unlist
(
output
)
}
return
(
output
)
}
#' Check splatParams object
#' Check splatParams object
#'
#'
#' Check that a splatParams object has valid parameter values.
#' Check that a splatParams object has valid parameter values.
...
@@ -260,57 +360,6 @@ checkParams <- function(params) {
...
@@ -260,57 +360,6 @@ checkParams <- function(params) {
}
}
}
}
#' Update a splatParams object
#'
#' Update any of the parameters in a splatParams object to have a new value.
#'
#' @param params the splatParams object to update.
#' @param ... Any parameters to update.
#'
#' @details
#' This function allows multiple parameters to be updated or set using a single
#' simple function call. Parameters to update are specified by supplying
#' additional arguments that follow the levels of the splatParams data structure
#' separated by the "." character. For example
#' \code{updateParams(params, nGenes = 100)} is equivalent to
#' \code{params$nGenes <- 100} and \code{update(params, mean.rate = 1)} is
#' equivalent to \code{params$mean$rate <- 1}. For more details of the available
#' parameters and the splatParams data structure see \code{\link{splatParams}}.
#'
#' @return splatParms object with updated parameters
#' @examples
#' params <- defaultParams()
#' params
#' # Set nGenes and nCells
#' params <- updateParams(params, nGenes = 1000, nCells = 200)
#' params
#' # Set mean rate paramater and library size location parameter
#' params <- updateParams(params, mean.rate = 1, lib.loc = 12)
#' params
#' @export
updateParams
<-
function
(
params
,
...
)
{
update
<-
list
(
...
)
if
(
length
(
update
)
==
0
)
{
return
(
params
)
}
update.names
<-
strsplit
(
names
(
update
),
"."
,
fixed
=
TRUE
)
for
(
idx
in
1
:
length
(
update
))
{
update.name
<-
update.names
[[
idx
]]
value
<-
update
[[
idx
]]
if
(
length
(
update.name
)
==
1
)
{
params
[[
update.name
]]
<-
value
}
else
{
params
[[
update.name
[
1
]]][[
update.name
[
2
]]]
<-
value
}
}
return
(
params
)
}
#' Merge two splatParams objects
#' Merge two splatParams objects
#'
#'
#' Merge two splatParams objects. Any parameters that are NA in the first
#' Merge two splatParams objects. Any parameters that are NA in the first
...
@@ -355,7 +404,7 @@ defaultParams <- function() {
...
@@ -355,7 +404,7 @@ defaultParams <- function() {
params
<-
splatParams
()
params
<-
splatParams
()
params
<-
update
Params
(
params
,
nGenes
=
10000
,
nCells
=
100
,
params
<-
set
Params
(
params
,
nGenes
=
10000
,
nCells
=
100
,
groupCells
=
100
,
mean.rate
=
0.3
,
mean.shape
=
0.4
,
groupCells
=
100
,
mean.rate
=
0.3
,
mean.shape
=
0.4
,
lib.loc
=
10
,
lib.scale
=
0.5
,
out.prob
=
0.1
,
lib.loc
=
10
,
lib.scale
=
0.5
,
out.prob
=
0.1
,
out.loProb
=
0.5
,
out.facLoc
=
4
,
out.facScale
=
1
,
out.loProb
=
0.5
,
out.facLoc
=
4
,
out.facScale
=
1
,
...
...
This diff is collapsed.
Click to expand it.
man/getParams.Rd
0 → 100644
+
32
−
0
View file @
ebc0e307
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/params.R
\name{getParams}
\alias{getParams}
\title{Get parameters from splatParams object}
\usage{
getParams(params, names)
}
\arguments{
\item{params}{splatParams object to get parameters from.}
\item{names}{vector of parameter names to extract.}
}
\value{
Vector if all selected parameters are single values, otherwise a
list.
}
\description{
Get values for the parameters in a splatParams object. Uses the same pattern
(category.parameter) as \code{\link{setParams}}.
}
\examples{
params <- defaultParams()
# Get the number of genes
getParams(params, "nGenes")
# Get the number of genes and the mean rate parameter
getParams(params, c("nGenes", "mean.rate"))
# Returns a list if one of the selected parameters is a vector
params <- setParams(params, groupCells = c(100, 200))
getParams(parans, c("nGenes", "mean.rate", "groupCells"))
}
This diff is collapsed.
Click to expand it.
man/
update
Params.Rd
→
man/
set
Params.Rd
+
8
−
8
View file @
ebc0e307
% Generated by roxygen2: do not edit by hand
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/params.R
% Please edit documentation in R/params.R
\name{
update
Params}
\name{
set
Params}
\alias{
update
Params}
\alias{
set
Params}
\title{Update a splatParams object}
\title{Update a splatParams object}
\usage{
\usage{
update
Params(params, ...)
set
Params(params, ...)
}
}
\arguments{
\arguments{
\item{params}{the splatParams object to update.}
\item{params}{the splatParams object to update.}
\item{...}{Any parameters to
update
.}
\item{...}{Any parameters to
set
.}
}
}
\value{
\value{
splatParms object with updated parameters
splatParms object with updated parameters
}
}
\description{
\description{
Update
any of the parameters in a splatParams object to have a new value.
Set
any of the parameters in a splatParams object to have a new value.
}
}
\details{
\details{
This function allows multiple parameters to be updated or set using a single
This function allows multiple parameters to be updated or set using a single
simple function call. Parameters to update are specified by supplying
simple function call. Parameters to update are specified by supplying
additional arguments that follow the levels of the splatParams data structure
additional arguments that follow the levels of the splatParams data structure
separated by the "." character. For example
separated by the "." character. For example
\code{
update
Params(params, nGenes = 100)} is equivalent to
\code{
set
Params(params, nGenes = 100)} is equivalent to
\code{params$nGenes <- 100} and \code{update(params, mean.rate = 1)} is
\code{params$nGenes <- 100} and \code{update(params, mean.rate = 1)} is
equivalent to \code{params$mean$rate <- 1}. For more details of the available
equivalent to \code{params$mean$rate <- 1}. For more details of the available
parameters and the splatParams data structure see \code{\link{splatParams}}.
parameters and the splatParams data structure see \code{\link{splatParams}}.
...
@@ -31,10 +31,10 @@ parameters and the splatParams data structure see \code{\link{splatParams}}.
...
@@ -31,10 +31,10 @@ parameters and the splatParams data structure see \code{\link{splatParams}}.
params <- defaultParams()
params <- defaultParams()
params
params
# Set nGenes and nCells
# Set nGenes and nCells
params <-
update
Params(params, nGenes = 1000, nCells = 200)
params <-
set
Params(params, nGenes = 1000, nCells = 200)
params
params
# Set mean rate paramater and library size location parameter
# Set mean rate paramater and library size location parameter
params <-
update
Params(params, mean.rate = 1, lib.loc = 12)
params <-
set
Params(params, mean.rate = 1, lib.loc = 12)
params
params
}
}
This diff is collapsed.
Click to expand it.
man/splatParams.Rd
+
1
−
1
View file @
ebc0e307
...
@@ -8,7 +8,7 @@ splatParams(...)
...
@@ -8,7 +8,7 @@ splatParams(...)
}
}
\arguments{
\arguments{
\item{...}{parameters to set in the new params object, passed to
\item{...}{parameters to set in the new params object, passed to
\code{\link{
update
Params}}.}
\code{\link{
set
Params}}.}
}
}
\value{
\value{
List based S3 splatParams object
List based S3 splatParams object
...
...
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