Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ghowitt opened this issue May 25, 2023 · 0 comments
Open

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

ghowitt opened this issue May 25, 2023 · 0 comments

Comments

@ghowitt
Copy link

ghowitt commented May 25, 2023

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant