diff --git a/BinaryMetaAnalyzer/src/main/java/nl/umcg/westrah/binarymetaanalyzer/BinaryMetaAnalysisSettings.java b/BinaryMetaAnalyzer/src/main/java/nl/umcg/westrah/binarymetaanalyzer/BinaryMetaAnalysisSettings.java index ad096869f..38b31c7a5 100644 --- a/BinaryMetaAnalyzer/src/main/java/nl/umcg/westrah/binarymetaanalyzer/BinaryMetaAnalysisSettings.java +++ b/BinaryMetaAnalyzer/src/main/java/nl/umcg/westrah/binarymetaanalyzer/BinaryMetaAnalysisSettings.java @@ -27,7 +27,7 @@ public String toString() { "useAbsoluteZscore\t" + useAbsoluteZscore + "\n" + "finalEQTLBufferMaxLength\t" + finalEQTLBufferMaxLength + "\n" + "includeSNPsWithoutProperMapping\t" + includeSNPsWithoutProperMapping + "\n" + - "includeProbesWithoutProperMapping\t" + includeProbesWithoutProperMapping + + "includeProbesWithoutProperMapping\t" + includeProbesWithoutProperMapping + "\n" + "analysisType\t" + analysisType + "\n" + "cisdistance\t" + cisdistance + "\n" + "transdistance\t" + transdistance + "\n" + @@ -45,6 +45,7 @@ public String toString() { "snpselection\t'" + snpselection + '\'' + "\n" + "snpprobeselection\t'" + snpprobeselection + '\'' + "\n" + "snpAnnotationFile\t'" + snpAnnotationFile + '\'' + "\n" + + "probeRescaling\t" + rescalingOfSampleSize + "\n" + "minimalNumberOfDatasets\t" + minimalNumberOfDatasets + "\n" + "debug\t" + debug + "\n" + "fullpermutationoutput\t" + fullpermutationoutput + "\n" + @@ -249,7 +250,6 @@ public void parse(String settings, String texttoreplace, String replacetextwith) } i++; } - summarize(); // parse datasets } catch (ConfigurationException e) { diff --git a/BinaryMetaAnalyzer/src/main/java/nl/umcg/westrah/binarymetaanalyzer/BinaryMetaAnalysisTask.java b/BinaryMetaAnalyzer/src/main/java/nl/umcg/westrah/binarymetaanalyzer/BinaryMetaAnalysisTask.java index 235cc752e..ef2d08ace 100644 --- a/BinaryMetaAnalyzer/src/main/java/nl/umcg/westrah/binarymetaanalyzer/BinaryMetaAnalysisTask.java +++ b/BinaryMetaAnalyzer/src/main/java/nl/umcg/westrah/binarymetaanalyzer/BinaryMetaAnalysisTask.java @@ -392,14 +392,21 @@ public Triple, String, String> call() { if (settings.getRescalingOfSampleSize()) { weights = new double[sampleSizes.length]; - for (int d = 0; d < datasetZScores.length; d++) { - Double rescaleValue = datasets[d].getFeatureOccuranceScaleMap().get(t.getPlatformIds()[d]); - if (!Double.isFinite(rescaleValue)) { - System.out.println("Warning for feature: " + t.getPlatformIds()[d] + " no rescale value set for: " + datasets[d].getName() + "\n Defaulted to weight of 1."); + for(int d=0; d, String, String> call() { if (!settings.getRescalingOfSampleSize()) { metaAnalysisZ = ZScores.getWeightedZ(datasetZScores, sampleSizes); } else { - metaAnalysisZ = ZScores.getWeightedZ(datasetZScores, sampleSizes, weights); + metaAnalysisZ = ZScores.getDatasetSizeWeightedZ(datasetZScores, sampleSizes, weights); } if (debug && traitList[probe].getMetaTraitName().equals("ENSG00000132465")) { diff --git a/GeneticRiskScoreCalculator/pom.xml b/GeneticRiskScoreCalculator/pom.xml index edce69ef4..8367dda9d 100644 --- a/GeneticRiskScoreCalculator/pom.xml +++ b/GeneticRiskScoreCalculator/pom.xml @@ -93,7 +93,7 @@ lib/ nl.systemsgenetics.simplegeneticriskscorecalculator.Main - + diff --git a/GeneticRiskScoreCalculator/src/main/java/nl/systemsgenetics/simplegeneticriskscorecalculator/Main.java b/GeneticRiskScoreCalculator/src/main/java/nl/systemsgenetics/simplegeneticriskscorecalculator/Main.java index 1c13856f8..1f0083854 100644 --- a/GeneticRiskScoreCalculator/src/main/java/nl/systemsgenetics/simplegeneticriskscorecalculator/Main.java +++ b/GeneticRiskScoreCalculator/src/main/java/nl/systemsgenetics/simplegeneticriskscorecalculator/Main.java @@ -54,7 +54,7 @@ public static void main(String[] args) { Option FileOut = OptionBuilder.withArgName("path").hasArg().withDescription("Location (folder) for the output.").withLongOpt("OutputFolder").create("o"); Option GenotypeTypeIn = OptionBuilder.withArgName("type").hasArg().withDescription("Type of reference data.").withLongOpt("GenotypeType").create("gt"); Option GenotypeIn = OptionBuilder.withArgName("path").hasArg().withDescription("Location for the reference data.").withLongOpt("GenotypeLocation").create("gi"); - Option InFolder = OptionBuilder.withArgName("path").hasArg().withDescription("Location of the folder with genetic risk score information.").withLongOpt("input").create("i"); + Option InFolder = OptionBuilder.withArgName("path").hasArg().withDescription("Location of the file/folder with genetic risk score information.").withLongOpt("input").create("i"); Option rSquared = OptionBuilder.withArgName("double").hasArg().withDescription("R2 for pruning.").withLongOpt("rSquared").create("r"); Option pValueThreshold = OptionBuilder.withArgName("double").hasArg().withDescription("P-value thresholds for genetic risk score inclusion, colon separated should be ordered from most stringent to least stringent.").withLongOpt("pValue").create("p"); Option WindowSize = OptionBuilder.withArgName("double").hasArg().withDescription("Window size for pruning, if given two window-sizes (colon separated), a two step window approach is used.").withLongOpt("wSize").create("w"); @@ -205,11 +205,17 @@ private static THashMap { diff --git a/Genotype-IO/src/test/java/org/molgenis/genotype/bgen/BgenGenotypeDataTest.java b/Genotype-IO/src/test/java/org/molgenis/genotype/bgen/BgenGenotypeDataTest.java index 47629451b..331e59640 100644 --- a/Genotype-IO/src/test/java/org/molgenis/genotype/bgen/BgenGenotypeDataTest.java +++ b/Genotype-IO/src/test/java/org/molgenis/genotype/bgen/BgenGenotypeDataTest.java @@ -441,3 +441,4 @@ public void TestBgenGenotypeDataBgenix() throws URISyntaxException, IOException } } } + diff --git a/genetica-libraries/src/main/java/umcg/genetica/math/stats/ZScores.java b/genetica-libraries/src/main/java/umcg/genetica/math/stats/ZScores.java index f5d0e33d0..a9954738d 100644 --- a/genetica-libraries/src/main/java/umcg/genetica/math/stats/ZScores.java +++ b/genetica-libraries/src/main/java/umcg/genetica/math/stats/ZScores.java @@ -105,6 +105,30 @@ public static double getWeightedZ(float[] zScores, int[] sampleSizes, double[] w return weightedZ; } + /** + * Calculates a weighted Z-score according to Whitlock's paper: + * http://www.ncbi.nlm.nih.gov/pubmed/16135132 Square root of the sample + * size is used as the weight for each test. + * + * @param zScores Z-scores from individual tests + * @param sampleSizes sample sizes of these tests + * @return + */ + public static double getDatasetSizeWeightedZ(float[] zScores, int[] sampleSizes, double[] weights) { + if (zScores.length != sampleSizes.length) { + throw new IllegalArgumentException("Zscores and sample sizes should have same length!"); + } + double weightedZ = 0; + double sampleSizeSum = 0; + for (int j = 0; j < zScores.length; j++) { + if (!Double.isNaN(zScores[j])) { + weightedZ += Math.sqrt(sampleSizes[j]* weights[j]) * zScores[j]; + sampleSizeSum += (sampleSizes[j] * weights[j]); + } + } + weightedZ /= Math.sqrt(sampleSizeSum); + return weightedZ; + } /** * Calculates a weighted Z-score according to Whitlock's paper: * http://www.ncbi.nlm.nih.gov/pubmed/16135132 Square root of the sample