# Load the csv file with the information for the plot. my_plot <- read_csv("file_for_plot.csv") coeff <- 100 # Determine the order that the clusters/genera are going to be in the x axis of the plot. my_plot$cluster <- factor(my_plot$cluster, levels = c(#LEVELS#)) # Initialize a ggplot object. Declare the input data as the loaded csv file. Determine the plot aesthetics. ggplot(data=my_plot, mapping=aes(x=cluster)) + # Determines the type of plot with geom_jitter, with the desired aesthetics and characteristics. This is done for both y axes. geom_jitter(aes(y=CAI, shape=organism, color=group), width=0.3, height=0.05, size=0.8, alpha=0.4) + geom_jitter(aes(y=GC / coeff, shape=organism, color=group), width=0.3, height=0.05, size=0.8, alpha=0.4) + # Determines the limits of the y axes. coord_cartesian(ylim=c(0, 0.8)) + # Determines y axes as continous, specify the axes titles and breaks. scale_y_continuous( name="CAI", sec.axis = sec_axis(~.*coeff, name="%GC"), breaks=seq(0, 0.8, 0.1) ) + # Specifies the shapes of the dots in the plot according to a variable included in the input file. scale_shape_manual(values=c("V"=16, "B"=17)) + # Specifies the colors according to a variable included in the input file. scale_color_manual(values=c(#COLORS#)) + # Determines the theme of the plot. Legend is excluded, as well as the title of the x axis. Y axes titles, axes labels, plot background, plot grid and axes lines are modified to preference. theme( legend.position="none", axis.title.x=element_blank(), axis.title.y=element_text(size=10), axis.title.y.right=element_text(size=10), axis.text.x=element_text(size=7, angle=90), axis.text.y=element_text(size=7), axis.text.y.right=element_text(size=7), panel.background=element_rect(fill="white"), panel.grid.major.x=element_line(color="lightgray", size=0.5), panel.grid.major.y=element_line(color="lightgray", size=0.5), axis.line=element_line(size=1, color="dimgray") ) # Save the plot. Determine the filename and the characteristics the plot has to be saved in. ggsave(filename = "plot.png", width = 16, height = 10, dpi = 500, units = "cm") #LEVELS# "Arthrobacter","AK","AL","AM*","AN","AO","AP","AQ","AR","AS","AT","AU*","AV","AW*","AX","AY","AZ","FA","FB","FC","FD","FE","FF","FG" "Streptomyces","BA","BB","BC","BD","BE","BF","BG","BH","BI*","BJ","BK","BL","BM","BN","BO" "Rhodococcus","CA","CB","CC*" "Microbacterium","EA","EB","EC","ED","EE","EF","EG","EH","EI","EJ","EK","EL*","EM","GA","GB" "Faecalibacterium","Faec*","Faec" "Lactococcus","Lacto*","Lacto" "Gordonia","A","CD","CQ","CR","CS","CT","CU","CV","CW","CX","CY","CZ","DB","DC","DE","DF","DG","DH","DI","DJ*","DK","DL", "DM","DN","DO","DP","DQ","DR","DS","DT","DU","DV" #COLORS# "R1"="darkorchid4","R2"="orchid3","M1"="blue4","M2"="skyblue3","F1"="chocolate4","F2"="chocolate","L1"="black","L2"="gray62" "G1"="darkgreen","G2"="green1" "A1"="deeppink4","A2"="deeppink","S1"="firebrick4","S2"="firebrick1" Arthrobacter: - nRCA/CAI:deeppink4 - GC:deeppink Streptomyces: - nRCA/CAI:firebrick4 - GC:firebrick1 Gordonia: - nRCA/CAI:darkgreen - GC:green1 Faecalibacterium: - nRCA/CAI:chocolate4 - GC:chocolate Lactococcus: - nRCA/CAI:black - GC:gray62 Microbacterium - nRCA/CAI:blue4 - GC:skyblue3 Rhodococcus: - nRCA/CAI:darkorchid4 - GC:orchid3