Skip to content

Commit

Permalink
add run_R.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
matsumoto authored and matsumoto committed Feb 14, 2017
1 parent fbf6438 commit 6c3c4a5
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@ G x D matrix, which corresponds to W of linear regression.
#### RSS.txt
The residual sum of squares of linear regression.

## Running SCODE several times
We recommend runnning SCODE several times and averaging the result (A) to obtain reliable relationships.
```
ruby run_R.rb <Input_file1> <Input_file2> <Output_dir> <G> <D> <C> <I> <R>
```

* R : The number of traials
* Output_dir : Result files of each trial is outputted in the directory

The averaged A (meanA.txt) is outputted in the Output_dir.

<br>
<br>
# Downstream analysis
Expand Down
12 changes: 12 additions & 0 deletions averageA.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
args <- commandArgs(trailingOnly = T)
dir <- args[1]
repnum <- as.numeric(args[2])

meanA <- as.matrix(read.table(paste(dir,"/out_1/A.txt",sep="")))
for(i in 2:repnum){
tmp <- as.matrix(read.table(paste(dir,"/out_",i,"/A.txt",sep="")))
meanA <- meanA + tmp
}
meanA <- meanA / repnum

write.table(meanA, paste(dir,"/meanA.txt",sep=""), sep="\t", col.names=F, row.names=F)
16 changes: 16 additions & 0 deletions run_R.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/ruby

fdata = ARGV[0]
ftime = ARGV[1]
dir = ARGV[2]
tfnum = ARGV[3]
pnum = ARGV[4]
cnum = ARGV[5]
maxite = ARGV[6]
repnum = ARGV[7].to_i

system("mkdir #{dir}")
for i in 1..repnum
system("Rscript SCODE.R #{fdata} #{ftime} #{dir}/out_#{i} #{tfnum} #{pnum} #{cnum} #{maxite}")
end
system("Rscript averageA.R #{dir} #{repnum}")

0 comments on commit 6c3c4a5

Please sign in to comment.