View source: R/at_scale_em_algo_functs.R
run_glmeiv_at_scale_simulatr | R Documentation |
Run GLM-EIV at scale simulatr
run_glmeiv_at_scale_simulatr(
dat,
m_fam,
g_fam,
covariate_matrix,
m_offset,
g_offset,
alpha = 0.95,
n_em_rep = 15,
save_membership_probs_mult = 250,
pi_guess_range = c(1e-05, 0.03),
m_perturbation_guess_range = log(c(0.1, 1.5)),
g_perturbation_guess_range = log(c(0.5, 10)),
exponentiate_coefs = FALSE,
ep_tol = 1e-04,
rm_covariate = ""
)
dat |
data frame containing columns "m" and "g" for mRNA counts and gRNA counts |
m_fam |
family describing m |
g_fam |
family describing g |
covariate_matrix |
the matrix of covariates; NULL if there are no covariates. |
m_offset |
offsets for m |
g_offset |
offsets for g |
alpha |
confidence level |
n_em_rep |
number of times to repeat EM algorithm in reduced model |
save_membership_probs_mult |
save posterior membership probabilities at this multiple |
pi_guess_range |
range of values over which to sample pi |
m_perturbation_guess_range |
range of values over which to sample m_perturbation |
g_perturbation_guess_range |
range of values over which to sample g_perturbation |
exponentiate_coefs |
(boolean) should the fitted coeficients (and associated standard errors) be exponentiated? |
ep_tol |
(optional) EM convergence threshold |
fam_str |
string (currently either "poisson" or "Negative Binomial") giving family object |
fitted GLM-EIV model
m_fam <- g_fam <- augment_family_object(poisson())
n <- 50000
lib_size <- rpois(n = n, lambda = 5000)
m_offset <- g_offset <- log(lib_size)
pi <- 0.01
m_intercept <- log(0.01)
m_perturbation <- log(0.5)
g_intercept <- log(0.005)
g_perturbation <- log(2.5)
covariate_matrix <- data.frame(batch = rbinom(n = n, size = 1, prob = 0.5))
m_covariate_coefs <- log(0.9)
g_covariate_coefs <- log(1.1)
dat <- generate_full_data(m_fam = m_fam, m_intercept = m_intercept,
m_perturbation = m_perturbation, g_fam = g_fam, g_intercept = g_intercept,
g_perturbation = g_perturbation, pi = pi, n = n, B = 2,
covariate_matrix = covariate_matrix, m_covariate_coefs = m_covariate_coefs,
g_covariate_coefs = g_covariate_coefs, m_offset = m_offset, g_offset = g_offset)[[1]]
m <- dat$m; g <- dat$g; p <- dat$p
# ability to recover ground truth given p
fit <- run_glmeiv_at_scale_simulatr(dat, m_fam, g_fam, covariate_matrix, m_offset, g_offset)
fit <- run_glmeiv_random_init_simulatr(dat, m_fam, g_fam, covariate_matrix, m_offset, g_offset)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.