StructureGGplot {CountClust} | R Documentation

## Struture plot using ggplot2

### Description

Make the traditional Structure plot of GoM model with ggplot2

### Usage

    StructureGGplot(omega, annotation = NULL,
      palette = RColorBrewer::brewer.pal(8, "Accent"), figure_title = "",
      yaxis_label = "Tissue type", order_sample = TRUE,
      sample_order_decreasing = TRUE, sample_order_opts = 1,
      split_line = list(split_lwd = 1, split_col = "white"), plot_labels = TRUE,
      axis_tick = list(axis_ticks_length = 0.1, axis_ticks_lwd_y = 0.1,
      axis_ticks_lwd_x = 0.1, axis_label_size = 3, axis_label_face = "bold"),
      legend_title_size = 8, legend_key_size = 0.4, legend_text_size = 5)

### Arguments

`omega` | Cluster membership probabilities of each sample. Usually a sample by cluster matrix in the Topic model output. The cluster weights sum to 1 for each sample.
`annotation` | data.frame of two columns: sample_id and tissue_label. sample_id is a vetor consisting of character type of variable, which indicates the unique identifying number of each sample. tissue_label is a vector consisting of factor type of variable, which indicates the sample phenotype that is to be used in sorting and grouping the samples in the Structre plot; for example, tissue of origin in making Structure plot of the GTEx samples. Default is set to "none for when no phenotype information is used to order the sample vectors.
`palette` | Colors assigned to label the clusters. The first color in the palette is assigned to the cluster that is labeled 1 (usually arbitrarily assigned during the clustering process). Note: The number of colors must be the same or greater than the number of clusters. When the number of clusters is greater than the number of colors, the clusters that are not assigned a color are filled with white in the figure. The recommended choice of color palette is RColorBrewer, for instance RColorBrewer::brewer.pal(8, "Accent") or RColorBrewwer::brewer.pal(9, "Set1").
`figure_title` | Title of the plot.
`yaxis_label` | Axis label for the phenotype used to order the samples, for example, tissue type or cell type.
`order_sample` | Whether to order the samples that are of the same tissue label or phenotype lable, that is, having the same label in the tissue_label variable. If TRUE, we order samples that are of the same phenotype label and sort the samples by membership of most representative cluster. If FALSE, we keep the order in the data.
`sample_order_decreasing` | If order_sample=TRUE, then order the sample in descending (TRUE) or ascending order.
`sample_order_opts` | Orders by different choices of clusters in a batch. Can take the values 1, 2, 3 or 4 corresponding to 4 ordering options. Default equal to 1.
`split_line` | Control parameters for the line that separates phenotype subgroups in the plot.
`plot_labels` | If TRUE, the plot the axis labels.
`axis_tick` | Control parameters for x-axis and y-axis tick sizes.
`legend_title_size` | The size of the title of the Structure Plot representation.
`legend_key_size` | The size of the legend key in Structure plot.
`legend_text_size` | the size specification of the legend text.

### Value

Plots the Structure plot visualization of the GoM model

### Examples

    data("MouseDeng2014.FitGoM")

    # extract the omega matrix: membership weights of each cell
    names(MouseDeng2014.FitGoM$clust_6)
    omega <- MouseDeng2014.FitGoM$clust_6$omega
    tissue_label <- rownames(omega)

    # make annotation matrix
    annotation <- data.frame(
      sample_id = paste0("X", c(1:NROW(omega))),
      tissue_label = factor(rownames(omega),
                         levels = rev( c("zy", "early2cell",
                                         "mid2cell", "late2cell",
                                         "4cell", "8cell", "16cell",
                                         "earlyblast","midblast",
                                         "lateblast") ) ) )
    head(annotation)

    # setw rownames of omega to be sample ID
    rownames(omega) <- annotation$sample_id

    StructureGGplot(omega = omega,
                     annotation = annotation,
                     palette = RColorBrewer::brewer.pal(8, "Accent"),
                     yaxis_label = "development phase",
                     order_sample = TRUE,
                     axis_tick = list(axis_ticks_length = .1,
                                      axis_ticks_lwd_y = .1,
                                      axis_ticks_lwd_x = .1,
                                      axis_label_size = 7,
                                      axis_label_face = "bold"))

[Package CountClust version 1.10.1 Index]