#' Node color visualization
#'
#' Visualizing a metric with node color. This functions works well for a comparison of two conditions e.g. log2(treatment/control).
#'
#' @param x experimental data as a dataframe, compounds in rows, samples in columns
#' @param y name of the metric to visualize
#'
#' @return Cytoscape network with node color representing the metric of interest
#' @export
#'
#' @examples
#' x <- data_to_plot
#' y <- 'log2(treatment/control)'
#' calcyt_binary(data_to_plot,'log2(treatment/control)')
calcyt_binary <- function (x,y)
{
#subset the metric of interest for visualization
sub_data <- x[y]
#range for plotting
ax_range <- max(abs(ceiling(min(sub_data))), abs(ceiling(max(sub_data))))
#function to visualize a metric with node color
setNodeColorMapping(
y,
table.column.values = c(-ax_range, 0, ax_range),
colors = c('#0000FF','#FFFFFF','#FF3333'), #blue-white-red color scale for negative-zero-positive values
mapping.type = "c",
default.color = NULL,
style.name = "default",
network = NULL)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.