Reputation: 105
I am trying to create a circular heatmap in R using the ComplexHeatmap and circlize packages. My dataset is contained in a CSV file named "inter_tm_count.csv", which can be accessed via the Google Drive link provided below:
Google Drive link to the CSV dataset
Here's a summary of my dataset:
Here's my desired output:
Here's my current script:
library(ComplexHeatmap)
library(reshape2)
library(circlize)
# Read the data
inter_tm_count <- read.csv("path/to/inter_tm_count.csv")
# Split the data by the 'phyla' column
split_data <- split(inter_tm_count, inter_tm_count$phyla)
# Assign colors to characteristics
colors <- c("#ffffff", "#f7f9cb", "#c7edc0", "#92e0c3", "#56d0d0", "#00bdde",
"#00afef", "#539df4", "#9085e8", "#cd6ace", "#f54a9d", "#ff3d5e",
"#f0550d", "#fc8d59")
# Get unique characteristics
characteristics <- unique(inter_tm_count$characteristic)
# Create a named vector of colors
col_vector <- setNames(colors[1:length(characteristics)], characteristics)
# Convert data to matrix format
matrix_data <- acast(inter_tm_count, characteristic ~ tm, value.var = "number")
# Plot heatmap with named vector of colors and cell borders
circos.heatmap(matrix_data, split = split, col = col_vector)
circos.clear()
However, this script doesn't produce the desired plot. How can I modify it to address the challenges above and create the circular heatmap as described?
Any help or guidance would be greatly appreciated. Thank you!
Upvotes: 0
Views: 81