HelenaLC / CATALYST

Cytometry dATa anALYsis Tools
66 stars 30 forks source link

plotDiffHeatmap: avoid failure when only one cluster remains #382

Closed SamGG closed 1 month ago

SamGG commented 7 months ago

IIUC, when there is only one cluster left, as.matrix() results in a one column matrix instead of one row matrix. https://github.com/HelenaLC/CATALYST/blob/f3e294ed9a4d3f300feb994bb381df6a6b2c8309/R/plotDiffHeatmap.R#L243-L250 I propose to transpose y in such a case. if (nrow(top) == 1) y <- t(y) In my hands, it works and permits to display a single significant cluster.

SamGG commented 7 months ago

In fact, the following is even simpler: fq <- fq[top$cluster_id, , drop = FALSE]

HelenaLC commented 6 months ago

Sounds good. Thanks again for catching this. Edgy cases aren't my strong suit to think of ;) - will do along with issue #381.

SamGG commented 6 months ago

Thanks. Edgy cases are very difficult to anticipate. This question is independent from #381.

HelenaLC commented 6 months ago

Yes, absolutely, I only meant that I will try and resolve both with one update/version bump.