Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: dlptools
Title: DLPTools: Handling DLP+ Data
Version: 1.1.0
Version: 1.1.1
Authors@R: c(
person("Ben", "Furman", email = "bfurman@bccrc.ca", role = c("aut", "cre")),
person("Aparicio Lab Past and Present", role = "aut")
Expand Down
24 changes: 21 additions & 3 deletions R/heatmap_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ generate_state_hm <- function(
#'
#' @param total_hm ComplexHeatmap::Heatmap of the combined tree and states.
#' @param file_name optional string of where to save a png image of the heatmap.
#' @param png_height optional height of png file
#' @return ComplexHeatmap::draw or nothing if a file is written.
#' @export
output_hm_image <- function(
Expand Down Expand Up @@ -389,7 +390,6 @@ build_left_annot <- function(
col = anno_cols_list
)
}

return(left_annot)
}

Expand Down Expand Up @@ -514,15 +514,20 @@ make_clone_palette <- function(clone_ids) {
#' in the heatmap. Will default to the name of the column being plotted.
#' @param legend_11plus bool. Default FALSE. For HMMCopy state values,
#' state 11 is really 11+, so we replace 11s with 11+ for the plot in the
#' legend.
#' #' legend.
#' @param scale_y bool. Default FALSE. Scale the y size of the saved image accoring
#' to the number of cells in the heatmap
#' @param cell_height, int. Default = 10 Heigh in pixels per cell if scale_y is True
#' @param default_png_height, int: Default = 1600. If scale_y not used, height
#' of final png
#' @export
plot_state_hm <- function(
states_df,
state_col,
phylogeny = NULL,
file_name = NULL,
anno_df = NULL, # optional, can also specify columns in the dataframe
anno_colors_list = list(), # for custom colors of annotations
anno_colors_list = list(), # for custom colors of annotations. Can also specify custom breaks in the cmap
anno_columns = NULL,
clone_column = NULL,
clones_df = NULL, # optional, can also specify columns in the dataframe
Expand All @@ -537,6 +542,9 @@ plot_state_hm <- function(
hm_legend_title = NULL,
legend_11plus = FALSE,
color_tree_clones = FALSE,
scale_y = FALSE,
cell_height = 10,
default_png_height = 1600,
...) {
check_args()

Expand Down Expand Up @@ -634,9 +642,19 @@ plot_state_hm <- function(
legend_11plus = legend_11plus
)

# If scale_y is true, scale image height to number of cells
if (scale_y) {
message("Scaling Image Size by number of cells")
ncells <- length(unique(states_df$cell_id))
png_height <- 200 + ncells*cell_height
} else {
png_height <- default_png_height
}

output_hm_image(
hm_p,
file_name = file_name,
png_height = png_height,
...
)
}
Loading