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
dd3df053
Commit
dd3df053
authored
7 years ago
by
Luke Zappia
Browse files
Options
Downloads
Patches
Plain Diff
Add mfaSimulate
parent
712fe45c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
NAMESPACE
+1
-0
1 addition, 0 deletions
NAMESPACE
R/mfa-simulate.R
+84
-0
84 additions, 0 deletions
R/mfa-simulate.R
man/mfaSimulate.Rd
+41
-0
41 additions, 0 deletions
man/mfaSimulate.Rd
with
126 additions
and
0 deletions
NAMESPACE
+
1
−
0
View file @
dd3df053
...
@@ -26,6 +26,7 @@ export(makeCompPanel)
...
@@ -26,6 +26,7 @@ export(makeCompPanel)
export(makeDiffPanel)
export(makeDiffPanel)
export(makeOverallPanel)
export(makeOverallPanel)
export(mfaEstimate)
export(mfaEstimate)
export(mfaSimulate)
export(newLun2Params)
export(newLun2Params)
export(newLunParams)
export(newLunParams)
export(newMFAParams)
export(newMFAParams)
...
...
This diff is collapsed.
Click to expand it.
R/mfa-simulate.R
0 → 100644
+
84
−
0
View file @
dd3df053
#' MFA simulation
#'
#' Simulate a bifurcating pseudotime path using the mfa method.
#'
#' @param params MFAParams object containing simulation parameters.
#' @param verbose Logical. Whether to print progress messages.
#' @param ... any additional parameter settings to override what is provided in
#' \code{params}.
#'
#' @details
#' This function is just a wrapper around \code{\link[mfa]{create_synthetic}}
#' that takes a \code{\link{MFAParams}}, runs the simulation then converts the
#' output to a \code{\link[SingleCellExperiment]{SingleCellExperiment}} object.
#' See \code{\link[mfa]{create_synthetic}} and the mfa paper for more details
#' about how the simulation works.
#'
#' @return SingleCellExperiment containing simulated counts
#'
#' @references
#' Campbell KR, Yau C. Probabilistic modeling of bifurcations in single-cell
#' gene expression data using a Bayesian mixture of factor analyzers. Wellcome
#' Open Research (2017).
#'
#' Paper: \url{10.12688/wellcomeopenres.11087.1}
#'
#' Code: \url{https://github.com/kieranrcampbell/mfa}
#'
#' @examples
#' sim <- mfaSimulate()
#' @export
mfaSimulate
<-
function
(
params
=
newMFAParams
(),
verbose
=
TRUE
,
...
)
{
checkmate
::
assertClass
(
params
,
"MFAParams"
)
params
<-
setParams
(
params
,
...
)
# Set random seed
seed
<-
getParam
(
params
,
"seed"
)
set.seed
(
seed
)
# Get the parameters we are going to use
nCells
<-
getParam
(
params
,
"nCells"
)
nGenes
<-
getParam
(
params
,
"nGenes"
)
trans.prop
<-
getParam
(
params
,
"trans.prop"
)
zero.neg
<-
getParam
(
params
,
"zero.neg"
)
dropout.present
<-
getParam
(
params
,
"dropout.present"
)
dropout.lambda
<-
getParam
(
params
,
"dropout.lambda"
)
if
(
verbose
)
{
message
(
"Simulating counts..."
)}
mfa.sim
<-
mfa
::
create_synthetic
(
C
=
nCells
,
G
=
nGenes
,
p_transient
=
trans.prop
,
zero_negative
=
zero.neg
,
model_dropout
=
dropout.present
,
lambda
=
dropout.lambda
)
if
(
verbose
)
{
message
(
"Creating final dataset..."
)}
cell.names
<-
paste0
(
"Cell"
,
seq_len
(
nCells
))
gene.names
<-
paste0
(
"Gene"
,
seq_len
(
nGenes
))
counts
<-
t
(
mfa.sim
$
X
)
rownames
(
counts
)
<-
gene.names
colnames
(
counts
)
<-
cell.names
cells
<-
data.frame
(
Cell
=
cell.names
,
Branch
=
mfa.sim
$
branch
,
Pseudotime
=
mfa.sim
$
pst
)
rownames
(
cells
)
<-
cell.names
features
<-
data.frame
(
Gene
=
gene.names
,
KBranch1
=
mfa.sim
$
k
[,
1
],
KBranch2
=
mfa.sim
$
k
[,
2
],
PhiBranch1
=
mfa.sim
$
phi
[,
1
],
PhiBranch2
=
mfa.sim
$
phi
[,
2
],
DeltaBranch1
=
mfa.sim
$
delta
[,
1
],
DeltaBranch2
=
mfa.sim
$
delta
[,
2
])
rownames
(
features
)
<-
gene.names
sim
<-
SingleCellExperiment
(
assays
=
list
(
counts
=
counts
),
rowData
=
features
,
colData
=
cells
,
metadata
=
list
(
params
=
params
))
return
(
sim
)
}
This diff is collapsed.
Click to expand it.
man/mfaSimulate.Rd
0 → 100644
+
41
−
0
View file @
dd3df053
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/mfa-simulate.R
\name{mfaSimulate}
\alias{mfaSimulate}
\title{MFA simulation}
\usage{
mfaSimulate(params = newMFAParams(), verbose = TRUE, ...)
}
\arguments{
\item{params}{MFAParams object containing simulation parameters.}
\item{verbose}{Logical. Whether to print progress messages.}
\item{...}{any additional parameter settings to override what is provided in
\code{params}.}
}
\value{
SingleCellExperiment containing simulated counts
}
\description{
Simulate a bifurcating pseudotime path using the mfa method.
}
\details{
This function is just a wrapper around \code{\link[mfa]{create_synthetic}}
that takes a \code{\link{MFAParams}}, runs the simulation then converts the
output to a \code{\link[SingleCellExperiment]{SingleCellExperiment}} object.
See \code{\link[mfa]{create_synthetic}} and the mfa paper for more details
about how the simulation works.
}
\examples{
sim <- mfaSimulate()
}
\references{
Campbell KR, Yau C. Probabilistic modeling of bifurcations in single-cell
gene expression data using a Bayesian mixture of factor analyzers. Wellcome
Open Research (2017).
Paper: \url{10.12688/wellcomeopenres.11087.1}
Code: \url{https://github.com/kieranrcampbell/mfa}
}
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