HelenaLC / CATALYST

Cytometry dATa anALYsis Tools
67 stars 30 forks source link

Add labels to points in plotAbundances #341

Closed MargolinGaby closed 1 year ago

MargolinGaby commented 1 year ago

Hello, I have sce00C - single cell experiment object, which already includes manually merged clusters,

  1. Is it possible to add at this step additional meta data attribute like age of the donor/sample_id (for each patient_id/sample_id)?
  2. Can you please direct me how to add labels to the points in plotAbundances graph. this is my original command for plotAbundances: pA <- plotAbundances(sce00C, k = "merging1", by = "cluster_id", shape_by = "gender") and I want to keep the original output (as attached) and add to each point the age for each patient_id ),

Question_AbundancePlot_add_age.docx

thank you, Gaby

HelenaLC commented 1 year ago
  1. re additional metadata, please see issue #337
  2. re adding labels: you can add basic ggplot2 commands for this. Here using ggrepel, actually, to avoid overlaps. In the example, I am labeling by sample_id, but anything that's in the colData and maps uniquely to the samples can go here. Though, for my taste, annotating by additional metadata makes the plot too crowded/hard to read...
    
    library(CATALYST)
    library(ggplot2)
    library(ggrepel)

data(PBMC_fs, PBMC_panel, PBMC_md) sce <- prepData(PBMC_fs, PBMC_panel, PBMC_md) sce <- cluster(sce, verbose = FALSE) plt <- plotAbundances(sce, k = "meta8", by = "cluster_id")

plt + geom_text_repel(size = 3, aes(condition, Freq, col = condition, label = sample_id))


![image](https://user-images.githubusercontent.com/14542264/234216035-85ea7ea1-383c-4840-aa14-90eaaace5704.png)