|
1 | 1 | #' Add colouring to a set of cells. |
2 | 2 | #' |
| 3 | +#' The cells can be coloured by a grouping (clustering), according to a feature |
| 4 | +#' (gene expression), closest milestone, or pseudotime from the root of the trajectory. |
| 5 | +#' |
3 | 6 | #' @param cell_positions The positions of the cells, represented by a tibble. |
4 | 7 | #' Must contain column `cell_id` (character) and may contain columns `from`, |
5 | 8 | #' `to`, `pseudotime`, depending on the value of `color_cells`. |
6 | | -#' @param color_cells How to color the cells |
7 | | -#' @param trajectory The trajectory |
8 | | -#' @param grouping The grouping of the cells |
9 | | -#' @param groups Tibble containing information of the cell groups |
10 | | -#' @param feature_oi feature to plot expression |
11 | | -#' @param expression_source Source of the feature expression, defaults to `expression` |
12 | | -#' @param pseudotime The pseudotime |
13 | | -#' @param milestone_percentages The milestone percentages |
| 9 | +#' @param color_cells How to color the cells. |
| 10 | +#' * `"auto"`: Try to figure out how to color cells depending on whether |
| 11 | +#' one of the `grouping`, `feature_io`, `milestones` or `pseudotime` parameters are defined. |
| 12 | +#' * `"none"`: Cells are not coloured. |
| 13 | +#' * `"grouping"`: Cells are coloured according to a grouping (e.g. clustering). |
| 14 | +#' Either the `grouping` parameter or `trajectory$grouping` must be a named character vector. |
| 15 | +#' * `"feature"`: Cells are coloured according to the values of a given feature (e.g. gene expression). |
| 16 | +#' Either the `expression_source` parameter or `get_expression(trajectory)` must be a matrix. |
| 17 | +#' Parameter `feature_oi` must also be defined. |
| 18 | +#' * `"milestone"` (recommended): Cells are coloured according their position in the trajectory. The positioning of the |
| 19 | +#' cells are determined by parameter `milestone_percentages` or else by `trajectory$milestone_percentages`. The colours |
| 20 | +#' of the milestones can be determined automatically or can be specified by passing a tibble containing character columns |
| 21 | +#' `milestone_id` and `color` (See `add_milestone_coloring()` for help in constructing this object). |
| 22 | +#' * `"pseudotime"`: Cells are coloured according to the pseudotime value from the root. |
| 23 | +#' |
| 24 | +#' @param trajectory A dynwrap trajectory. |
| 25 | +#' @param grouping A grouping of the cells (e.g. clustering) as a named character vector. |
| 26 | +#' @param groups A tibble containing character columns `group_id` and `color`. If `NULL`, this object is inferred from the `grouping` itself. |
| 27 | +#' @param feature_oi The name of a feature to use for colouring the cells. |
| 28 | +#' @param expression_source Source of the feature expression, defaults to `get_expression(trajectory)`. |
| 29 | +#' @param pseudotime The pseudotime from the root of the trajectory to the cells as a named numeric vector. |
| 30 | +#' @param milestone_percentages The milestone percentages. |
| 31 | +#' |
| 32 | +#' @returns |
| 33 | +#' A named list with following objects: |
| 34 | +#' * cell_positions: The `trajectory$progressions` object with a `color` column added. |
| 35 | +#' * color_scale: A ggplot colour scale to add to the downstream ggplot. |
| 36 | +#' * fill_scale: A ggplot fill scale to add to the downstream ggplot. |
| 37 | +#' * color_cells: The input `color_cells` value, except `"auto"` will have been replaced depending |
| 38 | +#' on which other parameters were passed. |
| 39 | +#' |
| 40 | +# @examples |
| 41 | +# add_cell_coloring(example_bifurcating$progressions) |
14 | 42 | #' |
15 | 43 | #' @inheritParams add_milestone_coloring |
16 | 44 | #' |
|
0 commit comments