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
aea823a4
Commit
aea823a4
authored
8 years ago
by
Luke Zappia
Browse files
Options
Downloads
Patches
Plain Diff
Add simPathDE function
Rename old function to include group
parent
2fb13ced
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
DESCRIPTION
+1
-1
1 addition, 1 deletion
DESCRIPTION
R/simulate.R
+81
-8
81 additions, 8 deletions
R/simulate.R
man/getPathOrder.Rd
+23
-0
23 additions, 0 deletions
man/getPathOrder.Rd
with
105 additions
and
9 deletions
DESCRIPTION
+
1
−
1
View file @
aea823a4
Package: splatter
Type: Package
Title: Simple Simulation of Single-cell RNA Sequencing Data
Version: 0.3.1
1
Version: 0.3.1
2
Date: 2016-10-10
Author: Luke Zappia
Authors@R: as.person(c(
...
...
This diff is collapsed.
Click to expand it.
R/simulate.R
+
81
−
8
View file @
aea823a4
...
...
@@ -15,7 +15,8 @@
# set.seed
# group DE
# Min path length
# Path.from
#' FUNCTION TITLE
#'
...
...
@@ -49,7 +50,11 @@ splat <- function(params = defaultParams(), method = c("groups", "paths"),
# Set up name vectors
cell.names
<-
paste0
(
"Cell"
,
1
:
n.cells
)
gene.names
<-
paste0
(
"Gene"
,
1
:
n.genes
)
group.names
<-
paste0
(
"Group"
,
1
:
n.groups
)
if
(
method
==
"groups"
)
{
group.names
<-
paste0
(
"Group"
,
1
:
n.groups
)
}
else
if
(
method
==
"paths"
)
{
group.names
<-
paste0
(
"Path"
,
1
:
n.groups
)
}
# Create SCESet with dummy counts to store simulation
dummy.counts
<-
matrix
(
1
,
ncol
=
n.cells
,
nrow
=
n.genes
)
...
...
@@ -71,11 +76,15 @@ splat <- function(params = defaultParams(), method = c("groups", "paths"),
sim
<-
simLibSizes
(
sim
,
params
)
sim
<-
simGeneMeans
(
sim
,
params
)
sim
<-
simDE
(
sim
,
params
)
sim
<-
simGroupCellMeans
(
sim
,
params
)
sim
<-
simBCVMeans
(
sim
,
params
)
sim
<-
simTrueCounts
(
sim
,
params
)
sim
<-
simDropout
(
sim
,
params
)
if
(
method
==
"groups"
)
{
sim
<-
simGroupDE
(
sim
,
params
)
sim
<-
simGroupCellMeans
(
sim
,
params
)
}
else
{
sim
<-
simPathDE
(
sim
,
params
)
}
#sim <- simBCVMeans(sim, params)
#sim <- simTrueCounts(sim, params)
#im <- simDropout(sim, params)
# Create new SCESet to make sure values are calculated correctly
sce
<-
newSCESet
(
countData
=
counts
(
sim
),
...
...
@@ -129,7 +138,7 @@ simGeneMeans <- function(sim, params) {
return
(
sim
)
}
simDE
<-
function
(
sim
,
params
)
{
sim
Group
DE
<-
function
(
sim
,
params
)
{
n.genes
<-
getParams
(
params
,
"nGenes"
)
de.prob
<-
getParams
(
params
,
"de.prob"
)
...
...
@@ -150,6 +159,29 @@ simDE <- function(sim, params) {
return
(
sim
)
}
simPathDE
<-
function
(
sim
,
params
)
{
n.genes
<-
getParams
(
params
,
"nGenes"
)
de.prob
<-
getParams
(
params
,
"de.prob"
)
de.downProb
<-
getParams
(
params
,
"de.downProb"
)
de.facLoc
<-
getParams
(
params
,
"de.facLoc"
)
de.facScale
<-
getParams
(
params
,
"de.facScale"
)
path.from
<-
getParams
(
params
,
"path.from"
)
means.gene
<-
fData
(
sim
)
$
GeneMean
path.names
<-
unique
(
pData
(
sim
)
$
Group
)
path.order
<-
getPathOrder
(
path.from
)
for
(
path.name
in
path.names
[
path.order
])
{
de.facs
<-
getLNormFactors
(
n.genes
,
de.prob
,
de.downProb
,
de.facLoc
,
de.facScale
)
path.means.gene
<-
means.gene
*
de.facs
fData
(
sim
)[[
paste0
(
"DEFac"
,
path.name
)]]
<-
de.facs
fData
(
sim
)[[
paste0
(
"GeneMean"
,
path.name
)]]
<-
path.means.gene
}
return
(
sim
)
}
simGroupCellMeans
<-
function
(
sim
,
params
)
{
cell.names
<-
pData
(
sim
)
$
Cell
...
...
@@ -287,4 +319,45 @@ getLNormFactors <- function(n.facs, sel.prob, neg.prob, fac.loc, fac.scale) {
factors
[
is.selected
]
<-
facs.selected
^
dir.selected
return
(
factors
)
}
#' Get path order
#'
#' Identify the correct order to process paths so that preceding paths have
#' already been simulated.
#'
#' @param path.from Vector giving the path endpoints that each path orginates
#' from.
#'
#' @return Vector giving the order to process paths in.
#' @examples
#' path.order <- getPathOrder(c(2, 0, 2))
getPathOrder
<-
function
(
path.from
)
{
# Transform the vector into a list of (from, to) pairs
path.pairs
<-
list
()
for
(
idx
in
1
:
length
(
path.from
))
{
path.pairs
[[
idx
]]
<-
c
(
path.from
[
idx
],
idx
)
}
# Determine the processing order
# If a path is in the "done" vector any path originating here can be
# completed
done
<-
0
while
(
length
(
path.pairs
)
>
0
)
{
path.pair
<-
path.pairs
[[
1
]]
path.pairs
<-
path.pairs
[
-1
]
from
<-
path.pair
[
1
]
to
<-
path.pair
[
2
]
if
(
from
%in%
done
)
{
done
<-
c
(
done
,
to
)
}
else
{
path.pairs
<-
c
(
path.pairs
,
list
(
path.pair
))
}
}
# Remove the origin from the vector
done
<-
done
[
-1
]
return
(
done
)
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
man/getPathOrder.Rd
0 → 100644
+
23
−
0
View file @
aea823a4
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/simulate.R
\name{getPathOrder}
\alias{getPathOrder}
\title{Get path order}
\usage{
getPathOrder(path.from)
}
\arguments{
\item{path.from}{Vector giving the path endpoints that each path orginates
from.}
}
\value{
Vector giving the order to process paths in.
}
\description{
Identify the correct order to process paths so that preceding paths have
already been simulated.
}
\examples{
path.order <- getPathOrder(c(2, 0, 2))
}
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