# Making a box plot of the proportion of cells in each cell types in two groups

I have number of cells in three cell types T, B, M in a Seurat object

For two groups of patients, cancers and controls like

> table(Idents(pbmc), pbmc$samples) PN0252_0001 PN0252_0002 PN0252_0003 PN0252_0004 PN0252_0005 PN0252_0006 PN0252_0008 T 3550 568 136 268 1835 2 1678 B 136 129 11 25 133 0 203 M 120 22 18 26 159 0 59 > dput(table(Idents(pbmc), pbmc$samples))
structure(c(3550L, 136L, 120L, 568L, 129L, 22L, 136L, 11L, 18L,
268L, 25L, 26L, 1835L, 133L, 159L, 2L, 0L, 0L, 1678L, 203L, 59L
), .Dim = c(3L, 7L), .Dimnames = structure(list(c("T", "B", "M"
), c("PN0252_0001", "PN0252_0002", "PN0252_0003", "PN0252_0004",
"PN0252_0005", "PN0252_0006", "PN0252_0008")), .Names = c("",
"")), class = "table")
>


Patients PN0252_0001, PN0252_0002, PN0252_0003, PN0252_0004 are controls

and PN0252_0005, PN0252_0006, PN0252_0008 are cancers

I want to look at the difference of the proportion of cells in each cell type between cancer and control

But I am confused for getting proportion should I divide the number of cells on total cells in the object or total cells in each group

Basically I need a box plot like although here numbers are not correct

• This looks like a ggplot with a facet added to it. What have you tried? Jul 29, 2021 at 19:40
• What I plotted here is what I have tried but I am not sure about the proportions Jul 30, 2021 at 8:34
• Your boxplot seems correct. What do you think is wrong about it? Jul 30, 2021 at 10:37
• I don't know proportion of T cells for example, I should divide the number of T cells in each patients on the total number of cells or total cells in controls and cancers separately Jul 30, 2021 at 20:19
• The answer to that depends on the question you're asking and what you wish to showcase. In any case, only you can answer it, we can't do that for you. Jul 30, 2021 at 21:55