Skip to contents

The init_variable() function is used for defining the variables in your experimental design. Sizes of effects (sd) for each variable and interaction term can be defined. It is crucial to highlight that the choice of these parameters plays a critical role in the simulation process. For optimal results, we recommend basing these decisions on real data, as outlined in the Simulation tutorial

Init a single variable

Alternatively, you can randomly initialize varA by specifying a standard deviation (sd).

list_var <- init_variable( name = "varA",  sd = 0.2, level = 5) 

Init several variables

You can also initialize multiple variables, such as varA and varB, with random values. This flexibility allows you to create diverse experimental designs.

list_var <- init_variable( name = "varA", sd = 0.2, level = 5) %>%
            init_variable( name = "varB", sd = 0.34, level = 2)

Add interaction between variable

Similarly to init_variable(), add_interaction() allows to define an interaction between variable. In this example, we initialize varA and varB, and create an interaction between varA, and varB using add_interaction().

list_var <- init_variable( name = "varA", sd = 0.2, level = 2) %>%
            init_variable( name = "varB", sd = 0.43, level = 2) %>%
            add_interaction( between_var = c("varA", "varB"), sd = 0.2)

Complex design

Interactions can involve a maximum of three variables, such as varA, varB, and varC.

list_var <- init_variable( name = "varA", sd = 0.2, level = 2) %>%
            init_variable( name = "varB", sd = 0.78, level = 2) %>%
            init_variable( name = "varC", sd = 0.1, level = 2) %>%
            add_interaction( between_var = c("varA", "varC"), sd = 0.2) %>%
            add_interaction( between_var = c("varA", "varB"), sd = 0.37) %>%
            add_interaction( between_var = c("varB", "varC"), sd = 0.12) %>%
            add_interaction( between_var = c("varA", "varB" ,"varC"), sd = 0.18)

Structure of list_var object

The list_var object collected all the information needed to generate a mock_rnaseq object.

str(list_var)
#> List of 3
#>  $ varA        :'data.frame':    1 obs. of  3 variables:
#>   ..$ mu   : num 0
#>   ..$ sd   : num 0.2
#>   ..$ level: num 2
#>  $ varB        :'data.frame':    1 obs. of  3 variables:
#>   ..$ mu   : num 0
#>   ..$ sd   : num 0.43
#>   ..$ level: num 2
#>  $ interactions:List of 1
#>   ..$ varA:varB:'data.frame':    1 obs. of  3 variables:
#>   .. ..$ mu   : num 0
#>   .. ..$ sd   : num 0.2
#>   .. ..$ level: num 4