Convert contrast names to sedesign object
Source:R/jam_contrastnames2design.R
contrast_names_to_sedesign.Rd
Convert contrast names to sedesign object
Arguments
- contrast_names
character
vector of contrast names where factors are separated byfactor_sep
and contrasts are separated bycontrast_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.
See also
Other jam experiment design:
check_sedesign()
,
contrast2comp()
,
contrast_colors_by_group()
,
contrasts_to_factors()
,
contrasts_to_venn_setlists()
,
draw_oneway_contrast()
,
draw_twoway_contrast()
,
filter_contrast_names()
,
groups_to_sedesign()
,
plot_sedesign()
,
sedesign_to_factors()
,
validate_sedesign()
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"
#>