Skip to content

Commit c1c349e

Browse files
committed
plain R version of test.rb
1 parent 529eb85 commit c1c349e

File tree

4 files changed

+44
-9
lines changed

4 files changed

+44
-9
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*~
2+
output/**/*

README

+11-4
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,25 @@ It outputs three types of data:
1010

1111
We use this tool to analyze the data from our Millipore Guava easyCyte, and some of the code may be specific to the fcs files produced by this device.
1212

13+
Running using R directly:
14+
15+
R --vanilla < test.r
16+
17+
Running using R through Ruby:
18+
19+
ruby test.rb
20+
1321
Requirements:
1422

1523
BioConductor libraries: flowCore, flowClust and flowViz
16-
Ruby libraries: rubygems, rsruby
24+
For Ruby: rubygems, rsruby
1725

1826
ToDo:
1927

20-
R script to run this without Ruby.
2128
Support for specifying channel (red or green) per fcs file in batch mode.
2229

2330
Note:
2431

25-
The test.rb file runs in batch mode.
26-
You can also run this for a single fcs file using the "run" function in fcs3_analysis/run.r
32+
The test.rb file runs in batch mode.
33+
You can also run this for a single fcs file using the "run" function in fcs3_analysis/run.r
2734

test.r

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
root.path = getwd()
3+
script.path = file.path(root.path, 'fcs3_analysis')
4+
main.script = file.path(script.path, 'fcs3_analysis.r')
5+
replicate.path = file.path(root.path, 'example_replicate')
6+
out.path = file.path(root.path, 'output')
7+
dump.file = file.path(out.path, 'out.dump')
8+
9+
fluo.channel = 'GRN' # or 'RED'
10+
init.gate = 'ellipse' # or 'rectangle
11+
12+
setwd(script.path)
13+
source(main.script)
14+
15+
fcs.file.paths = c()
16+
files = list.files(replicate.path)
17+
18+
for(i in 1:length(files)) {
19+
if(length(grep(".+\\.fcs$", files[i], perl=TRUE)) > 0) {
20+
fcs.file.paths = c(fcs.file.paths, file.path(replicate.path, files[i]))
21+
}
22+
}
23+
24+
data.set = batch(out.path, fcs.file.paths, fluo.channel=fluo.channel, init.gate=init.gate, verbose=TRUE)
25+
26+
cat("Analysis completed.\n")
27+
cat("Cleaned fcs files and plots in: ", out.path, "\n")
28+
cat("Output data not dumped (not implemented).\n")
29+

test.rb

+2-5
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
out_path = File.join(root_path, 'output')
1414
dump_file = File.join(out_path, 'out.dump')
1515

16-
fluo_channel = 'GRN'
17-
init_gate = 'ellipse'
1816

1917
begin
2018

@@ -33,7 +31,7 @@
3331
next if (fcs_file == '.') || (fcs_file == '..')
3432
fcs_file_path = File.join(replicate_path, fcs_file)
3533
next if File.directory?(fcs_file_path)
36-
next if !fcs_file.match(/.*\.fcs3?$/i)
34+
next if !fcs_file.match(/.+\.fcs3?$/i)
3735
fcs_file_paths << fcs_file_path
3836
end
3937

@@ -45,11 +43,10 @@
4543
f = File.new(dump_file, 'w+')
4644
f.puts(data_set.inspect)
4745
f.close
48-
puts "Output data dumped to: #{dump_file}"
4946

5047
puts "Analysis completed."
51-
puts "Data available in: #{dump_file}"
5248
puts "Cleaned fcs files and plots in: #{out_path}"
49+
puts "Output data dumped to: #{dump_file}"
5350

5451
rescue Exception => e
5552
if(e.message[:r_msg])

0 commit comments

Comments
 (0)