Skip to content

Commit d0afff5

Browse files
committed
Shorten heatmap columns
Keeps the first annotation with an ellipsis for those with more than one annotation, to help visualization
1 parent 316bbc2 commit d0afff5

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

template.qmd

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ table <- read.csv(params$table)
8484
n.samples <- table %>% pull(Sample) %>% unique() %>% length()
8585
8686
# Heatmap
87-
vcf <- read_csv(params$heat_tab)
88-
row.names(vcf) <- vcf$`...1`
89-
vcf <- vcf[-1]
90-
cor.mat <- cor(vcf, method = params$cor_method)
87+
heatmap.df <- read_csv(params$heat_tab)
88+
row.names(heatmap.df) <- heatmap.df$`...1`
89+
heatmap.df <- heatmap.df[-1]
90+
cor.mat <- cor(heatmap.df, method = params$cor_method)
9191
cor.mat[is.na(cor.mat)] <- 0
9292
if (params$cor_method == "pearson") {
9393
cor.method.name <- "Pearson's"
@@ -279,7 +279,7 @@ heatmaply_cor(
279279
cor.mat,
280280
fontsize_row = 8,
281281
fontsize_col = 8,
282-
column_text_angle = 90
282+
column_text_angle = 45
283283
)
284284
```
285285

workflow/scripts/report/heatmap.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ vcf <- vcf %>%
2929
values_fn = sum
3030
) %>%
3131
arrange(factor(SAMPLE, levels = date_order)) %>%
32+
# Removes "|"-separated annotations, keeping the first one + ellipsis (clarifies heatmap)
33+
rename_with(~ str_replace(., "^([^|]+)\\|.*$", "\\1(...)"), -SAMPLE) %>%
3234
column_to_rownames(var = "SAMPLE")
3335

3436
log_info("Saving table to create heatmap")

0 commit comments

Comments
 (0)