plotExprsVsTxLength {scater} | R Documentation

## Plot expression against transcript length

### Description

Plot expression values from an `SingleCellExperiment` object against transcript length values defined in the SingleCellExperiment object or supplied as an argument.

### Usage

    plotExprsVsTxLength(object, tx_length = "median_feat_eff_len",
      exprs_values = "logcounts", colour_by = NULL, shape_by = NULL,
      size_by = NULL, xlab = NULL, show_exprs_sd = FALSE,
      show_smooth = FALSE, alpha = 0.6, theme_size = 10,
      log2_values = FALSE, size = NULL, se = TRUE)

### Arguments

`object` | an `SingleCellExperiment` object
`tx_length` | transcript lengths to plot on the x-axis. Can be one of: (1) the name of a column of `rowData(object)` containing the transcript length values, or (2) the name of an element of `assays(object)` containing a matrix of transcript length values, or (3) a numeric vector of length equal to the number of rows of `object` (number of features).
`exprs_values` | character string indicating which values should be used as the expression values for this plot. Valid arguments are `"tpm"` (transcripts per million), `"norm_tpm"` (normalised TPM values), `"fpkm"` (FPKM values), `"norm_fpkm"` (normalised FPKM values), `"counts"` (counts for each feature), `"norm_counts"`, `"cpm"` (counts-per-million), `"norm_cpm"` (normalised counts-per-million), `"logcounts"` (log-transformed count data; default), `"norm_exprs"` (normalised expression values) or `"stand_exprs"` (standardised expression values) or any other slots that have been added to the `"assays"` slot by the user.
`colour_by` | optional character string supplying name of a column of `rowData(object)` which will be used as a variable by which to colour expression values on the plot. Alternatively, a data frame with one column, containing a value for each feature to map to a colour.
`shape_by` | optional character string supplying name of a column of `rowData(object)` which will be used as a variable to define the shape of points for expression values on the plot. Alternatively, a data frame with one column containing values to map to shapes.
`size_by` | optional character string supplying name of a column of `rowData(object)` which will be used as a variable to define the size of points for expression values on the plot. Alternatively, a data frame with one column containing values to map to sizes.
`xlab` | label for x-axis; if `NULL` (default), then `x` will be used as the x-axis label
`show_exprs_sd` | logical, show the standard deviation of expression values for each feature on the plot
`show_smooth` | logical, show a smoothed fit through the expression values on the plot
`alpha` | numeric value between 0 (completely transparent) and 1 (completely solid) defining how transparent plotted points (cells) should be. Points are jittered horizontally if the x-axis value is categorical rather than numeric to avoid overplotting.
`theme_size` | numeric scalar giving default font size for plotting theme (default is 10)
`log2_values` | should the expression values be transformed to the log2-scale for plotting (with an offset of 1 to avoid logging zeroes)?
`size` | numeric scalar optionally providing size for points if `size_by` argument is not given. Default is `NULL`, in which case ggplot2 default is used.
`se` | logical, should standard errors be shown (default `TRUE`) for the smoothed fit through the cells. (Ignored if `show_smooth` is `FALSE`).

### Value

a ggplot object

### Examples

    data("sc_example_counts")
    data("sc_example_cell_info")
    rd <- DataFrame(gene_id = rownames(sc_example_counts),
            feature_id = paste("feature", rep(1:500, each = 4), sep = "_"),
         median_tx_length = rnorm(2000, mean = 5000, sd = 500))
    rownames(rd) <- rownames(sc_example_counts)
    example_sce <- SingleCellExperiment(
    assays = list(counts = sc_example_counts),
    colData = sc_example_cell_info, rowData = rd)
    example_sce <- normalize(example_sce)

    plotExprsVsTxLength(example_sce, "median_tx_length")
    plotExprsVsTxLength(example_sce, "median_tx_length", show_smooth = TRUE)
    plotExprsVsTxLength(example_sce, "median_tx_length", show_smooth = TRUE,
    show_exprs_sd = TRUE)

    ## using matrix of tx length values in assays(object)
    mat <- matrix(rnorm(ncol(example_sce) * nrow(example_sce), mean = 5000,
     sd = 500), nrow = nrow(example_sce))
    dimnames(mat) <- dimnames(example_sce)
    assay(example_sce, "tx_len") <- mat

    plotExprsVsTxLength(example_sce, "tx_len", show_smooth = TRUE,
    show_exprs_sd = TRUE)

    ## using a vector of tx length values
    plotExprsVsTxLength(example_sce, rnorm(2000, mean = 5000, sd = 500))

[Package scater version 1.6.3 Index]