Skip to content

Commit 25dc503

Browse files
Merge pull request #18 from CIDARLAB/casestudy/n10matrix
Added a matrix for N=10
2 parents 417739f + 9d8e605 commit 25dc503

File tree

4 files changed

+127
-6
lines changed

4 files changed

+127
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
,T-Sapphire,mKelly2,Sirius,miRFP670,mEmerald,mKeima,iFP1.4,mKalama1,miRFP720,TagRFP-T
2+
Violet (B),1.0,0.0,0.007986949899912821,0.0,0.2115173622032521,0.011320250946328055,0.0,0.4612716063942493,0.0,1.6676958783427712E-4
3+
Yel/Grn (A),0.0,0.28179631708403724,0.0,0.00397105824329659,1.6425520158325137E-4,0.0,0.0,0.0,0.0,1.0
4+
UV (A),2.899210231862116E-4,0.0,1.0,0.0,0.0,0.0,0.0,0.03670770245967755,0.0,0.0
5+
Red (B),0.0,0.04517925054167844,0.0,1.0,2.9081738741205827E-5,0.0,0.0,0.0,0.0,0.0
6+
Blue (A),0.04347776852771244,0.0,0.0,0.0,1.0,0.00343073882440439,0.0,0.0,0.0,6.911925243532591E-4
7+
Violet (C),0.03203228505500069,0.0,0.0,0.0,0.007380918915115408,1.0,0.0,0.0022710094477892562,0.0,0.028282340251470327
8+
Violet (E),0.0,0.0,0.0,0.0,0.0,0.08368808121466456,1.0,0.0,0.0,8.473114863450691E-4
9+
Violet (A),0.0153367566964738,0.0,0.05805469436684404,0.0,4.4308893155085334E-4,0.0,0.0,1.0,0.0,0.0
10+
Red (C),0.0,0.01809664328957377,0.0,0.8788937597835339,1.5521921148430897E-6,0.0,1.0,0.0,0.7989515699583776,0.0
11+
Yel/Grn (C),0.0,0.014742151183734653,0.0,0.0,4.0192899288262585E-4,0.0,0.0,0.0,0.0,1.0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
,T-Sapphire,mKelly2,Sirius,miRFP670,mEmerald,mKeima,iFP1.4,mKalama1,miRFP720,TagRFP-T,Total Bleed-through as % of signal
2+
Violet (B),1,0,0.00798695,0,0.211517362,0.011320251,0,0.461271606,0,1.67E-04,0.692262939
3+
Yel/Grn (A),0,0.281796317,0,0.003971058,1.64E-04,0,0,0,0,1,3.56333725
4+
UV (A),2.90E-04,0,1,0,0,0,0,0.036707702,0,0,3.70E-02
5+
Red (B),0,0.045179251,0,1,2.91E-05,0,0,0,0,0,4.52E-02
6+
Blue (A),0.043477769,0,0,0,1,0.003430739,0,0,0,6.91E-04,0.0475997
7+
Violet (C),0.032032285,0,0,0,0.007380919,1,0,0.002271009,0,0.02828234,0.069966554
8+
Violet (E),0,0,0,0,0,0.083688081,1,0,0,8.47E-04,0.084535393
9+
Violet (A),0.015336757,0,0.058054694,0,4.43E-04,0,0,1,0,0,0.07383454
10+
Red (C),0,0.018096643,0,0.87889376,1.55E-06,0,1,0,0.79895157,0,2.374351621
11+
Yel/Grn (C),0,0.014742151,0,0,4.02E-04,0,0,0,0,1,0.01514408

fpSelection/src/test/java/org/cidarlab/fpSelection/FPbaseTest.java

+19-5
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,32 @@ public void testFPbase() throws IOException, InterruptedException{
6565
}
6666

6767
@Test
68-
public void testIterationCount(){
69-
double temp = 1000000;
70-
double rate = 0.001;
68+
public void testSelectionMatrix() throws IOException, InterruptedException{
69+
String resfp = basefp + "fpbase" + Utilities.getSeparater() + "results_seed0.csv";
70+
List<String[]> lines = Utilities.getCSVFileContentAsList(resfp);
71+
72+
Cytometer harvardCytoflex = fpFortessaParse.parse(harvardCytoFlexfp, false);
73+
Map<String, Fluorophore> fpmap = fpSpectraParse.parse(spectrafp);
74+
List<SelectionInfo> selection = TestUtilities.getConfiguration(lines.get(0),3,fpmap,harvardCytoflex);
75+
76+
TestUtilities.printConfigSignals(selection,basefp + "fpbase" + Utilities.getSeparater() + "seed0rank0matrix.csv");
77+
}
7178

72-
int count = 0;
7379

80+
private static int getIterationCount(double temp, double rate){
81+
int count = 0;
7482
while(temp > 1){
7583
count++;
7684
temp *= (1 - rate);
7785
}
78-
Assert.assertEquals(count,13809);
86+
return count;
7987

88+
}
89+
@Test
90+
public void testIterationCount(){
91+
Assert.assertEquals(getIterationCount(1000000,0.001),13809);
92+
Assert.assertEquals(getIterationCount(10000,0.001),9206);
93+
8094
}
8195

8296
@Test

fpSelection/src/test/java/org/cidarlab/fpSelection/TestUtilities.java

+86-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,92 @@ public static String toString(List<SelectionInfo> selection) {
5454
//line += snr.getSignalNoiseList().get(maps.get(key)).getKey() + "," + snr.getSignalNoiseList().get(maps.get(key)).getValue();
5555
return line;
5656
}
57-
57+
58+
59+
public static Laser getLaser(Cytometer c, String lname) {
60+
for (Laser l : c.lasers) {
61+
if (l.getName().equals(lname)) {
62+
return l;
63+
}
64+
}
65+
System.out.println("This shouldn't happen");
66+
return null;
67+
}
68+
69+
public static Detector getDetector(Laser l, String dname) {
70+
for (Detector d : l.detectors) {
71+
if (d.identifier.equals(dname)) {
72+
return d;
73+
}
74+
}
75+
System.out.println("This shouldn't happen");
76+
return null;
77+
}
78+
79+
public static List<SelectionInfo> getConfiguration(String[] row, int features, Map<String, Fluorophore> fpmap, Cytometer c) {
80+
int n = row.length / features;
81+
List<SelectionInfo> config = new ArrayList<SelectionInfo>();
82+
for (int i = 0; i < row.length-1; i += features) {
83+
Fluorophore fp = fpmap.get(row[i]);
84+
Laser l = getLaser(c, row[i + 1]);
85+
Detector d = getDetector(l, row[i + 2]);
86+
SelectionInfo si = new SelectionInfo();
87+
si.setSelectedFluorophore(fp);
88+
si.setSelectedLaser(l);
89+
si.setSelectedDetector(d);
90+
config.add(si);
91+
}
92+
93+
return config;
94+
}
95+
96+
private static List<Double> normalize(List<Double> vals) {
97+
double max = vals.get(0);
98+
for (Double d : vals) {
99+
if (d > max) {
100+
max = d;
101+
}
102+
}
103+
List<Double> norm = new ArrayList<Double>();
104+
for (Double d : vals) {
105+
if (max != 0)
106+
norm.add(d / max);
107+
else
108+
norm.add(d);
109+
}
110+
return norm;
111+
}
112+
113+
public static void printConfigSignals(List<SelectionInfo> config, String filefp) {
114+
115+
List<String> lines = new ArrayList<String>();
116+
117+
List<Fluorophore> fps = new ArrayList<Fluorophore>();
118+
String header = "";
119+
for (SelectionInfo si : config) {
120+
fps.add(si.getSelectedFluorophore());
121+
//header += ("," + si.getSelectedLaser().getName() + " (" + si.getSelectedDetector().identifier + ")");
122+
header += ("," + si.getSelectedFluorophore().name);
123+
}
124+
lines.add(header);
125+
126+
for (int i = 0; i < config.size(); i++) {
127+
SelectionInfo si = config.get(i);
128+
String configline = si.getSelectedLaser().getName() + " (" + si.getSelectedDetector().identifier + ")";
129+
130+
List<Double> sigs = new ArrayList<Double>();
131+
for (Fluorophore fp : fps) {
132+
sigs.add(fp.express(si.getSelectedLaser(), si.getSelectedDetector()));
133+
}
134+
for (Double d : normalize(sigs)) {
135+
configline += ("," + d);
136+
}
137+
lines.add(configline);
138+
}
139+
140+
Utilities.writeToFile(filefp, lines);
141+
142+
}
58143

59144
//Get Random set of fluorophores - Seeded
60145
private static List<Fluorophore> getRandomFluorophores(int n, List<Fluorophore> fluorophores,ThreadLocal<Random> threadrandom){

0 commit comments

Comments
 (0)