'Save facet_wrap into individual files after plotting

Here is my code where I'm trying to use facet_wrap on multiple PCs[Principle Components].

As an example i have shown here two PCs

p3 <- select(tcga_mrna.pcs, Sex, FAB, PC1:PC2) %>%
  gather(starts_with("PC"), key="PC", value="score") %>%
  ggplot(aes(x=FAB:Sex, y=score, color=FAB, shape=Sex)) +
  geom_boxplot(outlier.shape=NA) +
  geom_point(position = position_jitter(width=0.25, height=0)) +
  facet_wrap(~PC, ncol=5) +
  theme_bw(base_size = 18) +
  ggtitle("mRNA Principle Components")
 p3

This is how it looks like when i plot. The plot looks crowded if i use facet_wrap.

I have like 15 Principle component. So how do I plot one principle component and save it into a different file for example I have 15 PCs so I want to plot PC1 and then save it with name which would be like PC1 , similarly for PC2,PC3 etc etc till the last PC.

Any suggestion or help would be really appreciated. My plot

My data-frame looks like this

Sample_ID FAB prior_malignancy Age BM_percentage     Cytogenetic_Code   Histologic_Subtype    Risk_Cyto Risk_Molecular    Sex       TMB  WBC
1 TCGA-AB-2856  M4               no  63            82     Normal Karyotype  NUP98 Translocation Intermediate           Poor   Male 0.0000000 76.7
2 TCGA-AB-2849  M0               no  39            83 Complex Cytogenetics Complex Cytogenetics         Poor           Poor   Male 0.7333333  5.0
3 TCGA-AB-2971  M4               no  76            91     Normal Karyotype     Normal Karyotype Intermediate   Intermediate Female 0.3000000  5.0
4 TCGA-AB-2930  M2               no  62            72     Normal Karyotype  NUP98 Translocation Intermediate           Poor Female 0.2666667 27.7
5 TCGA-AB-2891  M1               no  42            68 Complex Cytogenetics Complex Cytogenetics         Poor           Poor   Male 0.4666667 10.7
6 TCGA-AB-2872  M3               no  42            88             PML-RARA             PML-RARA         Good           Good   Male 0.3333333  2.1
         PC1         PC2         PC3        PC4         PC5        PC6        PC7        PC8        PC9      PC10      PC11         PC12
1 -25.424317  14.4895578 -10.6509446   1.182488 -14.8325881  0.6953673 -16.700015   2.798221  -7.053316 13.213244 -1.790502   7.83152902
2  38.558442 -27.8233346  28.0996433 -21.014576  17.8653710 -7.4625539  14.388732  -6.635287 -12.198575 -2.821523 -6.578223 -19.59501836
3 -18.883826  -0.3180748   5.8827061 -13.665220   8.9000249 -9.4897354  16.065772 -12.872551   4.106133 -8.007720 -4.201322  -9.38164110
4   3.773812   6.1704313 -26.4971717   4.645449  -0.5507934  5.2762678  -9.866106  -2.175799 -20.037491  5.333369  4.515898  16.36901220
5  -5.028680  -9.2915076  -0.8963628   6.105521   5.9079080  2.8564553  -8.278327 -12.578166 -13.427652 -6.781148 -1.679537   0.07350317
6  21.465828  35.1156168  23.2794430   1.085498  13.7446794 -2.5417697  -3.148765  -2.909438  -2.770329 -5.633546  3.753492   2.32446981


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source