Convert numeric ternary outcomes into a factor
Arguments
- x
a numeric vector of -1, 0, and +1 values, indicating down-regulation, uncertain response or up-regulation, or a numeric vector that can be converted into such values using a pair of thresholds.
- n.levels
numeric Number of levels to create, either 3 or 2.
- threshold
numeric vector Range enclosing the values to be considered uncertain.
Details
These functions convert the numerically encoded values into a factor
with the three levels "down", "uncertain" and "up", or
into a factor with two levels de and uncertain as expected by
default by scales scale_colour_outcome,
scale_fill_outcome and scale_shape_outcome.
When n.levels = 2 both -1 and +1 are merged to the same level of the
factor with label "de".
Note
These are convenience functions that only save some typing. The same
result can be achieved by a direct call to factor and
comparisons. These functions aim at making it easier to draw volcano and
quadrant plots.
See also
Other Functions for quadrant and volcano plots:
FC_format(),
scale_colour_outcome(),
scale_shape_outcome(),
scale_y_Pvalue(),
xy_outcomes2factor()
Other scales for omics data:
scale_colour_logFC(),
scale_shape_outcome(),
scale_x_logFC(),
xy_outcomes2factor()
Examples
outcome2factor(c(-1, 1, 0, 1))
#> [1] down up uncertain up
#> Levels: up uncertain down
outcome2factor(c(-1, 1, 0, 1), n.levels = 2L)
#> [1] de de uncertain de
#> Levels: de uncertain
threshold2factor(c(-0.1, -2, 0, +5))
#> [1] down down uncertain up
#> Levels: up uncertain down
threshold2factor(c(-0.1, -2, 0, +5), n.levels = 2L)
#> [1] de de uncertain de
#> Levels: de uncertain
threshold2factor(c(-0.1, -2, 0, +5), threshold = c(-1, 1))
#> [1] uncertain down uncertain up
#> Levels: up uncertain down
