R/visualize.R

Defines functions show_heatmap show_gene_track show_tree

Documented in show_gene_track show_heatmap show_tree

#' Display tree {VALIDATED}
#'
#' Displays constructed tree and saves it at the given filename.
#'
#' @param filename filename to which the plot will be saved
#' @param tree ape::phylo tree
#' @param title title name
#' @param edge_labels optional labels for each branch
#' @return None
#' @examples
#' show_tree('tree.pdf', tree, 'Hematopoietic Tree')
#' ... some visualization 
#' @export
show_tree <- function(filename, tree, title, edge_labels) {
	pdf(filename)
	plot(tree)
	title(title)
	if(!missing(edge_labels)) {
		edgelabels(edge_labels)
	}
	nodelabels()
	dev.off()
}

#' Track the single probe resolution change of a gene
#'
#' Displays constructed tree with node labels for the proportion of each probe 
#' state for a selected gene. This is saved at the given filename
#'
#' @param filename filename to which the plot will be saved
#' @param tree ape::phylo tree
#' @param gene gene name
#' @param thermo_prop_node thermo proportion plot for internal nodes of all of 
#' the probe states
#' @param thermo_prop_leaves thermo proportion plot for leaves of all of
#' the probe states
#' @return None
#' @examples
#' show_gene_track('tree_CD81', tree, 'CD81', thermo_prop_internal_nodes, 
#' thermo_prop_leaves)
#' ... some visualization 
#' @export
show_gene_track <- function(filename, tree, gene, thermo_prop_internal_nodes, thermo_prop_leaves) {
	pdf(filename)
	plot(tree)
	title(paste("Summary plot for gene: ", gene, sep=""))
	nodelabels(thermo = thermo_prop_internal_nodes, piecol=topo.colors(3))
	tiplabels(adj = c(0.59,0.5), thermo = thermo_prop_leaves, piecol=topo.colors(3))
	legend("topleft", inset=.02, title="Methylation Status", c("Methylated", "Unmethylated", "Ambiguous"), fill=topo.colors(3), horiz=TRUE, cex=0.8)
	dev.off()
}

#' Relabel node in probe-node matrix
#'
#' Relabel node label n_old with node label n_new in probe-node matrix.
#'
#' @param probe_node_matrix matrix storing the methylation status across all
#' probes and nodes on a tree
#' @param n_old node number
#' @param n_new node number
#' @return relabeled probe_node_matrix with node label n_old with node label
#' n_new
#' @examples
#' probe_node_matrix <- relabel_node_matrix(probe_node_matrix, 7, 10)
#' ... some visualization 
#' @export
show_heatmap <- function() {

}
ethanmoyer/MethylConstruct documentation built on July 10, 2020, 12:28 a.m.