#' print function for gland object
#'
#' @param x a gland object
#' @param ... Not currently used; values passed here will be
#' ignored.
#' @export
print.gland <- function(x, ...) {
cat("Cell gland object\n\n")
cat(paste0("Number of cell: ", nrow(x$cells), "\n"))
cat(paste0("Number of cell states: ", x$cell_length, "\n"))
unique_cells <- unique(x$cells)
unique_cells_n <- nrow(unique_cells)
cat(paste0("Number of unique mutations: ", unique_cells_n, "\n\n"))
if (unique_cells_n < 5) {
cat(paste0("The ", unique_cells_n, " unique cells are:\n\n"))
for (i in seq_len(unique_cells_n)) {
cat(paste0(i, ": ", paste(unique_cells[i, ], collapse = " ")), "\n")
}
} else {
cat(paste0("The first 5 unique cells are:\n"))
for (i in seq_len(5)) {
cat(paste0(i, ": ", paste(unique_cells[i, ], collapse = " ")), "\n")
}
}
}
#' plot function for gland object
#'
#' @param x a gland object
#' @param ... Not currently used; values passed here will be
#' ignored.
#'
#' @examples
#' plot(gland_create(sample(c(0, 1), 10, TRUE)))
#' @export
plot.gland <- function(x, ...) {
state_ticks <- seq(from = 0, to = 1, length.out = ncol(x$cells))
graphics::image(x$cells, col = c("grey30", "grey90"), xaxt = "n", yaxt = "n",
ylab = "state", xlab = "cells", main = "gland plot")
graphics::axis(side = 2, at = state_ticks, labels = seq_len(ncol(x$cells)))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.