-
Notifications
You must be signed in to change notification settings - Fork 32
/
QuickDotplot.R
executable file
·42 lines (34 loc) · 1.23 KB
/
QuickDotplot.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env Rscript
# The above "shebang" allows this file to be self-executing
# QuickDotplot.R
#
# This R script was generated by the Perl command QuickDotplot, at
# Mon Sep 19 13:43:55 2016
# Specifically, the command was:
# < directory=/data/scratch/lachesis/git-201609 >
# QuickDotplot clm.22.dotplot.txt
library( ggplot2, quietly=TRUE ) # ggplot
dotplot.file <- 'clm.22.dotplot.txt'
jpeg.file <- 'out/clm.22.dotplot.txt.jpg'
# Read the dotplot file.
dotplot <- read.table( dotplot.file, header=FALSE )
# Load the data into a ggplot object.
p <- ggplot( dotplot, aes( x=V1, y=V2 ) )
p <- p + theme_bw()
# Plot the points, and load in the colors, if any were given.
if ( ncol(dotplot) == 2 ) {
p <- p + geom_point( size = 2, col='black' )
w <- 14
} else {
p <- p + geom_point( size = 2, aes( col=dotplot[,3] ) )
if ( dim( table( dotplot[,3] ) ) <= 10 ) {
p <- p + scale_colour_brewer(palette="Set1") # color mapping
}
w <- 12
}
# Assign text labels.
p <- p + ggtitle( "QuickDotplot of clm.22.dotplot.txt" )
p <- p + xlab("")
p <- p + ylab("")
# Save the plot to the jpeg file. Adjust the width to make room for a legend, if there is one.
suppressWarnings( ggsave( filename=jpeg.file, plot=p, width=w, height=12 ) )