Title: | Generate Cofeature Matrices |
---|---|
Description: | Generate cofeature (feature by sample) matrices. The package utilizes ggplot2::geom_tile() to generate the matrix allowing for easy additions from the base matrix. |
Authors: | Fong Chun Chan [aut, cre] |
Maintainer: | Fong Chun Chan <[email protected]> |
License: | GPL-3 |
Version: | 1.1.1 |
Built: | 2025-03-09 02:55:34 UTC |
Source: | https://github.com/tinyheero/cofeaturer |
Add tiles to the ggplot2
add_tiles(p1, in.df, tile.col, missing.fill.col, tile.border.size)
add_tiles(p1, in.df, tile.col, missing.fill.col, tile.border.size)
p1 |
Existing ggplot2 |
in.df |
A 3 column (feature, sampleID, type) data.frame object |
tile.col |
Border color of each cell. If not set, no border color is used. |
missing.fill.col |
Color of the cell that has missing values |
tile.border.size |
Integer to indicate the size of the tile borders. |
Generate cofeature (feature by sample) matrices. The package utilizes ggplot2::geom_tile to generate the matrix allowing for easy customization of additions from the base matrix.
Generates a ggplot2::geom_tile plot of features by sample. It is able to deal with multiple types affecting the same sample.
plot_cofeature_mat(in.df, feature.order, sample.id.order, fill.colors, type.display.mode = c("multiple", "single"), type.order, tile.col = NA, rotate.x.labels, missing.fill.col, dot.flag = FALSE, dot.size, tile.flag = TRUE, drop.x = FALSE, tile.border.size = 1)
plot_cofeature_mat(in.df, feature.order, sample.id.order, fill.colors, type.display.mode = c("multiple", "single"), type.order, tile.col = NA, rotate.x.labels, missing.fill.col, dot.flag = FALSE, dot.size, tile.flag = TRUE, drop.x = FALSE, tile.border.size = 1)
in.df |
A 3 column (feature, sampleID, type) data.frame object |
feature.order |
character vector indicating the order of the features in the final plot on the y-axis. If not set, then function will set it automatically |
sample.id.order |
character vector indicating the order of the samples in the final plot on the x-axis. If not set, then function will set it automatically |
fill.colors |
character vector indicating the colors of the different "types". The names should be the types with the value being the color |
type.display.mode |
Specify whether multiple or a single feature type can appear in the same feature/sample cell |
type.order |
Specify the "priority" of the feature types. This only has an effect when type.display.mode is set to single. |
tile.col |
Border color of each cell. If not set, no border color is used. |
rotate.x.labels |
Rotate the x-axes labels by a certain degree |
missing.fill.col |
Color of the cell that has missing values |
dot.flag |
Boolean to turn on/off dots (dot.flag) |
dot.size |
Column name indicating the size of the dots. Only takes effect if dot.flag is TRUE. |
tile.flag |
Boolean to turn on/off tiles (tile.flag) |
drop.x |
Boolean to drop levels (from a factor) in the x dimension. |
tile.border.size |
Integer to indicate the size of the tile borders. |
## Not run: v1 <- c("RCOR1", "NCOR1", "LCOR", "RCOR1", "RCOR1", "RCOR1", "RCOR1") v2 <- c("sampleA", "sampleC", "sampleB", "sampleC", "sampleA", "sampleC", "sampleC") v3 <- c("Deletion", "Deletion", "SNV", "Rearrangement", "SNV", "Rearrangement", "SNV") v4 <- c(0.05, 0.5, 0.25, 0.01, 0.03, 0.24, 0.89) v5 <- c(1, 2, 1, 1, 2, 2, 1) feature.order <- c("RCOR1", "NCOR1", "LCOR") sample.id.order <- c("sampleA", "sampleB", "sampleC") in.df <- dplyr::data_frame(feature = v1, sampleID = v2, type = v3, p_value = -log10(v4), dir_flag = v5) fill.colors <- c("Deletion" = "Blue", "Rearrangement" = "Green", "SNV" = "Red") plot_cofeature_mat(in.df) # With black tile color plot_cofeature_mat(in.df, tile.col = "black") # Fill in missing values with a lightgrey color plot_cofeature_mat(in.df, tile.col = "black", missing.fill.col = "lightgrey") # Rotate x-axes labels by 90 degrees plot_cofeature_mat(in.df, rotate.x.labels = 90) # Specify order of features, samples, and colors plot_cofeature_mat(in.df, feature.order, sample.id.order, fill.colors = fill.colors) # Specify each cell can only have one "feature type" plot_cofeature_mat(in.df, feature.order, sample.id.order, fill.colors = fill.colors, type.display.mode = "single") # Specify the specific priority of the "feature type" for cells with # multiple features plot_cofeature_mat(in.df, feature.order, sample.id.order, fill.colors = fill.colors, type.display.mode = "single", type.order = c("Rearrangement", "SNV", "Deletion")) # Add dots to tiles for an additional layer of information plot_cofeature_mat(in.df, dot.size = "p_value") # Only display dots plot_cofeature_mat(in.df, dot.flag = TRUE, dot.size = "p_value", tile.flag = FALSE) # Samples will not be dropped sample.id.order.new <- c("sampleA", "sampleB", "sampleC", "sampleD") plot_cofeature_mat(in.df, tile.col = "black", sample.id.order = sample.id.order.new) # Samples can be dropped by setting drop.x = TRUE plot_cofeature_mat(in.df, tile.col = "black", sample.id.order = sample.id.order.new, drop.x = TRUE) ## End(Not run)
## Not run: v1 <- c("RCOR1", "NCOR1", "LCOR", "RCOR1", "RCOR1", "RCOR1", "RCOR1") v2 <- c("sampleA", "sampleC", "sampleB", "sampleC", "sampleA", "sampleC", "sampleC") v3 <- c("Deletion", "Deletion", "SNV", "Rearrangement", "SNV", "Rearrangement", "SNV") v4 <- c(0.05, 0.5, 0.25, 0.01, 0.03, 0.24, 0.89) v5 <- c(1, 2, 1, 1, 2, 2, 1) feature.order <- c("RCOR1", "NCOR1", "LCOR") sample.id.order <- c("sampleA", "sampleB", "sampleC") in.df <- dplyr::data_frame(feature = v1, sampleID = v2, type = v3, p_value = -log10(v4), dir_flag = v5) fill.colors <- c("Deletion" = "Blue", "Rearrangement" = "Green", "SNV" = "Red") plot_cofeature_mat(in.df) # With black tile color plot_cofeature_mat(in.df, tile.col = "black") # Fill in missing values with a lightgrey color plot_cofeature_mat(in.df, tile.col = "black", missing.fill.col = "lightgrey") # Rotate x-axes labels by 90 degrees plot_cofeature_mat(in.df, rotate.x.labels = 90) # Specify order of features, samples, and colors plot_cofeature_mat(in.df, feature.order, sample.id.order, fill.colors = fill.colors) # Specify each cell can only have one "feature type" plot_cofeature_mat(in.df, feature.order, sample.id.order, fill.colors = fill.colors, type.display.mode = "single") # Specify the specific priority of the "feature type" for cells with # multiple features plot_cofeature_mat(in.df, feature.order, sample.id.order, fill.colors = fill.colors, type.display.mode = "single", type.order = c("Rearrangement", "SNV", "Deletion")) # Add dots to tiles for an additional layer of information plot_cofeature_mat(in.df, dot.size = "p_value") # Only display dots plot_cofeature_mat(in.df, dot.flag = TRUE, dot.size = "p_value", tile.flag = FALSE) # Samples will not be dropped sample.id.order.new <- c("sampleA", "sampleB", "sampleC", "sampleD") plot_cofeature_mat(in.df, tile.col = "black", sample.id.order = sample.id.order.new) # Samples can be dropped by setting drop.x = TRUE plot_cofeature_mat(in.df, tile.col = "black", sample.id.order = sample.id.order.new, drop.x = TRUE) ## End(Not run)