4

I have generated a ggplot for 8 single-cell libraries, with the purpose of visualizing the tSNE facet plot by sample, colored by cell type -- with percentages. The best I could get to is this -

enter image description here

however, it looks too crowded, and I also want the cell types to be labeled for each cluster, which makes it look even worse.
How can I improve the data visualization here?

my code:

p6 <- ggplot(tsnePlot, aes(x=tSNE_1, y=tSNE_2, color=RefinedCellTypes)) + 
  scale_color_manual(values=refinedCellTypeColors) +
  geom_point(data = tsnePlotAll, mapping = aes(x=tSNE_1, y=tSNE_2), size = 1, alpha = 1, color = "grey75") +
  geom_point(size = 1, alpha = 1) +
  geom_text(data = tsneClusterLabelsRefined, mapping = aes(x = tSNE_1, y = tSNE_2, label = CellType),color="black",size=0.75,hjust=0) +
  geom_label(data = tsneCellTypeFractions, mapping = aes(x = tSNE_1, y = tSNE_2, label = scales::percent(Freq,accuracy = 0.1)),color="black",fill = "white", alpha = 0.5, label.size = 0) +
  facet_wrap(~Sample) +
  theme_bw(base_size = 12) +
  theme(legend.position="left",
        axis.text=element_text(size=12, color = "black"),
        axis.title=element_text(size=10))

Is there any way I can control the number of cols/rows for the figure?

gringer
  • 14,012
  • 5
  • 23
  • 79
ShaniS
  • 51
  • 1

2 Answers2

3

On top of M__'s suggestion to reduce the point alpha, here are a few other things you can implement to make your figures cleaner:

Remove grid lines from the panel backgrounds

theme(panel.grid.major = element_blank(),
      panel.grid.minor = element_blank())

I think a figure legend like the one you have now is a better approach than labeling every cell type in every facet. However, if you still want to go that route, I suggest implementing repulsive labels with the ggrepel package. geom_label_repel() can also be applied to your percentages so they are not overlapping.

acvill
  • 613
  • 3
  • 12
1

Try

p6 + geom_point(alpha = 1/100)

And variations of 1/10 to 1/1000, this will give a better idea of point density.

M__
  • 12,263
  • 5
  • 28
  • 47