make_heatmap_bidir_lt_ggplot: Make a ggplot heatmap object from an input ligand-target...

View source: R/application_visualization.R

make_heatmap_bidir_lt_ggplotR Documentation

Make a ggplot heatmap object from an input ligand-target matrix.

Description

make_heatmap_bidir_lt_ggplot Make a ggplot heatmap object from an input ligand-target matrix in which it is indicated whether a gene is a top target of a ligand ("top-target"), the ligand is a top ligand of the gene ("top-ligand") or both ("top") or none ("none").

Usage

make_heatmap_bidir_lt_ggplot(matrix, y_name, x_name, y_axis = TRUE, x_axis = TRUE, x_axis_position = "top", legend_position = "top", ...)
#'

Arguments

matrix

Matrix with continuous values to plot in heatmap

y_name

Title of the y-axis

x_name

Title of the x-axis

y_axis

Should y-axis label names and titles be displayed? TRUE or FALSE. Default: TRUE.

x_axis

Should x-axis label names and titles be displayed? TRUE or FALSE. Default: TRUE.

x_axis_position

X-axis position: "top" or "bottomm"; only relevant if x_axis == TRUE. Default:"top".

legend_position

Legend position: "top", "bottom", "left", "right" or "none". Default: "top"

...

Optional arguments passed to element_text(); used to set font type and size of axis labels and titles.

Value

A ggplot object displaying a heatmap

Examples

## Not run: 
library(dplyr)
weighted_networks = construct_weighted_networks(lr_network, sig_network, gr_network,source_weights_df)
ligands = list("TNF","BMP2",c("IL4","IL13"))
ligand_target_matrix = construct_ligand_target_matrix(weighted_networks, ligands, ltf_cutoff = 0.99, algorithm = "PPR", damping_factor = 0.5,ligands_as_cols = TRUE)

ligand_target_matrix_vis_genedirection = ligand_target_matrix %>% apply(1,scaling_modified_zscore) %>% .[,1:50]
ligand_target_matrix_vis_genedirection[ligand_target_matrix_vis_genedirection < 2] = 0
ligand_target_matrix_vis_genedirection[ligand_target_matrix_vis_genedirection != 0] = 1

ligand_target_matrix_vis_liganddirection = ligand_target_matrix %>% apply(2,scaling_modified_zscore) %>% .[1:50, ] %>% t()
ligand_target_matrix_vis_liganddirection[ligand_target_matrix_vis_liganddirection < 2] = 0
ligand_target_matrix_vis_liganddirection[ligand_target_matrix_vis_liganddirection != 0] = 2

bidirectional_ligand_target_matrix_vis = ligand_target_matrix_vis_genedirection + ligand_target_matrix_vis_liganddirection
bidirectional_ligand_target_matrix_vis[bidirectional_ligand_target_matrix_vis == 0] = "none"
bidirectional_ligand_target_matrix_vis[bidirectional_ligand_target_matrix_vis == 1] = "top-ligand"
bidirectional_ligand_target_matrix_vis[bidirectional_ligand_target_matrix_vis == 2] = "top-target"
bidirectional_ligand_target_matrix_vis[bidirectional_ligand_target_matrix_vis == 3] = "top"
p = make_heatmap_bidir_lt_ggplot(bidirectional_ligand_target_matrix_vis, y_name = "ligand", x_name = "target")

## End(Not run)

saeyslab/nichenetr documentation built on March 26, 2024, 9:22 a.m.