Skip to content
Snippets Groups Projects
Commit 3c9de622 authored by Arnaud Duvermy's avatar Arnaud Duvermy
Browse files

add v2

parent 8f13449f
No related branches found
No related tags found
No related merge requests found
Showing
with 775 additions and 0 deletions
^HTRSIM\.Rproj$
^\.Rproj\.user$
^devtools_history\.R$
Package: HTRSIM
Title: RNAseq counts simulation
Version: 0.0.0.9000
Authors@R:
person("Arnaud", "Duvermy", , "first.last@example.com", role = c("aut", "cre"),
comment = c(ORCID = "YOUR-ORCID-ID"))
Description: RNAseq counts simulation.
License: `use_mit_license()`, `use_gpl3_license()` or friends to pick a
license
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.2
Suggests:
testthat (>= 3.0.0)
Config/testthat/edition: 3
Depends:
tidyverse
Imports:
DESeq2,
furrr,
MASS,
S4Vectors,
stats,
stringr
Version: 1.0
RestoreWorkspace: No
SaveWorkspace: No
AlwaysSaveHistory: Default
EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8
RnwWeave: Sweave
LaTeX: pdfLaTeX
AutoAppendNewline: Yes
StripTrailingWhitespace: Yes
LineEndingConversion: Posix
BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageRoxygenize: rd,collate,namespace
# Generated by roxygen2: do not edit by hand
export(ddsExtraction.viz)
export(extractDistributionFromDDS)
export(getBetaforSimulation)
export(getDfComparison)
export(getGenesDispersionsForSimulation)
export(buildDesign2simulate)
export(getK_ij)
export(getLog_qij)
export(getMu_ij)
export(rnorm.distrib.beta)
export(run.deseq)
export(run.glm)
export(reshapeGlmRes)
import(DESeq2)
import(dplyr)
import(ggplot2)
import(reshape2)
import(stats)
import(stringr)
import(tidyverse)
import(MASS)
#' Get beta_ij
#'
#' @param n_genes an integer
#' @param n_genotype A int.
#' @param n_environment A int.
#' @param beta.dtf a dtf of beta0,betaG, betaE, betaGE.
#' @param model_matrix an output of stat::model.matrix()
#' @param theta a float to control the noise introduce around betaG, betaE, betaGxE
#' @import stringr
#' @import base
#' @import dplyr
#' @import Rfast
#' @import MASS
#' @import purrr
#' @return a dataframe with the gene dispersion for each samples
#' @export
#'
#' @examples
getBetaforSimulation <- function(n_genes = 100, n_genotypes = 20, n_environments = 2, beta.dtf, theta = 10 ){
x = beta.dtf %>% as.matrix()
fit.mvrnorm <- Rfast::mvnorm.mle(x)
x <- NULL
beta.matrix.tmp <- MASS::mvrnorm(n = n_genes,
mu = fit.mvrnorm$mu,
Sigma = fit.mvrnorm$sigma )
replicate_beta <- function(beta_vec, n, theta){
beta_vec.rep = rep(beta_vec, n)
beta_vec.rep + rnorm(length(beta_vec.rep), mean = 0, sd = abs(beta_vec/theta))
}
beta0 = beta.matrix.tmp[,1]
beta.matrix.tmp = purrr::map2(.x = c(2,3,4), .y = c(n_genotypes-1,
n_environments-1,
(n_genotypes-1)*(n_environments-1)),
~ replicate_beta(beta.matrix.tmp[,.x], .y, theta) %>% matrix(ncol = .y)) %>%
do.call(cbind, .)
beta.matrix = cbind(beta0, beta.matrix.tmp)
betaG.colnames = base::paste("genotype", "G", 1:(n_genotypes-1), sep = "")
betaE.colnames = base::paste("environment", "E", 1:(n_environments-1), sep = "")
betaGE.colnames = as.vector(outer(betaG.colnames, betaE.colnames, paste, sep=":"))
matrix.colnames = c('Intercept', betaG.colnames, betaE.colnames, betaGE.colnames)
colnames(beta.matrix) = matrix.colnames
rownames(beta.matrix) = base::paste("gene", 1:(n_genes), sep = "")
return(beta.matrix)
}
#' Get log(q_ij)
#'
#' @param beta.dtf a dtf of beta0,betaG, betaE, betaGE.
#' @param model_matrix an output of stat::model.matrix()
#' @import stringr
#' @import base
#' @import dplyr
#' @import
#' @return a dataframe with the gene dispersion for each samples
#' @export
#'
#' @examples
getLog_qij <- function( beta.matrix.input , model_matrix){
log_qij = beta.matrix.input %*% t(model_matrix) ## j samples (n_genotypes * n_environments), i genes
return(log_qij )
}
#' Get mu_ij
#'
#' @param beta.dtf a dtf of beta0,betaG, betaE, betaGE.
#' @param model_matrix an output of stat::model.matrix()
#' @import stringr
#' @import base
#' @import dplyr
#' @import
#' @return a dataframe with the gene dispersion for each samples
#' @export
#'
#' @examples
getMu_ij <- function( log_qij.matrix, size_factor ){
mu_ij = size_factor * 2^log_qij.matrix ## size factor * log(qij)
return(mu_ij )
}
#' Get genes dispersion
#'
#' @param n_genes an integer
#' @param n_genotype A int.
#' @param n_environment A int.
#' @param dispersion.vec A vector of observed dispersion.
#' @param dispUniform_btweenCondition logical
#' @param model_matrix an output of stat::model.matrix()
#' @import stringr
#' @import base
#' @import dplyr
#' @import
#' @return a dataframe with the gene dispersion for each samples
#' @export
#'
#' @examples
getGenesDispersionsForSimulation <- function( n_genes = 100, n_genotypes, n_environments, dispersion.vec ,dispUniform_btweenCondition = T, model_matrix ){
if (dispUniform_btweenCondition == T ) {
gene_dispersion.dtf = base::sample( dds.extraction$gene_dispersion, replace = T, size = n_genes) %>% base::data.frame()
n_rep = length(rownames(model_matrix))
gene_dispersion.dtf = gene_dispersion.dtf[,base::rep(base::seq_len(base::ncol(gene_dispersion.dtf)), n_rep)]
rownames(gene_dispersion.dtf) = base::paste("gene", 1:(n_genes), sep = "")
colnames(gene_dispersion.dtf) = rownames(model_matrix)
}
else {
replication_table = rownames(model_matrix) %>% stringr::str_replace(., pattern = "_[0-9]+","" ) %>% table()
gene_dispersion.dtf = replication_table %>% purrr::map(., ~sample( dispersion.vec, replace = T, size = n_genes) ) %>% data.frame()
gene_dispersion.dtf = gene_dispersion.dtf[,rep(seq_len(ncol(gene_dispersion.dtf)), replication_table %>% as.numeric())]
colnames(gene_dispersion.dtf) = rownames(model_matrix)
rownames(gene_dispersion.dtf) = base::paste("gene", 1:(n_genes), sep = "")
}
return(gene_dispersion.dtf %>% as.matrix)
}
#' Get K_ij : gene counts
#'
#' @param log_qij.matrix a matrix of log_qij
#' @param gene_disp.matrix a matrix of gene dispersion
#' @import stats
#' @return a dataframe with the gene dispersion for each samples
#' @export
#'
#' @examples
getK_ij <- function( mu_ij.matrix , gene_disp.matrix ){
n_genes = nrow(mu_ij.matrix)
n_sples = ncol(mu_ij.matrix)
alpha_gene = 1/gene_disp.matrix
k_ij = stats::rnbinom(length(mu_ij.matrix), size = alpha_gene , mu = mu_ij.matrix) %>% matrix(. , nrow = n_genes, ncol = n_sples )
k_ij[is.na(k_ij)] = 0
colnames(k_ij) = colnames(mu_ij.matrix)
rownames(k_ij) = rownames(mu_ij.matrix)
return(k_ij)
}
#' Build a design dataframe
#'
#' @param n_genotype A int.
#' @param n_environment A int.
#' @param n_replicate A int.
#' @param uniform_nb_rep logical
#' @examples
#' buildDesign2simulate(1000, 2, 30)
#
#' @return dataframe with n_genotype rows and 3 columns (sample_id, genotype, environment)
#' @import tidyverse
#' @import stats
#'
buildDesign2simulate <- function(n_genotype , n_environment, n_replicate , uniform_nb_rep = T ){
genotypes = base::paste("G", 0:(n_genotype-1), sep = "")
environments = base::paste("E", 0:(n_environment-1), sep = "")
sample_ids = as.vector(outer(genotypes, environments, paste, sep="_")) %>% sort()
sample_id.split = sample_ids %>% str_split(., "_", simplify = T)
design_without_rep = base::list(sample_id = sample_ids ,
environment = sample_id.split[,2],
genotype = sample_id.split[,1] ) %>% data.frame()
rows = c(1:nrow(design_without_rep))
if (uniform_nb_rep == T) times = rep(n_replicate, base::nrow(design_without_rep))
else { times = sample(1:n_replicate, base::nrow(design_without_rep), replace=T) ; message("uniform_nb_rep = FALSE \nn_replicate consider as a maximum number of replicates possible") }
design = design_without_rep %>%
dplyr::mutate(rep = times) %>%
dplyr::group_by(sample_id, genotype, environment) %>%
tidyr::expand(rep = seq(1:rep)) %>%
tidyr::unite(sample_id, sample_id, rep) %>%
dplyr::ungroup()
if (n_genotype > 1) design$genotype <- factor(x = design$genotype,levels = c("G0", unique(design$genotype)[-1]))
if (n_environment > 1) design$environment <- factor(x = design$environment, levels = c( "E0", unique(design$environment)[-1]))
model_matrix = stats::model.matrix(~ genotype + environment + genotype:environment, design)
rownames(model_matrix) = design$sample_id
return( base::list(model_matrix = model_matrix,
design2simulate = design) )
}
#' Get getDfComparison
#'
#' @param dds_simu.mcols dds object obtain on simulation
#' @param model_matrix a stats::model.matrix output
#' @param beta.actual.matrix.matrix a matrix of beta used as input for simulation
#' @param threads
#' @import stringr
#' @import base
#' @import dplyr
#' @import reshape2
#' @import DESeq2
#' @import furrr
#' @return a dataframe for beta comparison
#' @export
#'
#' @examples
getDfComparison <- function(dds_simu , model_matrix, beta.actual.matrix, threads = 4 ){
listBeta = DESeq2::resultsNames(dds_simu)
plan(multisession, workers = 4)
res = listBeta %>% furrr::future_map(.x = ., ~DESeq2::results(dds_simu, contrast=list(.x)) %>% data.frame() %>% .$padj)
padj.matrix = do.call("cbind", res)
dds_simu.mcols = S4Vectors::mcols(dds_simu,use.names=TRUE)
dds.simu.mcols.colnamesReshaped = colnames(dds_simu.mcols) %>%
stringr::str_replace(., "_vs_G0", "") %>%
stringr::str_replace(., "_vs_E0", "") %>%
stringr::str_replace_all(., "_", "") %>%
stringr::str_replace(., "\\.", ":")
columnOfInterest = model_matrix %>% base::colnames() %>% stringr::str_replace_all(., "[//(//)]", "")
#dds_simu.mcols[,columnOfInterest]
## Get only column of interest
idx_cols = base::match(columnOfInterest, dds.simu.mcols.colnamesReshaped)
beta.infered = dds_simu.mcols[,idx_cols]
## homogeneize column names & rownames
idx_cols = base::match(columnOfInterest, beta.actual.matrix %>% colnames())
beta.actual.matrix = beta.actual.matrix[,idx_cols]
colnames(beta.infered) = base::colnames(beta.actual.matrix)
colnames(padj.matrix) = base::colnames(beta.actual.matrix)
rownames(padj.matrix) = base::rownames(beta.actual.matrix)
beta.infer.long = beta.infered %>% data.frame() %>%
tibble::rownames_to_column(., var = "gene_id") %>%
dplyr::mutate(origin = "Inference") %>%
reshape2::melt(., value.name = "value", variable.name= "beta")
beta.actual.matrix.long = beta.actual.matrix %>% data.frame() %>%
tibble::rownames_to_column(., var = "gene_id") %>%
dplyr::mutate(origin = "Actual") %>%
reshape2::melt(., value.name = "value", variable.name= "beta")
padj.matrix.long = padj.matrix %>% data.frame() %>%
tibble::rownames_to_column(., var = "gene_id") %>%
dplyr::mutate(origin = "padj") %>%
reshape2::melt(., value.name = "value", variable.name= "beta")
beta.merged.long = rbind(beta.infer.long, beta.actual.matrix.long, padj.matrix.long)
#beta.merged.long$beta %>% unique()
beta.merged.long.reshape = beta.merged.long %>% dplyr::mutate(type = dplyr::case_when(
str_detect(beta, "genotypeG\\d+\\.environment") ~ "GxE",
str_detect(beta, "genotypeG\\d+$") ~ "G",
str_detect(beta, "environmentE\\d+$") ~ "E",
str_detect(beta, "Intercept$") ~ "Intercept")
)
beta.merged.long.reshape2 = beta.merged.long.reshape %>% reshape2::dcast(., gene_id + beta + type ~ origin)
beta.merged.long.reshape2$type = factor(beta.merged.long.reshape2$type, levels = c("Intercept", "G", "E", "GxE"))
return(beta.merged.long.reshape2)
}
#' Launch MASS:GLM.NB
#'
#' @param gene_count a row of kij simulated table
#' @param i index of the gene
#' @import dplyr
#' @import stringr
#' @import stats
#' @return a dtf
#' @export
#'
#' @examples
reshapeGlmRes <- function(fit, i, error_bool = F){
if (error_bool == T){ ## error while fiting model
res = list(Inference = NA, pval = NA,
beta = NA, gene_id = paste("gene", i, sep = ""), type = NA, deviance = NA) %>%
data.frame()
}
else{ ## success to fit model
res = coef(summary(fit))[,c(1,4)] %>%
data.frame() %>%
dplyr::rename(., pval = "Pr...z.." , Inference = "Estimate") %>%
dplyr::mutate(beta = stringr::str_remove_all(rownames(.), "[//(//)]")) %>%
dplyr::mutate(beta = stringr::str_replace(beta, ":", "."))
rownames(res) <- NULL
res = res %>%
dplyr::mutate(gene_id = paste("gene", i, sep = "") ) %>%
dplyr::mutate(type = dplyr::case_when(
stringr::str_detect(beta, "genotypeG\\d+\\.environment") ~ "GxE",
stringr::str_detect(beta, "genotypeG\\d+$") ~ "G",
stringr::str_detect(beta, "environmentE\\d+$") ~ "E",
stringr::str_detect(beta, "Intercept$") ~ "Intercept")) %>%
dplyr::mutate(dispersion = fit$theta)
#stats::summary.glm(fit)$dispersion
}
return(res)
}
#' Launch MASS:GLM.NB
#'
#' @param gene_count a row of kij simulated table
#' @param i index of the gene
#' @param design.dtf a dtf of the design simulated
#' @import MASS
#' @return a dtf
#' @export
#'
#' @examples
run.glm <- function(gene_count, i, design.dtf) {
y = gene_count
genotype = design2simulate$design2simulate$genotype
environment = design2simulate$design2simulate$environment
df_gene_i = list(y = y , genotype = genotype,environment = environment) %>% data.frame()
rownames(df_gene_i) <- NULL
print(i)
tryCatch({
fit = MASS::glm.nb(y ~ genotype + environment + genotype:environment, data = df_gene_i, link = log)
return(reshapeGlmRes(fit, i))
},
error = function(cnd){
return(reshapeGlmRes(NULL, i, error_bool = T))
}
)
}
#' Launch Deseq
#'
#' @param tabl_cnts table containing counts per genes & samples
#' @param bioDesign table describing bioDesgin of input
#' @import DESeq2
#' @return DESEQ2 object
#' @export
#'
#' @examples
run.deseq <- function(tabl_cnts, bioDesign, model = ~ genotype + environment + genotype:environment){
dds = DESeq2::DESeqDataSetFromMatrix( countData = round(tabl_cnts), colData = bioDesign , design = model )
dds <- DESeq2::DESeq(dds)
return(dds)
}
#' Extract beta distribution from DESEQ2 object
#'
#' @param dds_obj a DESEQ2 object
#' @import S4vectors
#' @return a list containing 1- mean and sd of BetaG 2- mean and sd of BetaE 3- mean and sd of BetaGE 5- mean and sd of gene dispersion
#' @export
#'
#' @examples
extractDistributionFromDDS <- function(dds_obj){
## Beta
dds.mcols = S4Vectors::mcols(dds, use.names=TRUE)
beta0 <- dds.mcols$Intercept
betaG <- dds.mcols$genotype_RM11_vs_GSY147
betaE <- dds.mcols$environment_treated_vs_untreated
betaGE <- dds.mcols$genotypeRM11.environmenttreated
beta.dtf = cbind(beta0,betaG,betaE,betaGE) %>% as.data.frame() %>% drop_na()
## Dispersion
gene_disp = dds.mcols$dispersion %>% na.omit()
return(list(beta = beta.dtf,
gene_dispersion = gene_disp,
beta0.mean = mean(beta.dtf$beta0, na.rm = T), beta0.sd = sd(beta.dtf$beta0, na.rm = T) ,
betaG.mean = mean(beta.dtf$betaG, na.rm = T), betaG.sd = sd(beta.dtf$betaG, na.rm = T) ,
betaE.mean = mean(beta.dtf$betaE, na.rm = T) , betaE.sd = sd(beta.dtf$betaE, na.rm = T) ,
betaGE.mean = mean(beta.dtf$betaGE, na.rm = T) , betaGE.sd = sd(beta.dtf$betaGE, na.rm = T),
gene_disp.mean = mean(gene_disp, na.rm = T) , gene_disp.sd = sd(gene_disp, na.rm = T)))
}
#' Sampling value from a known Gaussian distribution
#'
#' @param beta_type a string (beta0, betaG, betaE, betaGE)
#' @param mean.distrib the mean of the distribution (dbl)
#' @param sd.distrib the standard deviation of the distribution (dbl)
#' @param n an integer defining the number of value sampling
#' @import dplyr
#' @import base
#' @return a dataframe
#' @export
#'
#' @examples
rnorm.distrib.beta <- function(parameter, mean.distrib , sd.distrib , n = 1000 ){
rnorm.distrib.dtf = rnorm(1000, mean = mean.distrib, sd = sd.distrib) %>%
base::data.frame() %>%
dplyr::mutate( parameter = parameter) %>%
dplyr::rename(., value = ".") %>%
dplyr::mutate(sampling_from = paste("rnorm(mean = ", signif(mean.distrib, 3), ", sd=" , signif(sd.distrib, 3), ")", sep = ""))
return(rnorm.distrib.dtf)
}
#' Vizualize the output of extractDistributionFromDDS
#'
#' @param dds.extraction output of extractDistributionFromDDS
#' @import ggplot2
#' @import base
#' @import dplyr
#' @return a plot
#' @export
#'
#' @examples
ddsExtraction.viz <- function(dds.extraction){
beta_obs.dtf.long = dds.extraction$beta %>% reshape2::melt(. , na.rm = T, variable.name = "parameter")
alpha_obs.dtf.long = dds.extraction$gene_dispersion %>% base::data.frame() %>%
dplyr::rename(., value = ".") %>%
dplyr::mutate(parameter = "dispersion")
dtf.params_obs = rbind(beta_obs.dtf.long, alpha_obs.dtf.long)
rnorm.distrib.beta0 = rnorm.distrib.beta(parameter = "beta0", mean.distrib = dds.extraction$beta0.mean, sd = dds.extraction$beta0.sd )
rnorm.distrib.betaG = rnorm.distrib.beta(parameter = "betaG", mean.distrib = dds.extraction$betaG.mean, sd = dds.extraction$betaG.sd )
rnorm.distrib.betaE = rnorm.distrib.beta(parameter = "betaE", mean.distrib = dds.extraction$betaE.mean, sd = dds.extraction$betaE.sd )
rnorm.distrib.betaGE = rnorm.distrib.beta(parameter = "betaGE", mean.distrib = dds.extraction$betaGE.mean, sd = dds.extraction$betaGE.sd )
rnorm.distrib.alpha = rnorm.distrib.beta(parameter = "dispersion", mean.distrib = dds.extraction$gene_disp.mean, sd = dds.extraction$gene_disp.sd )
dtf.rnorm.param = base::rbind(rnorm.distrib.beta0, rnorm.distrib.betaG, rnorm.distrib.betaE, rnorm.distrib.betaGE, rnorm.distrib.alpha)
p = ggplot(dtf.params_obs, aes(x= value)) +
geom_histogram(aes(y=..density..), colour="black", fill="white")+
geom_density(data = dtf.rnorm.param, aes(x = value, fill= sampling_from), alpha=.4) + facet_grid(~parameter)
return(p)
}
usethis::use_build_ignore("devtools_history.R")
usethis::use_package('tidyverse', type = "depends")
usethis::use_package('stats')
usethis::use_package("stringr")
usethis::use_package("MASS")
usethis::use_package("DESeq2")
usethis::use_package("furrr")
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/designSimulationBuilder.R
\name{buildDesign2simulate}
\alias{buildDesign2simulate}
\title{Build a design dataframe}
\usage{
buildDesign2simulate(
n_genotype,
n_environment,
n_replicate,
uniform_nb_rep = T
)
}
\arguments{
\item{n_genotype}{A int.}
\item{n_environment}{A int.}
\item{n_replicate}{A int.}
\item{uniform_nb_rep}{logical}
}
\value{
dataframe with n_genotype rows and 3 columns (sample_id, genotype, environment)
}
\description{
Build a design dataframe
}
\examples{
buildDesign2simulate(1000, 2, 30)
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/visualization.R
\name{ddsExtraction.viz}
\alias{ddsExtraction.viz}
\title{Vizualize the output of extractDistributionFromDDS}
\usage{
ddsExtraction.viz(dds.extraction)
}
\arguments{
\item{dds.extraction}{output of extractDistributionFromDDS}
}
\value{
a plot
}
\description{
Vizualize the output of extractDistributionFromDDS
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ublicsTableCountsExtractor.R
\name{extractDistributionFromDDS}
\alias{extractDistributionFromDDS}
\title{Extract beta distribution from DESEQ2 object}
\usage{
extractDistributionFromDDS(dds_obj)
}
\arguments{
\item{dds_obj}{a DESEQ2 object}
}
\value{
a list containing 1- mean and sd of BetaG 2- mean and sd of BetaE 3- mean and sd of BetaGE 5- mean and sd of gene dispersion
}
\description{
Extract beta distribution from DESEQ2 object
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/countsGenerator.R
\name{getBetaforSimulation}
\alias{getBetaforSimulation}
\title{Get beta_ij}
\usage{
getBetaforSimulation(
n_genes = 100,
n_genotypes = 20,
n_environments = 2,
beta.dtf,
threshold = 15
)
}
\arguments{
\item{n_genes}{an integer}
\item{beta.dtf}{a dtf of beta0,betaG, betaE, betaGE.}
\item{threshold}{an integer)}
\item{n_genotype}{A int.}
\item{n_environment}{A int.}
\item{model_matrix}{an output of stat::model.matrix()}
}
\value{
a dataframe with the gene dispersion for each samples
}
\description{
Get beta_ij
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/evaluation.R
\name{getDfComparison}
\alias{getDfComparison}
\title{Get getDfComparison}
\usage{
getDfComparison(dds_simu, model_matrix, beta.actual.matrix)
}
\arguments{
\item{model_matrix}{a stats::model.matrix output}
\item{dds_simu.mcols}{dds object obtain on simulation}
\item{beta.actual.matrix.matrix}{a matrix of beta used as input for simulation}
}
\value{
a dataframe for beta comparison
}
\description{
Get getDfComparison
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/countsGenerator.R
\name{getGenesDispersionsForSimulation}
\alias{getGenesDispersionsForSimulation}
\title{Get genes dispersion}
\usage{
getGenesDispersionsForSimulation(
n_genes = 100,
n_genotypes,
n_environments,
dispersion.vec,
dispUniform_btweenCondition = T,
model_matrix
)
}
\arguments{
\item{n_genes}{an integer}
\item{dispersion.vec}{A vector of observed dispersion.}
\item{dispUniform_btweenCondition}{logical}
\item{model_matrix}{an output of stat::model.matrix()}
\item{n_genotype}{A int.}
\item{n_environment}{A int.}
}
\value{
a dataframe with the gene dispersion for each samples
}
\description{
Get genes dispersion
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/countsGenerator.R
\name{getK_ij}
\alias{getK_ij}
\title{Get K_ij : gene counts}
\usage{
getK_ij(mu_ij.matrix, gene_disp.matrix)
}
\arguments{
\item{gene_disp.matrix}{a matrix of gene dispersion}
\item{log_qij.matrix}{a matrix of log_qij}
}
\value{
a dataframe with the gene dispersion for each samples
}
\description{
Get K_ij : gene counts
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/countsGenerator.R
\name{getLog_qij}
\alias{getLog_qij}
\title{Get log(q_ij)}
\usage{
getLog_qij(beta.matrix.input, model_matrix)
}
\arguments{
\item{model_matrix}{an output of stat::model.matrix()}
\item{beta.dtf}{a dtf of beta0,betaG, betaE, betaGE.}
}
\value{
a dataframe with the gene dispersion for each samples
}
\description{
Get log(q_ij)
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/countsGenerator.R
\name{getMu_ij}
\alias{getMu_ij}
\title{Get mu_ij}
\usage{
getMu_ij(log_qij.matrix, size_factor)
}
\arguments{
\item{beta.dtf}{a dtf of beta0,betaG, betaE, betaGE.}
\item{model_matrix}{an output of stat::model.matrix()}
}
\value{
a dataframe with the gene dispersion for each samples
}
\description{
Get mu_ij
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment