R: Plot the expression values of two genes

plot_pair {dnapath} | R Documentation

## Plot the expression values of two genes

### Description

Inspired by the `plotCors` function from the DGCA package, this function is used to plot the expression values of two genes contained in the differential network analysis results. This is useful for comparing the marginal relationship between two genes. Note, however, that this visualization is not able to show conditional associations.

### Usage

    plot_pair(
      x,
      gene_A,
      gene_B,
      method = "loess",
      alpha = 0.5,
      se_alpha = 0.1,
      use_facet = FALSE,
      scales = "fixed"
    )

### Arguments

`x` | A 'dnapath' or 'dnapath_list' object from `dnapath`.
`gene_A` | The name of the first gene to plot. Must be one of the names in `get_genes`(x).
`gene_B` | The name of the second gene to plot. Must be one of the names in `get_genes`(x).
`method` | A charater string, either "lm" or "loess" (the default) used by `geom_smooth` to summarize the marginal gene-gene association. For no line, set method = NULL.
`alpha` | Sets the transparancy of the points, used to set alpha in `geom_point`.
`se_alpha` | Sets the transparancy of the confidence band around the association trend line. Set to 0 to remove the band.
`use_facet` | If TRUE, the groups are plotted in separate graphs using the `link[ggplot2]{facet_wrap}` method.
`scales` | Only used if do_facet_wrap is TRUE. See `link[ggplot2]{facet_wrap}` for details.

### Value

Plots the differential network and returns the ggplot object. Additional modifications can be applied to this object just like any other ggplot.

### References

Grimes T, Datta S (2019). SeqNet: Generate RNA-Seq Data from Gene-Gene Association Networks. R package version 1.1.0, https://CRAN.R-project.org/package=SeqNet.

### Examples

    data(meso)
    data(p53_pathways)
    set.seed(0)
    results <- dnapath(x = meso$gene_expression, pathway_list = p53_pathways,
                       group_labels = meso$groups, n_perm = 10)
    # Plot of the marginal association between the first two genes.
    genes <- get_genes(results)[1:2]
    g <- plot_pair(results, genes[1], genes[2])
    # The ggplot object, g, can be further modified.
    # Here we move the legend and use a log scale for the expression values
    # (the log scale doesn't help with these data but is shown for demonstration).
    g <- g +
      ggplot2::theme(legend.position = "bottom") +
      ggplot2::scale_x_log10() +
      ggplot2::scale_y_log10()
    g

[Package dnapath version 0.7.4 Index]