-
Notifications
You must be signed in to change notification settings - Fork 24
Description
I think (not 100% sure though) the conversion from wide to long format performed in the heatmapEnrichment() function is incorrect. I think transposing the data.frame is causing a problem.
Lines 97 to 102 in c260ec6
| long <- data.frame( | |
| variable = rep(gene.set, each = nrow(agg)), | |
| value = as.vector(t(agg[gene.set])), | |
| group = rep(agg[[group.by]], times = length(gene.set)), | |
| stringsAsFactors = FALSE | |
| ) |
Example: The line as.vector(t(...)) returns all values of the first row. However, both variable and group are constructed assuming values are returned row-by-row for the first column etc. This leads to misalignment.
I would suggest switching to tidyr::pivot_longer() to avoid this problem (unless you want to keep base R) and make the conversion less error-prone.
If you want to keep base R, I think this chunk would fix the issue
long <- data.frame(
variable = rep(gene.set, each = nrow(agg)),
value = unlist(agg[gene.set], use.names = FALSE),
group = rep(agg[["ident"]], times = length(gene.set)),
stringsAsFactors = FALSE
)
Could you validate this?
Let me know what you would like to do. I can create a pull request once you confirm this.
Best wishes,
Tobi