From c4f5bd0fd2a62e26da3c5ddbeea50b9ed36bbb68 Mon Sep 17 00:00:00 2001 From: Fengchao Date: Tue, 24 Apr 2018 09:51:45 +0800 Subject: [PATCH] Output some warnings regarding the "not enough data points" issue. --- src/main/java/proteomics/Validation/CalFDR.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/proteomics/Validation/CalFDR.java b/src/main/java/proteomics/Validation/CalFDR.java index ae18a89..071f7c9 100644 --- a/src/main/java/proteomics/Validation/CalFDR.java +++ b/src/main/java/proteomics/Validation/CalFDR.java @@ -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 calFDR(String sqlPath, boolean cal_evalue, String clType) throws SQLException { double min_score = 999; double max_score = -999; @@ -47,6 +52,10 @@ public static Map 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; @@ -71,6 +80,7 @@ public static Map 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; @@ -85,6 +95,7 @@ public static Map 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; @@ -94,6 +105,10 @@ public static Map 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;