HelenaLC / CATALYST

Cytometry dATa anALYsis Tools
67 stars 30 forks source link

Duplicate ids in x-axis in freqheatmap #339

Closed Ind2022 closed 8 months ago

Ind2022 commented 1 year ago

Hello All,

The experimental data which I am trying to plot with freq heatmap after clustering has metadata with sample ids (all unique) but patient id with duplicates , for example: same patient id can have 2 unique sample_ids.

Sample id Patient id A11 A5555 A22 A5555

If I want to plot frequency heatmap after clustering with x-axis as patient id not sample id , is this possible? I see an option in freq heatmap as "by" but that is applicable for either sample id or cluster id. Please suggest.

Thanks, Indrani

Ind2022 commented 1 year ago

I mean to say is there any way I can "Group" them by patient id as x-axis in freq heatmap. Thanks

HelenaLC commented 8 months ago

This is currently not possible with the plotFreqHeatmap() function, however, can be done using base R and a plotting library of your choice; here's a minimal reproducible example:

# depencies
library(CATALYST)
library(pheatmap)

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

# wrangling
k <- "meta20"
ns <- table(
    patient_id=sce$patient_id,
    cluster_id=cluster_ids(sce, k))
fq <- prop.table(ns, margin=1)

# plotting
pheatmap(fq, scale="none")