| binomRegMethModelSim {SOMNiBUS} | R Documentation |
Simulate Bisulfite sequencing data from a
Generalized Additive Model
with functional parameters varying
with the genomic position. Both the true methylated counts
and observed methylated
counts are generated,
given the error/conversion rate parameters p0 and
p1. In addition,
the true methylated counts can be simulated
from a binomial or a dispersed binomial distribution
(Beta-binomial distribution).
binomRegMethModelSim( n, posit, theta.0, beta, phi, random.eff = FALSE, mu.e = 0, sigma.ee = 1, p0 = 0.003, p1 = 0.9, X, Z, binom.link = "logit" )
n |
sample size |
posit |
genomic position; a numeric vector of size
|
theta.0 |
a functional parameter for the intercept of
the GAMM model;
a numeric vector of size |
beta |
a functional parameter for the slope of cell
type composition. a numeric
vector of size |
phi |
multiplicative dispersion parameter for each
loci in a region. a vector of
length |
random.eff |
indicate whether adding the subject-specific
random effect term
|
mu.e |
the mean of the random effect; a single number. |
sigma.ee |
variance of the random effect; a single positive number. |
p0 |
the probability of observing a methylated read when
the underlying true
status is unmethylated. |
p1 |
the probability of observing a methylated read when
the underlying true
status is methylated. |
X |
the matrix of the read coverage for each CpG in
each sample; a matrix of n
rows and |
Z |
numeric matrix with |
binom.link |
the link function used for simulation |
The function returns a list of following objects
S the true methylation counts; a numeric matrix
of n rows and
p columns
Y the observed methylation counts; a numeric
matrix of n rows and
p columns
theta the methylation parameter (after the logit
transformation); a
numeric matrix of n rows and p columns
pi the true methylation proportions used to
simulate the data; a numeric
matrix of n rows and p columns
Kaiqiong Zhao
#------------------------------------------------------------#
data(RAdat)
RAdat.f <- na.omit(RAdat[RAdat$Total_Counts != 0, ])
out <- binomRegMethModel(
data=RAdat.f, n.k=rep(5, 3), p0=0, p1=1,
epsilon=10^(-6), epsilon.lambda=10^(-3), maxStep=200,
detail=FALSE, RanEff = FALSE
)
Z = as.matrix(RAdat.f[match(unique(RAdat.f$ID), RAdat.f$ID),
c('T_cell', 'RA')])
set.seed(123)
X = matrix(sample(80, nrow(Z)*length(out$uni.pos), replace = TRUE),
nrow = nrow(Z), ncol = length(out$uni.pos))+10
simdat = binomRegMethModelSim(n=nrow(Z), posit= out$uni.pos,
theta.0=out$Beta.out[,1], beta= out$Beta.out[,-1], random.eff=FALSE,
mu.e=0,sigma.ee=1, p0=0.003, p1=0.9,X=X , Z=Z, binom.link='logit',
phi = rep(1, length(out$uni.pos)))