View source: R/binomRegMethModelSim.R
binomRegMethModelSim | 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", verbose = TRUE )
n |
sample size |
posit |
a numeric vector of size |
theta.0 |
numeric vector of size |
beta |
numeric vector of size |
phi |
a vector of length |
random.eff |
indicates whether adding the subject-specific random effect
term |
mu.e |
number, the mean of the random effect. |
sigma.ee |
positive number, variance of the random effect |
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 |
verbose |
logical indicates if the algorithm should provide progress report information. The default value is TRUE. |
The function returns a list of following objects
S
a numeric matrix of n
rows and p
columns
containing the true methylation counts;
Y
a numeric matrix of n
rows and p
columns
containing the observed methylation counts;
theta
a numeric matrix of n
rows and p
columns
containing the methylation parameter (after the logit transformation);
pi
a numeric matrix of n
rows and p
columns
containing the true methylation proportions used to simulate the data.
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, 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)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.