Created
July 11, 2012 09:43
-
-
Save soh-i/3089325 to your computer and use it in GitHub Desktop.
Rをbatch modeで実行してFigureをたくさん描く
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env perl | |
| use strict; | |
| use warnings; | |
| use 5.16.0; | |
| ## | |
| ## This script makes figures that phosphorylation sites given specify output data by R batch mode. | |
| ## | |
| if ( scalar @ARGV != 1 ) { | |
| die "Usage:\n\tperl $0 <specify directory>\n\n"; | |
| } | |
| my $path = shift; | |
| opendir my $dir, $path || die "Cant load $path"; | |
| my @files; | |
| foreach ( readdir $dir ) { | |
| next if /^\.{1,2}$/; | |
| my ($file) = split /\./, $_; | |
| push @files, $file; | |
| } | |
| for my $file ( @files ) { | |
| my $script = "/home/soh.i/genokai/R_plot/$file.R"; | |
| open my $out, '>', "$script" || die $!; | |
| print $out <<EOF; | |
| #Fig B | |
| png("$file.B.png", width=800, height=500) | |
| data<-read.table("$file.data", header=T) | |
| labB<-c("B_PhosphoSerines", "B_ControlSerines") | |
| bp<-as.matrix(data\$B_PhosphoSerines) | |
| bc<-as.matrix(data\$B_ControlSerines) | |
| C=cbind(bp, bc) | |
| barplot(t(C), beside=T, legend=labB, names=data\$AA, col=c("red", "black"), ylab="Amino acid incidence(%)", xlab="Amino acid", main="$file") | |
| dev.off() | |
| #Fig C | |
| png("$file.C.png", width=800, height=500) | |
| labC<-c("C_PhosphoSerines", "C_ControlSerines") | |
| cp<-as.matrix(data\$C_PhosphoSerines) | |
| cc<-as.matrix(data\$C_ControlSerines) | |
| C=cbind(bp, bc) | |
| barplot(t(C), beside=T, legend=labC, names=data\$AA, col=c("red", "black"), ylab="Enrichment relative to overall AA abundance", xlab="Amino acid", main="$file") | |
| dev.off() | |
| #Fig D | |
| png("$file.D.png", width=800, height=500) | |
| ratio<-as.matrix(data\$cSer\.pSer) | |
| C=cbind(ratio) | |
| barplot(t(C-1), beside=T, names=data\$AA, col=c("red", "black"), ylab="Enrichment, pSer:Control Ser", xlab="Amino acid", main="$file") | |
| dev.off() | |
| EOF | |
| close $out; | |
| system("R --vanilla --slave < $script"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment