-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateBoxplotRscripts.pl
More file actions
executable file
·139 lines (112 loc) · 4.92 KB
/
createBoxplotRscripts.pl
File metadata and controls
executable file
·139 lines (112 loc) · 4.92 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/usr/bin/perl -w
# Author: Abdullah Kahraman
# Date: 06.01.2015
###############################################################################
###############################################################################
### bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla ###
###############################################################################
###############################################################################
use strict;
use warnings;
use Getopt::Long;
use File::Basename;
my (
# variable for parameters which are read in from commandline
$help,
);
##############################################################################
### read all needed parameters from commandline ##############################
&GetOptions(
"help!" => \$help, # print this help
) or die "\nTry \"$0 -h\" for a complete list of options\n\n";
##############################################################################
# help
if ($help) {printHelp(); exit}
##############################################################################
### SETTINGS #################################################################
##############################################################################
##############################################################################
### SUBROUTINES ##############################################################
##############################################################################
###############################################################################
sub printHelp {
###############################################################################
# prints a help about the using and parameters of this scripts
# (execute if user types commandline parameter -h)
# param: no paramaters
# return: no return value
my (
$usage,
$sourceCode,
@rows,
$row,
$option,
$scriptInfo,
$example,
);
$usage = "$0\n";
print "\nUsage: " . $usage . "\n";
print "Valid options are:\n\n";
open(MYSELF, "$0") or
die "Cannot read source code file $0: $!\n";
$sourceCode .= join "", <MYSELF>;
close MYSELF;
$sourceCode =~ s/^.+?\&GetOptions\(\n//s;
$sourceCode =~ s/\n\).+$//s;
@rows = split /\n/, $sourceCode;
foreach $row (@rows){
$option = $row;
$option =~ s/\s+\"//g;
$option =~ s/\"\s.+\#/\t\#/g;
$option =~ s/=./\t<value> [required]/;
$option =~ s/:./\t<value> [optional]/;
$option =~ s/!/\t<non value> [optional]/;
$row =~ s/^.*//;
print "\t";
printf("%-1s%-30s%-30s\n", "-",$option,$row);
} # end of foreach $row (@rows)
print "\n";
print "Options may be abreviated, e.g. -h for --help\n\n";
$example = "$0";
}
##############################################################################
### END OF SUBROUTINES########################################################
##############################################################################
############
### MAIN ###
############
for (my $i=15; $i<=38; $i++) {
my $input = "string3d_human/scores_".$i."_hit.txt.gz";
my $output = "scores_".$i."_hit_plots";
my $script = <<SCRIPT;
library(vioplot)
header = c("isHit", "KEGGpathway", "stringId1", "stringId2", "qUniprotAc1", "qUniprotAc2", "probisUniprotId1", "probisUniprotId2", "probisPdbId1", "probisPdbId2", "uniprotId1", "uniprotId2", "qPdbId-chainId2", "bs1-bs2", "probisEvalue1", "probisRmsd1", "probisZvalue1", "probisTotal1", "probisHit1", "probisFalse1", "probisRatio1", "probisEvalue2", "probisRmsd2", "probisZvalue2", "probisTotal2", "probisHit2", "probisFalse2", "probisRatio2", "hhsearchProb1", "hhsearchIdent1", "hhsearchInsideAlign1", "hhsearchOutsideAlign1", "hhsearchRatio1", "hhsearchProb2", "hhsearchIdent2", "hhsearchInsideAlign2", "hhsearchOutsideAlign2", "hhsearchRatio2");
i=$i
rowsTop = read.table(gzfile("$input"), nrows = 5)
classes = sapply(rowsTop, class)
data = read.table(gzfile("$input"),colClasses = classes, comment.char = "")
SCRIPT
if($i==30 or $i==38) {
$script .= 'data[,2] = as.numeric(sub("%","",data[,2]))/100'."\n";
}
# for scores that indicate better performance with increasing value, we need to sort backwards
if($i==15 or $i==16 or $i==20 or $i==22 or $i==23 or $i==27 or $i==32 or $i==37) {
$script .= 'data = data[order(data[,2]),]'."\n";
} else {
$script .= 'data = data[order(-data[,2]),]'."\n";
}
$script .= <<SCRIPT;
data.dens <- density(data[,2])
png("$output.png", width=1400, height=1400)
par(mfrow=c(2,2))
vioplot(data[,2], names=c(header[i]))
data.box = boxplot(data[,2])
data.hist = hist(data[,2], breaks=100, main=paste("Histogram of",header[i],sep=" "))
plot(data.dens)
dev.off()
cat(i, "\\t", header[i], "\\t", data.hist\$breaks, "\\t", data.hist\$mids, "\\t", data.hist\$counts, "\\t", data.hist\$density, "\\n", data.box\$stats, "\\n", file="$output.txt")
SCRIPT
open(O, ">$output.R") or die "\nERROR: Failed to create $output.R: $!\n\n";
print O $script;
close(O);
}