# OrgHeatmap
OrgHeatmap
is an R package for visualizing numerical
data (e.g., gene expression levels, physiological indicators) on human
organ diagrams. It supports custom color schemes, organ system
filtering, and quantitative bar charts to intuitively display data
distribution across anatomical structures.
Replace with your actual package file path:
install.packages("OrgHeatmap_0.1.0.tar.gz", repos = NULL, type = "source")
First install devtools if missing, then install from GitHub:
# Install devtools if not already installed
if (!require("devtools")) install.packages("devtools")
::install_github("QiruiShen439/OrgHeatmap") devtools
Install all dependent packages to ensure smooth operation:
install.packages(c("ggpolypath", "patchwork", "dplyr", "stringdist", "ggplot2"))
library(OrgHeatmap)
# Load built-in example dataset
<- system.file("extdata", "exampledata.Rdata", package = "OrgHeatmap")
file_path load(file_path)
# Inspect data structure (organ names and corresponding values)
head(example_Data3)
Create a basic organ visualization with default settings:
# Create basic organ visualization with default settings
<- OrgHeatmap(data = example_Data3)
result
# Display the generated plot
print(result$plot)
Visualize only organs from a specific system (e.g., circulatory system):
# Visualize only organs from the circulatory system
<- OrgHeatmap(
circulatory_plot data = example_Data3,
system = "circulatory",
title = "Circulatory System Data Visualization"
)
# Display the plot
print(circulatory_plot$plot)
Create visualization with accompanying bar chart for quantitative comparison:
<- OrgHeatmap(
bar_plot data = example_Data3,
organbar = TRUE,
organbar_title = "Value Distribution",
organbar_digit = 1,
title = "Organ Data Visualization with Bar Chart"
)
# Display the combined plot
print(bar_plot$plot)
The package provides two flexible ways to configure visualization colors—direct palette usage (for simplicity) and unified color schemes via define_organ_colors (for fine control).
Visualize respiratory system data with a pre-built palette, reversed color order, and custom middle color:
# Visualize respiratory system with "PuBuGn" palette
<- OrgHeatmap(
respiratory_palette_plot data = example_Data3,
system = "respiratory", # Target organ system
palette = "PuBuGn", # RColorBrewer palette (blue-purple-green)
reverse_palette = TRUE, # Reverse palette: low value = dark green, high value = purple
color_mid = "#87CEEB", # Custom middle color (sky blue) for 3-color gradient
organbar = TRUE, # Show bar chart
organbar_title = "Mean Value", # Bar chart legend title
organbar_digit = 2, # Keep 2 decimal places for bar values
showall = TRUE, # Show grey outlines of all organs (not just respiratory)
title = "Respiratory System (PuBuGn Palette)",
save_plot = TRUE, # Enable plot saving
plot_path = file.path(getwd(), "respiratory_palette_plot.png"), # Custom path for saving the plot
plot_width = 10, # Plot width (no need to repeat in ggsave)
plot_height = 8, # Plot height
plot_dpi = 300 # Plot resolution (function defaults to bg="white", no need to specify separately)
)
# Display the plot
print(respiratory_palette_plot$plot)
define_organ_colors
for Unified Color Schemes
(Advanced)For consistent colors across multiple plots (e.g., a series of figures for a paper), use define_organ_colors to generate a reusable color configuration first: #### Step 1: Generate a Custom Color Scheme
<- define_organ_colors(
respiratory_colors palette = "PuBuGn", # Base RColorBrewer palette
reverse = TRUE, # Reverse palette order
mid = "#87CEEB", # Custom middle color (sky blue)
fillcolor_other = "#E8F4F8", # Lighter fill for non-target organs (reduces distraction)
fillcolor_outline = "#F0E6D2", # Warmer body outline color (matches package default)
outline_color = "#333333" # Darker outline (better contrast for small organs)
)
<- OrgHeatmap(
custom_color_plot data = example_Data3,
system = "respiratory",
# Apply pre-defined colors from the configuration
color_low = respiratory_colors$fillcolor_low, # Low value color (from palette)
color_high = respiratory_colors$fillcolor_high, # High value color (from palette)
color_mid = respiratory_colors$fillcolor_mid, # Middle value color (custom)
fillcolor_other = respiratory_colors$fillcolor_other, # Non-target organ color
fillcolor_outline = respiratory_colors$fillcolor_outline, # Body outline color
# Plot styling
organbar = TRUE,
organbar_title = "Mean Value",
organbar_digit = 2,
showall = TRUE,
title = "Respiratory System (Custom Color Scheme)",
# Optional: Save plot and cleaned data
save_plot = TRUE,
plot_path = file.path(getwd(), "respiratory_custom_color_plot.png"),
save_clean_data = TRUE,
clean_data_path = file.path(getwd(), "respiratory_clean_data.rds")
)
# Display the plot
print(custom_color_plot$plot)
# Inspect the color configuration (for reuse in other plots)
str(respiratory_colors)
define_organ_colors
For comprehensive tutorials and parameter explanations:
# Access built-in vignettes
browseVignettes("OrgHeatmap")
# View function documentation
# Main visualization function ?OrgHeatmap
unique(organ_systems$organ)
for valid identifiersorgan_name_mapping
parameter to standardize non-standard
namesorganbar = TRUE
and valid data exists in
clean_data
Qirui Shen
Email: shenqr@i.smu.edu.cn