HelenaLC / CATALYST

Cytometry dATa anALYsis Tools
66 stars 31 forks source link

Clustering by specific marker #372

Closed 7DiM7 closed 10 months ago

7DiM7 commented 1 year ago

Hi Helena,

Thank you so much for creating this package, it's been incredibly useful for my work.

I've got a pretty basic question, I'm sorry if it's really obvious. I've tried to figure out how to do this with no luck.

I basically want my heatmap to cluster using a specific marker (Ki-67), the marker is part of my panel under "state"

If I try to run the heatmap using Ki-67 in place of state in features I only get 1 column with Ki-67 (code is below). I would like the clusters organised like that but with all the other state markers as well.

Below is the failed heatmap image. image

plotExprHeatmap(sce, features ="Ki-67",
by = "cluster_id", k = "meta20", row_clust = TRUE, bars = TRUE, perc = TRUE)

HelenaLC commented 10 months ago

Not sure I understood the issue correctly, sorry... Do you mean rendering a heatmap that includes all state features, but keeping the same order of clusters as obtained for one marker only? If yes, here's a minimal reproducible example that would do this (note that, it's currently missing the left-hand side dendrogram... perhaps google could help here). If no, feel free to reopen the issue.

# depencies
library(CATALYST)
library(ComplexHeatmap)

# setup
data(PBMC_fs, PBMC_panel, PBMC_md)
sce <- prepData(PBMC_fs, PBMC_panel, PBMC_md)
sce <- cluster(sce, verbose=FALSE)

# plot marker of interest
hm1 <- draw(plotExprHeatmap(sce, features="pAkt", by="cluster_id"))

image

# retrieve ordering
o <- row_order(hm1)
d <- row_dend(hm1) # not sure how to add this below...

# plot all markers with fixed order
hm2 <- plotExprHeatmap(sce, features=state_markers(sce), by="cluster_id")
draw(hm2, row_order=o)

image