HelenaLC / CATALYST

Cytometry dATa anALYsis Tools
66 stars 30 forks source link

visualising specific clusters using plotPbExprs #397

Closed satsumayo closed 1 month ago

satsumayo commented 1 month ago

Hello,

I have a single cell experiment data set that I have clustered. I have been using plotPbExprs to visualise 19 clusters faceted by antigen.

plotPbExprs(sce, features = c("GzmB", "Perforin"), k = "meta19", group_by = "cluster_id", facet_by = "antigen", color_by = "cluster_id", geom = "both", size_by = FALSE, jitter = FALSE, ncol = 2)

I would like to only compare median expression of only 2 specified clusters and run a Mann Whitney U text between the two specified clusters. Just wanted some advice on how to layer this onto the code above?

Thank you.

HelenaLC commented 1 month ago

To filter sce, you can use the filterSCE function; see minimal example below ... then again, if you're interested in just getting the "raw" data for this, I'd suggest just computing expression medians by cluster-sample using base R or scuttle::aggregateAcrossCells().

library(CATALYST)
data(PBMC_fs, PBMC_panel, PBMC_md)
sce <- prepData(PBMC_fs, PBMC_panel, PBMC_md)
sce <- cluster(sce, verbose = FALSE)

sub <- filterSCE(sce, k = "meta12", cluster_id %in% c(1, 10))

plotPbExprs(sub, 
    facet_by = "antigen", 
    k = "meta12", ncol = 7,
    group_by = "cluster_id", 
    color_by = "cluster_id")

image