4
$\begingroup$

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?

$\endgroup$
0

2 Answers 2

3
$\begingroup$

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.

$\endgroup$
3
  • $\begingroup$ Agreed, BTW I like the user icon $\endgroup$
    – M__
    Commented Feb 9, 2022 at 18:54
  • 1
    $\begingroup$ Phage are phantastic! $\endgroup$
    – acvill
    Commented Feb 9, 2022 at 19:04
  • 1
    $\begingroup$ Except for bacteria :-/ $\endgroup$
    – M__
    Commented Feb 9, 2022 at 19:22
1
$\begingroup$

Try

p6 + geom_point(alpha = 1/100)

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.