HelenaLC / CATALYST

Cytometry dATa anALYsis Tools
67 stars 30 forks source link

plotDR: Representation of multiple conditions #313

Closed BBarroso82 closed 1 year ago

BBarroso82 commented 1 year ago

Hi,

I have and Issue with an experiment. In my experiment i have two conditions that i want to compare, the AGE of the samples: YOUNG and OLD and the TIME of the experiment: BASAL, 14D, 28D. When i have the TSNE representations. Is there a way to represent how the young and old specimens would look in the three different times? So the 6 plot representation?

Thanks a lot :)

HelenaLC commented 1 year ago

Sure. I think the simplest approach would be to create a new cell metadata (colData) column that collapses the information you'd like to stratify samples by, i.e., sce$age_time <- paste(sce$age, sce$time, collapse = "."), then plotDR(sce, ..., facet_by = "age_time") will generate one panel per age-time combination. Alternatively, you can always construct a data.frame joining reduced dimensions and cell metadata, and use ggplot to suit your wishes, i.e., df <- data.frame(reducedDim(sce, "TSNE")), colData(sce), then ggplot(df, aes(...)) + geom_point() + facet_wrap(c("age", "time")) (or facet_grid(age ~time) to have a specific factor as rows/columns). In principle, the above can be used for any number of variables (not just two), as long as you are coloring points (cells) by one variable only in addition to faceting.