Skip to contents

Convert contrast names to sedesign object

Usage

contrast_names_to_sedesign(
  contrast_names,
  factor_sep = "_",
  contrast_sep = "-",
  ...
)

Arguments

contrast_names

character vector of contrast names where factors are separated by factor_sep and contrasts are separated by contrast_sep.

factor_sep, contrast_sep

character strings used as delimiters between factors and contrasts, respectively.

...

additional arguments are ignored.

Value

sedesign object, or if the input contrast_names contain mixed number of factors per contrast, the output is split into a list of sedesign objects based upon the number of factors.

Details

This function is a convenience function intended only to convert a vector of contrast names into sedesign format for use in other functions. It assumes only one sample replicate per group for this purpose.

One utility of this function is to convert two-way contrast names into a contrast matrix, to test whether the contrast defined is equivalent for the two names.

Examples

contrast_names_3fac <- c(
   "(CellA_Treated-CellA_Control)-(CellB_Treated-CellB_Control)",
   "(CellA_Treated-CellB_Treated)-(CellA_Control-CellB_Control)")
contrast_names_to_sedesign(contrast_names_3fac)
#> An object of class "SEDesign"
#> Slot "design":
#>               CellA_Treated CellA_Control CellB_Treated CellB_Control
#> CellA_Treated             1             0             0             0
#> CellA_Control             0             1             0             0
#> CellB_Treated             0             0             1             0
#> CellB_Control             0             0             0             1
#> 
#> Slot "contrasts":
#>                Contrasts
#> Levels          (CellA_Treated-CellA_Control)-(CellB_Treated-CellB_Control)
#>   CellA_Treated                                                           1
#>   CellA_Control                                                          -1
#>   CellB_Treated                                                          -1
#>   CellB_Control                                                           1
#>                Contrasts
#> Levels          (CellA_Treated-CellB_Treated)-(CellA_Control-CellB_Control)
#>   CellA_Treated                                                           1
#>   CellA_Control                                                          -1
#>   CellB_Treated                                                          -1
#>   CellB_Control                                                           1
#> 
#> Slot "samples":
#> [1] "CellA_Treated" "CellA_Control" "CellB_Treated" "CellB_Control"
#> 

contrast_names_3way <- c(
   paste0("((CellA_Treated_Mut-CellB_Treated_Mut)-",
      "(CellA_Control_Mut-CellB_Control_Mut))-",
      "((CellA_Treated_WT-CellB_Treated_WT)-",
      "(CellA_Control_WT-CellB_Control_WT))"),
   paste0("((CellA_Treated_Mut-CellA_Control_Mut)-",
      "(CellB_Treated_Mut-CellB_Control_Mut))-",
      "((CellA_Treated_WT-CellA_Control_WT)-",
      "(CellB_Treated_WT-CellB_Control_WT))"))
contrast_names_to_sedesign(contrast_names_3way)
#> An object of class "SEDesign"
#> Slot "design":
#>                   CellA_Treated_Mut CellA_Treated_WT CellA_Control_Mut
#> CellA_Treated_Mut                 1                0                 0
#> CellB_Treated_Mut                 0                0                 0
#> CellA_Control_Mut                 0                0                 1
#> CellB_Control_Mut                 0                0                 0
#> CellA_Treated_WT                  0                1                 0
#> CellB_Treated_WT                  0                0                 0
#> CellA_Control_WT                  0                0                 0
#> CellB_Control_WT                  0                0                 0
#>                   CellA_Control_WT CellB_Treated_Mut CellB_Treated_WT
#> CellA_Treated_Mut                0                 0                0
#> CellB_Treated_Mut                0                 1                0
#> CellA_Control_Mut                0                 0                0
#> CellB_Control_Mut                0                 0                0
#> CellA_Treated_WT                 0                 0                0
#> CellB_Treated_WT                 0                 0                1
#> CellA_Control_WT                 1                 0                0
#> CellB_Control_WT                 0                 0                0
#>                   CellB_Control_Mut CellB_Control_WT
#> CellA_Treated_Mut                 0                0
#> CellB_Treated_Mut                 0                0
#> CellA_Control_Mut                 0                0
#> CellB_Control_Mut                 1                0
#> CellA_Treated_WT                  0                0
#> CellB_Treated_WT                  0                0
#> CellA_Control_WT                  0                0
#> CellB_Control_WT                  0                1
#> 
#> Slot "contrasts":
#>                    Contrasts
#> Levels              ((CellA_Treated_Mut-CellB_Treated_Mut)-(CellA_Control_Mut-CellB_Control_Mut))-((CellA_Treated_WT-CellB_Treated_WT)-(CellA_Control_WT-CellB_Control_WT))
#>   CellA_Treated_Mut                                                                                                                                                       1
#>   CellA_Treated_WT                                                                                                                                                       -1
#>   CellA_Control_Mut                                                                                                                                                      -1
#>   CellA_Control_WT                                                                                                                                                        1
#>   CellB_Treated_Mut                                                                                                                                                      -1
#>   CellB_Treated_WT                                                                                                                                                        1
#>   CellB_Control_Mut                                                                                                                                                       1
#>   CellB_Control_WT                                                                                                                                                       -1
#>                    Contrasts
#> Levels              ((CellA_Treated_Mut-CellA_Control_Mut)-(CellB_Treated_Mut-CellB_Control_Mut))-((CellA_Treated_WT-CellA_Control_WT)-(CellB_Treated_WT-CellB_Control_WT))
#>   CellA_Treated_Mut                                                                                                                                                       1
#>   CellA_Treated_WT                                                                                                                                                       -1
#>   CellA_Control_Mut                                                                                                                                                      -1
#>   CellA_Control_WT                                                                                                                                                        1
#>   CellB_Treated_Mut                                                                                                                                                      -1
#>   CellB_Treated_WT                                                                                                                                                        1
#>   CellB_Control_Mut                                                                                                                                                       1
#>   CellB_Control_WT                                                                                                                                                       -1
#> 
#> Slot "samples":
#> [1] "CellA_Treated_Mut" "CellB_Treated_Mut" "CellA_Control_Mut"
#> [4] "CellB_Control_Mut" "CellA_Treated_WT"  "CellB_Treated_WT" 
#> [7] "CellA_Control_WT"  "CellB_Control_WT" 
#>