DillonHammill / CytoExploreR

Interactive Cytometry Data Analysis
60 stars 13 forks source link

combo population? #136

Closed algarji closed 2 years ago

algarji commented 2 years ago

Is it possible to call a combo population (for example CD4 OR CD8) in the parent argument of cyto_plot? One option that comes to my mind is to plot these populations as overlays and set the parent population in white color, however, if I am interested in drawing contour lines, I think that all cells are taken into account.

cyto_plot(gs[c(2,6,4,3,1,5)],
parent = "CD3",    ## I want to change this for CD4 OR CD8 gates
title = c("control", "pepT_EBV", "pepT_CMV", "control", "pepT_EBV", "pepT_CMV"),
channels = c("IFNg","TNF"), 
contour_lines = 18, 
contour_line_width = 0.2, 
point_col_alpha = 0.8, 
label_fill_alpha = 0,
point_col = c("gray", "lightblue", "indianred1", "gray", "lightblue", "indianred1"),
xlim = c(500,500000), 
ylim=c(100,1000000),
point_size = 0.45, 
point_shape = 16)
DillonHammill commented 2 years ago

@algarji, not entirely sure what you hope to achieve, but it sounds like you just need to set the number of contour lines for each layer:

cyto_plot(gs[c(2,6,4,3,1,5)],
parent = "CD3", 
overlay = c("CD4", "CD8"),
title = c("control", "pepT_EBV", "pepT_CMV", "control", "pepT_EBV", "pepT_CMV"),
channels = c("IFNg","TNF"), 
contour_lines = c(0,18,18), 
contour_line_width = 0.2, 
point_col_alpha = 0.8, 
label_fill_alpha = 0,
point_col = c("white","blue","red"),
xlim = c(500,500000), 
ylim=c(100,1000000),
point_size = 0.45, 
point_shape = 16)

This will place no contour lines on the bottom CD3 layer but set different contours for your overlaid CD4 and CD8 T cell layers.

algarji commented 2 years ago

@DillonHammill, that is a partial solution, because I am interested in combining the contours of layers CD4 and CD8 into one unique contour. I already have the parent CD3 population, but CD4 and CD8 subgatings are more precise to exclude for example double positives or CD3s poorly stained with CD4 or CD8. So I was wondering if there is a way to plot a combo population with a unique contour.

At the begining I tried parent=c('CD4', 'CD8') but it didn't work.

I also tried to double gate a CD4/CD8 population in the same plot but it got an error:

cyto_gate_draw(gs,
               parent = "CD3",
               alias = c("CD4/CD8", "CD4/CD8"),
               channels = c("CD4", "CD8"),
               type = c("rectangle", "rectangle"))
DillonHammill commented 2 years ago

You will need to create a boolean gate to combine these populations.

gs <- cyto_gate_bool(
gs, 
parent = "CD3", 
alias = "CD4+CD8+", 
logic = "CD4|CD8"
)

cyto_plot(
gs, 
parent = "CD4+CD8+",
channels = c("IFNg","TNF"),
contour_lines = 18
)
algarji commented 2 years ago

Yes, that definitely worked. Thank you so much @DillonHammill