Entering edit mode
19 months ago
hafiz.talhamalik
▴
350
have created a heatmap in R using heatmaply library which has 85 rows and 6 columns (samples). Is there ant possible way I could split my heatmap html file to indivdual sample heatmap ? I just want to view them separatly in an html file. I tried spliting the data using following code.
# Loop over each sample and create a separate plot for each one
for (sample in colnames(data)) {
# Subset the data to only include the current sample
sample_data <- data[, sample, drop = FALSE]
# Create the plot and save as an HTML file
p <- heatmaply(sample_data, dendrogram = "both", scale = "row",
colorscale = "Viridis", margins = c(80, 80),
main = paste0("Heatmap for ", sample))
html_file <- paste0(sample, ".html")
saveWidget(as.widget(p), file = html_file, selfcontained = TRUE)
}
but gives the error for hclust function. is there a wayout ?
I want to split my html file into multiple html file containing only the information of single sample each.
I don't use this package, but hclust probably fails because you are only inputting one sample, so nothing can be clustered. Try setting the parameter
dendrogram = "none"
to disable clustering and see if it works.tried that too. looks like hclust function is mandatory in heatmap
Really? try this code, this works for me:
let me check what I am doing wrong..!!
Are you getting a different type of error? for example, if you set
dendrogram = "none"
I think you should remove thescale = "row"
command.