structure(list(Patients = c("LT2", "LT2", "LT2", "LT2", "LT2",
"LT2", "LT2", "LT2", "LT2", "LT2", "LT3", "LT3", "LT3", "LT3",
"LT3", "LT3", "LT3", "LT3", "LT3", "LT3", "LT4", "LT4", "LT4",
"LT4", "LT4", "LT4", "LT4", "LT4", "LT4", "LT4", "LT5", "LT5",
"LT5", "LT5", "LT5", "LT5", "LT5", "LT5", "LT5", "LT5"), Cell_type = c("CD3 T cells",
"CD4 T cells", "CD8 T cells", "NKT cells", "CD14 monocytes",
"CD19 B cells", "CD56 dim NK cells", "CD56 high NK cells", "Eosinophils",
"Neutrophils", "CD3 T cells", "CD4 T cells", "CD8 T cells", "NKT cells",
"CD14 monocytes", "CD19 B cells", "CD56 dim NK cells", "CD56 high NK cells",
"Eosinophils", "Neutrophils", "CD3 T cells", "CD4 T cells", "CD8 T cells",
"NKT cells", "CD14 monocytes", "CD19 B cells", "CD56 dim NK cells",
"CD56 high NK cells", "Eosinophils", "Neutrophils", "CD3 T cells",
"CD4 T cells", "CD8 T cells", "NKT cells", "CD14 monocytes",
"CD19 B cells", "CD56 dim NK cells", "CD56 high NK cells", "Eosinophils",
"Neutrophils"), Value = c(25.6, 61.8, 27.2, 4.94, 1.92, 11.1,
7.39, 42.8, 4.39, 42.9, 19.8, 65.3, 29.1, 2.87, 1.68, 1.99, 6.23,
60.7, 4.7, 61.5, 20.3, 81, 16.2, 0.25, 1.09, 3.3, 7.07, 61.9,
4.96, 61.6, 29.4, 76.2, 20.8, 1.47, 1.3, 3.92, 11.3, 35.3, 1.18,
51.3)), class = "data.frame", row.names = c(NA, -40L))
Hi everyone, I was wondering if anyone could help making balloon plots with colours based on values, and value numbers in the dots. I can't download ggballoonplot in R, even though ggplot2 is updated.
I run the following code, but can only get black balloon plots.
Immunoph <- read.csv("LS-Pts_csv.csv", header = T)
names(Immunoph)[names(Immunoph) =="Freq"] <-"Value"
head(Immunoph)
p <- ggplot(Immunoph, aes(x=Patients, y=Cell_type))
p+geom_point(aes(size=Value)) +theme(panel.background = element_blank(),
panel.border =element_rect(colour = "blue", fill = NA, size = 1))
I would appreciate any suggestion/help, and sorry for my poor skills in R.
You need to use color = Value
inside aes
and add a geom_text()
call:
p <- ggplot(Immunoph, aes(x=Patients, y=Cell_type, color = Value))
p+geom_point(aes(size=Value)) +theme(panel.background = element_blank(),
panel.border =element_rect(colour = "blue", fill = NA, size = 1)) +
geom_text(label=Immunoph$Value, color="black")
Although if you nudge the text it looks better:
p <- ggplot(Immunoph, aes(x=Patients, y=Cell_type, color = Value))
p+geom_point(aes(size=Value)) +theme(panel.background = element_blank(),
panel.border =element_rect(colour = "blue", fill = NA, size = 1)) +
geom_text(label=Immunoph$Value, color="black", nudge_x = 0.2)