private float CalcGoGeneSim(int go, List <int> geneGOSet, GOSimHelper goSimHelper) { var maxSim = float.MinValue; foreach (var geneGO in geneGOSet) { var sim = _useGSESAME ? goSimHelper.CalcGOSim_GSESAME(go, geneGO) : goSimHelper.CalcGOSim(go, geneGO); //6355,8150 = Infinity? if (maxSim < sim) { maxSim = (float)sim; } } return(maxSim); }
private double CalcSimOnDAG_HyperOrCount(string rna1, string rna2, GOSimHelper goSimHelper) { double sim = 0; int count = 0; var goSet1 = _miRNAs[rna1].GOs; var goSet2 = _miRNAs[rna2].GOs; var filteredGOSet1 = goSimHelper.FilterGOs(goSet1); var filteredGOSet2 = goSimHelper.FilterGOs(goSet2); if (filteredGOSet1.Count == 0 || filteredGOSet2.Count == 0) { return(0.0); } Dictionary <int, double> maxSimReverse = new Dictionary <int, double>(); foreach (var go in filteredGOSet2) { maxSimReverse[go] = double.MinValue; } foreach (var go in filteredGOSet1) { double wx = 0; if (_mode == Mode.Hyper) { wx = GetOrSetWeightCache(rna1, go, goSimHelper); } else { wx = _miRNAs[rna1].kGOAnnotatedCount[go]; count += _miRNAs[rna1].kGOAnnotatedCount[go]; } var maxSim = float.MinValue; foreach (var go2 in filteredGOSet2) { var sim2 = _useGSESAME ? goSimHelper.CalcGOSim_GSESAME(go, go2) : goSimHelper.CalcGOSim(go, go2); if (maxSim < sim2) { maxSim = (float)sim2; } if (maxSimReverse[go2] < sim2) { maxSimReverse[go2] = sim2; } } sim += wx * maxSim; } foreach (var go in filteredGOSet2) { double wx = 0; if (_mode == Mode.Hyper) { wx = GetOrSetWeightCache(rna2, go, goSimHelper); } else { wx = _miRNAs[rna2].kGOAnnotatedCount[go]; count += _miRNAs[rna2].kGOAnnotatedCount[go]; } sim += wx * maxSimReverse[go]; } return(sim / (_mode == Mode.Hyper ? (filteredGOSet1.Count + filteredGOSet2.Count) : count)); }
private double CalcSimOnDAG_Max(string rna1, string rna2, GOSimHelper goSimHelper) { double sim = 0; var goSet1 = _miRNAs[rna1].GOs; var goSet2 = _miRNAs[rna2].GOs; var filteredGOSet1 = goSimHelper.FilterGOs(goSet1); var filteredGOSet2 = goSimHelper.FilterGOs(goSet2); if (filteredGOSet1.Count == 0 || filteredGOSet2.Count == 0) { return(0.0); } foreach (var go in filteredGOSet1) { foreach (var go2 in filteredGOSet2) { var sim2 = _useGSESAME ? goSimHelper.CalcGOSim_GSESAME(go, go2) : goSimHelper.CalcGOSim(go, go2); if (sim < sim2) { sim = (float)sim2; } } } return(sim); }