Skip to content

Can't match column labels to columns when using group_by #118

Open
@ghowitt

Description

@ghowitt

Hello,

Apologies if this is not the right place for this issue - it's possibly got more to do with ComplexHeatmap than tidyHeatmap - but I'm having some trouble with column labels.

I have a data frame of measurements from 9 different methods. The measurements were taken in three separate batches of 8 sample and some samples are duplicated across batches. I've made a mock dataframe with the same dimensions where in batch 1 all values are 1, batch 2 all values are 0.75 and batch 3 all values are 0.5

I want to make a heatmap where the rows are the methods, the columns are the samples, and the data is grouped by batch. Because there are some duplicated sample/method combinations I've had to create a new column in the dataframe, sample_x_batch, which appends the batch number to the sample name. If I use this code then the figure looks basically exactly as I want:
df %>% group_by(batch) %>% heatmap(.row = method, .column = sample_x_batch, .value = value, column_title = "", cluster_rows = FALSE, cluster_columns = FALSE)

image

However, I'd like to use the sample names as the column labels instead of sample_x_batch. I thought I could do this by adding a column_labels argument in to the heatmap function, but it doesn't put the labels on the right columns, e.g.

image

I've tried also using the column_order argument, but this only presents things in the correct order if I don't use group_by = batch.

Is there a way to assign the labels directly from the dataframe or a better way to control where they are placed on the heatmap?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions