Skip to content

Commit

Permalink
Output some warnings regarding the "not enough data points" issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
fcyu committed Apr 24, 2018
1 parent 142fbae commit c4f5bd0
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main/java/proteomics/Validation/CalFDR.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package proteomics.Validation;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.sql.*;
import java.util.*;

public class CalFDR {

private static final Logger logger = LoggerFactory.getLogger(CalFDR.class);

public static Map<String, Entry> calFDR(String sqlPath, boolean cal_evalue, String clType) throws SQLException {
double min_score = 999;
double max_score = -999;
Expand Down Expand Up @@ -47,6 +52,10 @@ public static Map<String, Entry> calFDR(String sqlPath, boolean cal_evalue, Stri
sqlStatement.close();
sqlConnection.close();

if (scanIdEntryMap.size() < 500) {
logger.warn("For {}, There are only {} hits in total, which is not enough to estimate an accurate FDR/q-value.", clType, scanIdEntryMap.size());
}

final int array_length = 1 + (int) Math.ceil((max_score - min_score) * inversePrecision);
if (array_length <= 0) { // there is no hit
return scanIdEntryMap;
Expand All @@ -71,6 +80,7 @@ public static Map<String, Entry> calFDR(String sqlPath, boolean cal_evalue, Stri
}

// Calculate FDR
boolean printWarning = false;
for (int idx_1 = 0; idx_1 < array_length - 1; ++idx_1) {
int decoy_count = 0;
int fuse_count = 0;
Expand All @@ -85,6 +95,7 @@ public static Map<String, Entry> calFDR(String sqlPath, boolean cal_evalue, Stri
if (target_count == 0) {
fdr = 0;
} else if (fuse_count < decoy_count) {
printWarning = true;
fdr = 0;
} else {
fdr = (double) (fuse_count - decoy_count) / (double) target_count;
Expand All @@ -94,6 +105,10 @@ public static Map<String, Entry> calFDR(String sqlPath, boolean cal_evalue, Stri
fdr_array[idx_1] = fdr;
}

if (printWarning) {
logger.warn("For {}, there are less T-D hits than D-D hits. The estimated FDR/q-value is not accurate.", clType);
}

// Convert FDR to qvalue
double last_q_value = fdr_array[0];
qvalue_array[0] = last_q_value;
Expand Down

0 comments on commit c4f5bd0

Please sign in to comment.