Learn R Programming

CountClust (version 1.0.2)

StructureGGplot: Struture plot with ggplot2 package

Description

Make the traditional Structure histogram plot of GoM model using ggplot2

Usage

StructureGGplot(omega, annotation, palette = RColorBrewer::brewer.pal(8, "Accent"), figure_title = "", yaxis_label = "Tissue type", order_sample = TRUE, sample_order_decreasing = TRUE, split_line = list(split_lwd = 1, split_col = "white"), 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"))

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
A data.frame of two columns: sample_id and tissue_label. sample_id is the unique identifying number of each sample (alphanumeric). tissue_lable is a factor of tissue labels, with levels of the factor arranged in the order of the tissues in the Structure (left to right).
palette
A vector of colors assigned to the clusters. First color in the vector is assigned to the cluster labeled as 1, and second color in the vector is assigned to the cluster labeled as 2, etc. The number of colors must be the same or greater than the number of clusters. The clusters not assigned a color are filled with white in the figure. In addition, the recommended choice of color palette here 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 samples.
order_sample
if TRUE, we order samples in each annotation batch sorted by membership of most representative cluster. If FALSE, we keep the order in the data.
sample_order_decreasing
if order_sample TRUE, then this input determines if the ordering due to main cluster is in ascending or descending order.
split_line
Control parameters for line splitting the batches in the plot.
axis_tick
Control parameters for x-axis and y-axis tick sizes.

Value

Plots the Structure plot visualization of the GoM model

Examples

Run this code
data("MouseDeng2014.FitGoM")

# extract the omega matrix: membership weights of each cell
names(MouseDeng2014.FitGoM$clust_6)
omega <- MouseDeng2014.FitGoM$clust_6$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") ) ) )
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"))

Run the code above in your browser using DataLab