diff --git a/imadsconf.yaml b/imadsconf.yaml index ea629d4..53cfa5a 100644 --- a/imadsconf.yaml +++ b/imadsconf.yaml @@ -19,6 +19,8 @@ genome_data: family: bHLH fix_script: bigBedToBed name: c-Myc_0001 + preference_max: '' + preference_min: '' sort_max_guess: 0.6 type: PREDICTION url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-binding-predictions/hg19/hg19_0001_c-Myc.bb @@ -27,6 +29,8 @@ genome_data: family: bHLH fix_script: bigBedToBed name: Mad1_0002 + preference_max: '' + preference_min: '' sort_max_guess: 0.6 type: PREDICTION url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-binding-predictions/hg19/hg19_0002_Mad1.bb @@ -35,6 +39,8 @@ genome_data: family: bHLH fix_script: bigBedToBed name: Max_0003 + preference_max: '' + preference_min: '' sort_max_guess: 0.6 type: PREDICTION url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-binding-predictions/hg19/hg19_0003_Max.bb @@ -43,24 +49,8 @@ genome_data: family: bHLH fix_script: bigBedToBed name: Mad1_0002_vs_c-Myc_0001 - preference_bins: - neg: - - 2.92 - - 3.27 - - 3.64 - - 3.84 - - 3.91 - - 4.64 - - 4.66 - pos: - - 2.73 - - 2.89 - - 3.05 - - 3.23 - - 3.39 - - 3.58 - - 3.84 - - 4.22 + preference_max: 6.85 + preference_min: -12.14 sort_max_guess: 16 type: PREFERENCE url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-preferences//hg19/hg19_Mad1_0002_vs_c-Myc_0001.bb @@ -69,25 +59,8 @@ genome_data: family: bHLH fix_script: bigBedToBed name: Mad1_0002_vs_Max_0003 - preference_bins: - neg: - - 2.77 - - 2.98 - - 3.22 - - 3.54 - - 4.37 - - 5.45 - - 5.71 - - 6.07 - pos: - - 2.64 - - 2.74 - - 2.86 - - 3.0 - - 3.19 - - 3.3 - - 3.46 - - 3.63 + preference_max: 6.28 + preference_min: -7.43 sort_max_guess: 16 type: PREFERENCE url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-preferences//hg19/hg19_Mad1_0002_vs_Max_0003.bb @@ -96,25 +69,8 @@ genome_data: family: bHLH fix_script: bigBedToBed name: Max_0003_vs_c-Myc_0001 - preference_bins: - neg: - - 2.68 - - 2.79 - - 2.91 - - 3.05 - - 3.23 - - 3.42 - - 3.69 - - 4.13 - pos: - - 2.73 - - 2.88 - - 3.01 - - 3.18 - - 3.39 - - 3.63 - - 3.95 - - 4.43 + preference_max: 8.59 + preference_min: -8.24 sort_max_guess: 16 type: PREFERENCE url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-preferences//hg19/hg19_Max_0003_vs_c-Myc_0001.bb @@ -123,6 +79,8 @@ genome_data: family: ETS fix_script: bigBedToBed name: Elk1_0004 + preference_max: '' + preference_min: '' sort_max_guess: 0.8 type: PREDICTION url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-binding-predictions/hg19/hg19_0004_Elk1.bb @@ -131,6 +89,8 @@ genome_data: family: ETS fix_script: bigBedToBed name: Ets1_0005 + preference_max: '' + preference_min: '' sort_max_guess: 0.8 type: PREDICTION url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-binding-predictions/hg19/hg19_0005_Ets1.bb @@ -139,6 +99,8 @@ genome_data: family: ETS fix_script: bigBedToBed name: Gabpa_0006 + preference_max: '' + preference_min: '' sort_max_guess: 0.6 type: PREDICTION url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-binding-predictions/hg19/hg19_0006_Gabpa.bb @@ -147,25 +109,8 @@ genome_data: family: ETS fix_script: bigBedToBed name: Elk1_0004_vs_Ets1_0005 - preference_bins: - neg: - - 2.92 - - 3.29 - - 3.7 - - 4.15 - - 4.65 - - 5.25 - - 6.05 - - 7.33 - pos: - - 3.91 - - 5.19 - - 6.46 - - 7.79 - - 9.21 - - 10.57 - - 11.89 - - 13.54 + preference_max: 25.3 + preference_min: -17.24 sort_max_guess: 16 type: PREFERENCE url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-preferences//hg19/hg19_Elk1_0004_vs_Ets1_0005.bb @@ -174,25 +119,8 @@ genome_data: family: ETS fix_script: bigBedToBed name: Elk1_0004_vs_Gabpa_0006 - preference_bins: - neg: - - 2.9 - - 3.22 - - 3.57 - - 3.93 - - 4.34 - - 4.8 - - 5.43 - - 6.41 - pos: - - 3.08 - - 3.6 - - 4.11 - - 4.67 - - 5.24 - - 5.73 - - 6.35 - - 7.1 + preference_max: 15.66 + preference_min: -13.29 sort_max_guess: 16 type: PREFERENCE url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-preferences//hg19/hg19_Elk1_0004_vs_Gabpa_0006.bb @@ -201,25 +129,8 @@ genome_data: family: ETS fix_script: bigBedToBed name: Ets1_0005_vs_Gabpa_0006 - preference_bins: - neg: - - 2.96 - - 3.33 - - 3.73 - - 4.13 - - 4.59 - - 5.11 - - 5.77 - - 6.68 - pos: - - 3.12 - - 3.71 - - 4.38 - - 5.15 - - 6.06 - - 7.12 - - 8.36 - - 9.87 + preference_max: 15.85 + preference_min: -19.33 sort_max_guess: 16 type: PREFERENCE url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-preferences//hg19/hg19_Ets1_0005_vs_Gabpa_0006.bb @@ -228,6 +139,8 @@ genome_data: family: E2F fix_script: bigBedToBed name: E2f1_0007 + preference_max: '' + preference_min: '' sort_max_guess: 0.6 type: PREDICTION url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-binding-predictions/hg19/hg19_0007_E2f1.bb @@ -236,6 +149,8 @@ genome_data: family: E2F fix_script: bigBedToBed name: E2f3_0008 + preference_max: '' + preference_min: '' sort_max_guess: 0.75 type: PREDICTION url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-binding-predictions/hg19/hg19_0008_E2f3.bb @@ -244,6 +159,8 @@ genome_data: family: E2F fix_script: bigBedToBed name: E2f4_0009 + preference_max: '' + preference_min: '' sort_max_guess: 0.65 type: PREDICTION url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-binding-predictions/hg19/hg19_0009_E2f4.bb @@ -252,25 +169,8 @@ genome_data: family: E2F fix_script: bigBedToBed name: E2f1_0007_vs_E2f4_0009 - preference_bins: - neg: - - 2.75 - - 3.02 - - 3.31 - - 3.64 - - 4.08 - - 4.68 - - 5.5 - - 6.14 - pos: - - 2.86 - - 3.12 - - 3.41 - - 3.67 - - 3.95 - - 4.3 - - 4.73 - - 5.39 + preference_max: 9.88 + preference_min: -11.44 sort_max_guess: 16 type: PREFERENCE url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-preferences//hg19/hg19_E2f1_0007_vs_E2f4_0009.bb @@ -279,25 +179,8 @@ genome_data: family: E2F fix_script: bigBedToBed name: E2f1_0007_vs_E2f3_0008 - preference_bins: - neg: - - 2.94 - - 3.41 - - 3.84 - - 4.47 - - 4.92 - - 5.58 - - 6.48 - - 7.57 - pos: - - 2.77 - - 2.95 - - 3.14 - - 3.38 - - 3.66 - - 3.92 - - 4.29 - - 4.85 + preference_max: 9.59 + preference_min: -16.98 sort_max_guess: 16 type: PREFERENCE url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-preferences//hg19/hg19_E2f1_0007_vs_E2f3_0008.bb @@ -306,25 +189,8 @@ genome_data: family: E2F fix_script: bigBedToBed name: E2f3_0008_vs_E2f4_0009 - preference_bins: - neg: - - 2.71 - - 2.85 - - 3.04 - - 3.22 - - 3.4 - - 3.66 - - 4.08 - - 4.63 - pos: - - 2.71 - - 2.89 - - 3.07 - - 3.29 - - 3.58 - - 3.91 - - 4.36 - - 5.03 + preference_max: 8.33 + preference_min: -8.05 sort_max_guess: 16 type: PREFERENCE url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-preferences//hg19/hg19_E2f3_0008_vs_E2f4_0009.bb @@ -333,6 +199,8 @@ genome_data: family: RUNX fix_script: bigBedToBed name: Runx1_0010 + preference_max: '' + preference_min: '' sort_max_guess: 0.7 type: PREDICTION url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-binding-predictions/hg19/hg19_0010_Runx1.bb @@ -341,6 +209,8 @@ genome_data: family: RUNX fix_script: bigBedToBed name: Runx2_0011 + preference_max: '' + preference_min: '' sort_max_guess: 0.8 type: PREDICTION url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-binding-predictions/hg19/hg19_0011_Runx2.bb @@ -349,24 +219,8 @@ genome_data: family: RUNX fix_script: bigBedToBed name: Runx1_0010_vs_Runx2_0011 - preference_bins: - neg: - - 2.63 - - 2.7 - - 2.79 - - 2.84 - - 2.9 - - 3.25 - - 3.425 - pos: - - 2.6 - - 2.63 - - 2.66 - - 2.7 - - 2.74 - - 2.8 - - 2.84 - - 2.97 + preference_max: 4.36 + preference_min: -3.6 sort_max_guess: 16 type: PREFERENCE url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-preferences//hg19/hg19_Runx1_0010_vs_Runx2_0011.bb @@ -403,6 +257,8 @@ genome_data: family: bHLH fix_script: bigBedToBed name: c-Myc_0001 + preference_max: '' + preference_min: '' sort_max_guess: 0.6 type: PREDICTION url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-binding-predictions/hg38/hg38_0001_c-Myc.bb @@ -411,6 +267,8 @@ genome_data: family: bHLH fix_script: bigBedToBed name: Mad1_0002 + preference_max: '' + preference_min: '' sort_max_guess: 0.6 type: PREDICTION url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-binding-predictions/hg38/hg38_0002_Mad1.bb @@ -419,6 +277,8 @@ genome_data: family: bHLH fix_script: bigBedToBed name: Max_0003 + preference_max: '' + preference_min: '' sort_max_guess: 0.6 type: PREDICTION url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-binding-predictions/hg38/hg38_0003_Max.bb @@ -427,24 +287,8 @@ genome_data: family: bHLH fix_script: bigBedToBed name: Mad1_0002_vs_c-Myc_0001 - preference_bins: - neg: - - 2.92 - - 3.27 - - 3.64 - - 3.84 - - 3.91 - - 4.64 - - 4.66 - pos: - - 2.73 - - 2.89 - - 3.05 - - 3.23 - - 3.39 - - 3.58 - - 3.85 - - 4.22 + preference_max: 6.85 + preference_min: -12.14 sort_max_guess: 16 type: PREFERENCE url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-preferences//hg38/hg38_Mad1_0002_vs_c-Myc_0001.bb @@ -453,25 +297,8 @@ genome_data: family: bHLH fix_script: bigBedToBed name: Mad1_0002_vs_Max_0003 - preference_bins: - neg: - - 2.77 - - 2.98 - - 3.22 - - 3.53 - - 4.37 - - 5.45 - - 5.71 - - 6.07 - pos: - - 2.64 - - 2.74 - - 2.86 - - 3.01 - - 3.21 - - 3.32 - - 3.46 - - 3.63 + preference_max: 6.28 + preference_min: -7.43 sort_max_guess: 16 type: PREFERENCE url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-preferences//hg38/hg38_Mad1_0002_vs_Max_0003.bb @@ -480,25 +307,8 @@ genome_data: family: bHLH fix_script: bigBedToBed name: Max_0003_vs_c-Myc_0001 - preference_bins: - neg: - - 2.68 - - 2.79 - - 2.91 - - 3.06 - - 3.23 - - 3.42 - - 3.69 - - 4.14 - pos: - - 2.73 - - 2.88 - - 3.01 - - 3.19 - - 3.39 - - 3.63 - - 3.95 - - 4.43 + preference_max: 8.59 + preference_min: -8.24 sort_max_guess: 16 type: PREFERENCE url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-preferences//hg38/hg38_Max_0003_vs_c-Myc_0001.bb @@ -507,6 +317,8 @@ genome_data: family: ETS fix_script: bigBedToBed name: Elk1_0004 + preference_max: '' + preference_min: '' sort_max_guess: 0.8 type: PREDICTION url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-binding-predictions/hg38/hg38_0004_Elk1.bb @@ -515,6 +327,8 @@ genome_data: family: ETS fix_script: bigBedToBed name: Ets1_0005 + preference_max: '' + preference_min: '' sort_max_guess: 0.8 type: PREDICTION url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-binding-predictions/hg38/hg38_0005_Ets1.bb @@ -523,6 +337,8 @@ genome_data: family: ETS fix_script: bigBedToBed name: Gabpa_0006 + preference_max: '' + preference_min: '' sort_max_guess: 0.6 type: PREDICTION url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-binding-predictions/hg38/hg38_0006_Gabpa.bb @@ -531,25 +347,8 @@ genome_data: family: ETS fix_script: bigBedToBed name: Elk1_0004_vs_Ets1_0005 - preference_bins: - neg: - - 2.92 - - 3.29 - - 3.7 - - 4.16 - - 4.65 - - 5.25 - - 6.01 - - 7.24 - pos: - - 3.9 - - 5.18 - - 6.44 - - 7.76 - - 9.17 - - 10.53 - - 11.86 - - 13.51 + preference_max: 25.3 + preference_min: -17.24 sort_max_guess: 16 type: PREFERENCE url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-preferences//hg38/hg38_Elk1_0004_vs_Ets1_0005.bb @@ -558,25 +357,8 @@ genome_data: family: ETS fix_script: bigBedToBed name: Elk1_0004_vs_Gabpa_0006 - preference_bins: - neg: - - 2.91 - - 3.26 - - 3.62 - - 3.98 - - 4.39 - - 4.87 - - 5.58 - - 6.51 - pos: - - 3.08 - - 3.59 - - 4.1 - - 4.67 - - 5.23 - - 5.72 - - 6.35 - - 7.09 + preference_max: 15.66 + preference_min: -13.29 sort_max_guess: 16 type: PREFERENCE url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-preferences//hg38/hg38_Elk1_0004_vs_Gabpa_0006.bb @@ -585,25 +367,8 @@ genome_data: family: ETS fix_script: bigBedToBed name: Ets1_0005_vs_Gabpa_0006 - preference_bins: - neg: - - 2.97 - - 3.35 - - 3.76 - - 4.18 - - 4.62 - - 5.13 - - 5.77 - - 6.61 - pos: - - 3.12 - - 3.71 - - 4.38 - - 5.18 - - 6.1 - - 7.18 - - 8.4 - - 9.92 + preference_max: 15.85 + preference_min: -19.33 sort_max_guess: 16 type: PREFERENCE url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-preferences//hg38/hg38_Ets1_0005_vs_Gabpa_0006.bb @@ -612,6 +377,8 @@ genome_data: family: E2F fix_script: bigBedToBed name: E2f1_0007 + preference_max: '' + preference_min: '' sort_max_guess: 0.6 type: PREDICTION url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-binding-predictions/hg38/hg38_0007_E2f1.bb @@ -620,6 +387,8 @@ genome_data: family: E2F fix_script: bigBedToBed name: E2f3_0008 + preference_max: '' + preference_min: '' sort_max_guess: 0.75 type: PREDICTION url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-binding-predictions/hg38/hg38_0008_E2f3.bb @@ -628,6 +397,8 @@ genome_data: family: E2F fix_script: bigBedToBed name: E2f4_0009 + preference_max: '' + preference_min: '' sort_max_guess: 0.65 type: PREDICTION url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-binding-predictions/hg38/hg38_0009_E2f4.bb @@ -636,25 +407,8 @@ genome_data: family: E2F fix_script: bigBedToBed name: E2f1_0007_vs_E2f4_0009 - preference_bins: - neg: - - 2.75 - - 3.02 - - 3.31 - - 3.64 - - 4.08 - - 4.67 - - 5.49 - - 6.14 - pos: - - 2.87 - - 3.14 - - 3.44 - - 3.67 - - 3.95 - - 4.31 - - 4.76 - - 5.39 + preference_max: 9.88 + preference_min: -11.44 sort_max_guess: 16 type: PREFERENCE url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-preferences//hg38/hg38_E2f1_0007_vs_E2f4_0009.bb @@ -663,25 +417,8 @@ genome_data: family: E2F fix_script: bigBedToBed name: E2f1_0007_vs_E2f3_0008 - preference_bins: - neg: - - 2.94 - - 3.42 - - 3.85 - - 4.5 - - 4.92 - - 5.64 - - 6.49 - - 7.58 - pos: - - 2.76 - - 2.95 - - 3.13 - - 3.36 - - 3.65 - - 3.92 - - 4.29 - - 4.85 + preference_max: 9.59 + preference_min: -16.98 sort_max_guess: 16 type: PREFERENCE url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-preferences//hg38/hg38_E2f1_0007_vs_E2f3_0008.bb @@ -690,25 +427,8 @@ genome_data: family: E2F fix_script: bigBedToBed name: E2f3_0008_vs_E2f4_0009 - preference_bins: - neg: - - 2.71 - - 2.85 - - 3.03 - - 3.21 - - 3.39 - - 3.65 - - 4.07 - - 4.63 - pos: - - 2.71 - - 2.87 - - 3.04 - - 3.26 - - 3.54 - - 3.87 - - 4.3 - - 4.98 + preference_max: 8.33 + preference_min: -8.05 sort_max_guess: 16 type: PREFERENCE url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-preferences//hg38/hg38_E2f3_0008_vs_E2f4_0009.bb @@ -717,6 +437,8 @@ genome_data: family: RUNX fix_script: bigBedToBed name: Runx1_0010 + preference_max: '' + preference_min: '' sort_max_guess: 0.7 type: PREDICTION url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-binding-predictions/hg38/hg38_0010_Runx1.bb @@ -725,6 +447,8 @@ genome_data: family: RUNX fix_script: bigBedToBed name: Runx2_0011 + preference_max: '' + preference_min: '' sort_max_guess: 0.8 type: PREDICTION url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-binding-predictions/hg38/hg38_0011_Runx2.bb @@ -733,24 +457,8 @@ genome_data: family: RUNX fix_script: bigBedToBed name: Runx1_0010_vs_Runx2_0011 - preference_bins: - neg: - - 2.63 - - 2.7 - - 2.79 - - 2.84 - - 2.9 - - 3.25 - - 3.425 - pos: - - 2.6 - - 2.63 - - 2.66 - - 2.7 - - 2.74 - - 2.8 - - 2.84 - - 2.97 + preference_max: 4.36 + preference_min: -3.6 sort_max_guess: 16 type: PREFERENCE url: http://trackhub.genome.duke.edu/gordanlab/tf-dna-preferences//hg38/hg38_Runx1_0010_vs_Runx2_0011.bb diff --git a/portal/src/app/models/ColorBlender.js b/portal/src/app/models/ColorBlender.js index bee34bc..348a0a2 100644 --- a/portal/src/app/models/ColorBlender.js +++ b/portal/src/app/models/ColorBlender.js @@ -15,14 +15,12 @@ COLOR_RGB[GREEN_COLOR_NAME] = [0, 128, 0]; COLOR_RGB[BLUE_COLOR_NAME] = [0, 0, 255]; // PREFERENCE_COLORS based on https://github.com/Duke-GCB/TrackHubGenerator/blob/master/cwl/bin/add_itemrgb_column.py -export let PREFERENCE_GRAY = [190, 190, 190]; -// The preferred length of a preference array. -export let PREFERRED_PREFERENCE_ARRAY_LENGTH = 9; +let PREFERENCE_GRAY = [190, 190, 190]; /** * Color constants for Red gradient * From Colorbrewer Red 9 http://colorbrewer2.org/?type=sequential&scheme=Reds&n=9 */ -export let PREFERENCE_REDS = [ +let PREFERENCE_REDS = [ [255, 245, 240], [254, 224, 210], [252, 187, 161], @@ -35,14 +33,15 @@ export let PREFERENCE_REDS = [ ]; /* - * Color constants for blue gradient - * Converted to RGB from R Color names - * plotclr2 = c("midnightblue","steelblue4","steelblue","steelblue3","steelblue2","steelblue1") - * using chart at http://research.stowers-institute.org/efg/R/Color/Chart/ColorChart.pdf - * midnightblue is the darkest, should be associated with the highest value, - * and therefore be last. - */ -export let PREFERENCE_BLUES = [ +# Color constants for blue gradient +# Converted to RGB from R Color names +# plotclr2 = c("midnightblue","steelblue4","steelblue","steelblue3","steelblue2","steelblue1") +# using chart at http://research.stowers-institute.org/efg/R/Color/Chart/ColorChart.pdf + +# midnightblue is the darkest, should be associated with the highest value, +# and therefore be last. +*/ +let PREFERENCE_BLUES = [ [99, 184, 255], // steelblue1 [92, 172, 238], // steelblue2 [79, 148, 205], // steelblue3 @@ -55,7 +54,7 @@ export let PREFERENCE_BLUES = [ * Color constants for green gradient * http://colorbrewer2.org/?type=sequential&scheme=Reds&n=9#type=sequential&scheme=Greens&n=9 */ -export let PREFERENCE_GREENS = [ +let PREFERENCE_GREENS = [ [247,252,245], [229,245,224], [199,233,192], @@ -91,67 +90,21 @@ export default class ColorBlender { } } - /** - * Using this.value and the preferenceBin array determine which color slot we should show. - * @returns {number} integer 0 -> bins.length - */ - getPreferenceSlot() { - let bins = this.getPreferenceBin(); - let slot = 0; // if greater than all bins must be the last slot - let absValue = Math.abs(this.value); - for (let i = 0; i < bins.length; i++) { - let binValue = Math.abs(bins[i]); - if (binValue > absValue) { - break; - } - slot = i + 1; - } - return slot; - } - - /** - * Return array of inner fenceposts used to determine which slot in color arrays we should use. - * If you have three colors ...-1, 1-10, 10-... it returns an array like so: [1, 10] - * Anything below the lowest number is assumed to be the first bin anything greater than the - * last fencepost is assumed to be the last bin. - * @returns array of inner fencepost cutoff values - */ - getPreferenceBin() { + getScaledValue() { if (this.isNegative()) { - return this.predictionColor.preferenceBins.neg; + return ColorBlender.scaleValue(this.value, this.predictionColor.preferenceMin); } else { - return this.predictionColor.preferenceBins.pos; + return ColorBlender.scaleValue(this.value, this.predictionColor.preferenceMax); } } - /** - * Return array of r,g,b values for this.value. - * @param colorName determines which color array to use eg: 'red' - * @returns array of r g b - */ - getPreferenceColorArray(colorName) { - let slot = this.getPreferenceSlot(); - let colorArray = PREF_ARRAY_LOOKUP[colorName]; - if (colorArray.length != PREFERRED_PREFERENCE_ARRAY_LENGTH) { - slot = this.scalePreferenceSlot(slot, colorArray.length); + static scaleValue(value, limitValue) { + if (limitValue) { + return value / Math.abs(limitValue); } - return colorArray[slot]; + return value; } - /** - * Return array of r,g,b values for this.value. - * @param colorName determines which color array to use eg: 'red' - * @returns array of r g b - */ - scalePreferenceSlot(slot, arrayLength) { - let scaleFactor = parseFloat(arrayLength) / parseFloat(PREFERRED_PREFERENCE_ARRAY_LENGTH); - let scaledSlot = slot * scaleFactor; - return Math.round(scaledSlot); - } - - /** - * Return CSS color string appropriate for this.value and color settings. - */ getColor() { let colorName = this.determineColorName(); if (this.isPreference) { @@ -159,31 +112,30 @@ export default class ColorBlender { } let colorRGB = COLOR_RGB[colorName]; let zeroColor = [255, 255, 255]; - let colorValues = ColorBlender.interpolateRGB(zeroColor, colorRGB, this.value); + let colorValues = ColorBlender.interpolateRGB(zeroColor, colorRGB, this.getScaledValue()); return this.getRGBString(colorValues); } - /** - * Returns an array of color values based on colorPreference.color1/2 and this.value being postitive or neg. - * @returns array of colors(array) - */ getPreferenceArray() { let colorName = this.determineColorName(); return PREF_ARRAY_LOOKUP[colorName]; } - /** - * Returns CSS color "rgb(r,g,b)" for this.value. - * Looks up which array to use based on colorName. - * Determines which slot in the array to use based on preferenceBins. - * @param colorName name of the color array to use eg: 'red' - * @returns CSS color string - */ getPreferenceColor(colorName) { - let value = this.value; + let value = this.getScaledValue(); let colorRGB = PREFERENCE_GRAY; if (value > POS_FLOAT_CUTOOFF || value < NEG_FLOAT_CUTOOFF) { - colorRGB = this.getPreferenceColorArray(colorName); + let gradientArray = this.getPreferenceArray(); + let slots = ColorBlender.determineSlots(value, gradientArray.length); + colorRGB = gradientArray[slots[0]]; + if (slots[0] != slots[1]) { + let zeroColor = gradientArray[slots[0]]; + let oneColor = gradientArray[slots[1]]; + //need to scale value for the two slots + let slotScaledValue = ColorBlender.scaleValueForSlot(slots[0], gradientArray.length, value); + let blendedColor = ColorBlender.interpolateRGB(zeroColor, oneColor, slotScaledValue); + return this.getRGBString(blendedColor); + } } return this.getRGBString({ 'r': colorRGB[0], diff --git a/portal/src/app/models/GenomeData.js b/portal/src/app/models/GenomeData.js index cd44192..98da0aa 100644 --- a/portal/src/app/models/GenomeData.js +++ b/portal/src/app/models/GenomeData.js @@ -20,7 +20,8 @@ export function getPreferenceSettings(genomeData, genomeName, modelName) { if (modelObj.data_type == PREFERENCE_TYPE) { return { isPreference: true, - preferenceBins: modelObj.preference_bins, + preferenceMin: modelObj.preference_min, + preferenceMax: modelObj.preference_max, } } } diff --git a/portal/src/tests/testColorBlender.js b/portal/src/tests/testColorBlender.js index 771f4d7..a8d37ed 100644 --- a/portal/src/tests/testColorBlender.js +++ b/portal/src/tests/testColorBlender.js @@ -1,12 +1,7 @@ import ColorBlender, {RED_COLOR_NAME, GREEN_COLOR_NAME, BLUE_COLOR_NAME, YELLOW_COLOR_NAME, - CYAN_COLOR_NAME, MAGENTA_COLOR_NAME, - PREFERENCE_GRAY, PREFERENCE_REDS, PREFERENCE_BLUES, PREFERENCE_GREENS} from './../app/models/ColorBlender.js'; + CYAN_COLOR_NAME, MAGENTA_COLOR_NAME} from './../app/models/ColorBlender.js'; var assert = require('chai').assert; -function rgbFromArray(items) { - return 'rgb(' + items[0] + ',' + items[1] + ',' + items[2] + ')'; -} - describe('ColorBlender', function () { describe('isNegative()', function () { it('true for values < 0', function () { @@ -31,103 +26,22 @@ describe('ColorBlender', function () { }); }); - describe('getPreferenceSlot()', function () { - it('works with two bins', function () { - let predictionColor = { - 'preferenceBins': { - 'pos': [2], - 'neg': [4] - } - }; - assert.equal(0, new ColorBlender(1.0, predictionColor).getPreferenceSlot()); - assert.equal(0, new ColorBlender(1.99, predictionColor).getPreferenceSlot()); - assert.equal(1, new ColorBlender(2.0, predictionColor).getPreferenceSlot()); - assert.equal(1, new ColorBlender(3.0, predictionColor).getPreferenceSlot()); - assert.equal(1, new ColorBlender(200.0, predictionColor).getPreferenceSlot()); - assert.equal(0, new ColorBlender(-1.0, predictionColor).getPreferenceSlot()); - assert.equal(0, new ColorBlender(-3.99, predictionColor).getPreferenceSlot()); - assert.equal(1, new ColorBlender(-4, predictionColor).getPreferenceSlot()); - assert.equal(1, new ColorBlender(-4.1, predictionColor).getPreferenceSlot()); - assert.equal(1, new ColorBlender(-4000.0, predictionColor).getPreferenceSlot()); - }); - it('works with three bins', function () { - let predictionColor = { - 'preferenceBins': { - 'pos': [1,8], - 'neg': [2,6] - } - }; - assert.equal(0, new ColorBlender(0.1, predictionColor).getPreferenceSlot()); - assert.equal(1, new ColorBlender(1.0, predictionColor).getPreferenceSlot()); - assert.equal(1, new ColorBlender(1.1, predictionColor).getPreferenceSlot()); - assert.equal(1, new ColorBlender(7.9, predictionColor).getPreferenceSlot()); - assert.equal(2, new ColorBlender(8.0, predictionColor).getPreferenceSlot()); - assert.equal(2, new ColorBlender(8.1, predictionColor).getPreferenceSlot()); - assert.equal(2, new ColorBlender(100, predictionColor).getPreferenceSlot()); - - assert.equal(0, new ColorBlender(-0.1, predictionColor).getPreferenceSlot()); - assert.equal(0, new ColorBlender(-1.9, predictionColor).getPreferenceSlot()); - assert.equal(1, new ColorBlender(-2.0, predictionColor).getPreferenceSlot()); - assert.equal(1, new ColorBlender(-2.1, predictionColor).getPreferenceSlot()); - assert.equal(1, new ColorBlender(-5.9, predictionColor).getPreferenceSlot()); - assert.equal(2, new ColorBlender(-6.0, predictionColor).getPreferenceSlot()); - assert.equal(2, new ColorBlender(-6.1, predictionColor).getPreferenceSlot()); - assert.equal(2, new ColorBlender(-100.0, predictionColor).getPreferenceSlot()); - }); - it('works with four bins', function () { - let predictionColor = { - 'preferenceBins': { - 'pos': [1, 8, 10], - 'neg': [2, 6, 20] - } - }; - assert.equal(0, new ColorBlender(0.1, predictionColor).getPreferenceSlot()); - assert.equal(1, new ColorBlender(1.0, predictionColor).getPreferenceSlot()); - assert.equal(1, new ColorBlender(1.1, predictionColor).getPreferenceSlot()); - assert.equal(1, new ColorBlender(7.9, predictionColor).getPreferenceSlot()); - assert.equal(2, new ColorBlender(8.0, predictionColor).getPreferenceSlot()); - assert.equal(2, new ColorBlender(8.1, predictionColor).getPreferenceSlot()); - assert.equal(3, new ColorBlender(10, predictionColor).getPreferenceSlot()); - assert.equal(3, new ColorBlender(11, predictionColor).getPreferenceSlot()); - - assert.equal(0, new ColorBlender(-0.1, predictionColor).getPreferenceSlot()); - assert.equal(0, new ColorBlender(-1.9, predictionColor).getPreferenceSlot()); - assert.equal(1, new ColorBlender(-2.0, predictionColor).getPreferenceSlot()); - assert.equal(1, new ColorBlender(-2.1, predictionColor).getPreferenceSlot()); - assert.equal(1, new ColorBlender(-5.9, predictionColor).getPreferenceSlot()); - assert.equal(2, new ColorBlender(-6.0, predictionColor).getPreferenceSlot()); - assert.equal(2, new ColorBlender(-6.1, predictionColor).getPreferenceSlot()); - assert.equal(2, new ColorBlender(-19.9, predictionColor).getPreferenceSlot()); - assert.equal(3, new ColorBlender(-20.0, predictionColor).getPreferenceSlot()); - assert.equal(3, new ColorBlender(-30.0, predictionColor).getPreferenceSlot()); + describe('getScaledValue()', function () { + it('just returns value when no preferenceMin or preferenceMax', function () { + let predictionColor = {}; + assert.equal(10, new ColorBlender(10, predictionColor).getScaledValue()); + assert.equal(-10, new ColorBlender(-10, predictionColor).getScaledValue()); }); - }); - - describe('getPreferenceColorArray()', function () { - it('looks up red colors', function () { + it('just scales value with abs preferenceMin/preferenceMax based on negative/positive values', function () { let predictionColor = { - 'preferenceBins': { - 'pos': [1, 8, 10], - 'neg': [2, 6, 20] - } + preferenceMax: 2, + preferenceMin: -5, }; - let color = RED_COLOR_NAME; - let colorArray = PREFERENCE_REDS; - assert.equal(colorArray[0], new ColorBlender(0, predictionColor).getPreferenceColorArray(color)); - assert.equal(colorArray[1], new ColorBlender(1.1, predictionColor).getPreferenceColorArray(color)); - assert.equal(colorArray[1], new ColorBlender(7, predictionColor).getPreferenceColorArray(color)); - assert.equal(colorArray[2], new ColorBlender(8, predictionColor).getPreferenceColorArray(color)); - assert.equal(colorArray[3], new ColorBlender(11, predictionColor).getPreferenceColorArray(color)); - assert.equal(colorArray[0], new ColorBlender(-0.1, predictionColor).getPreferenceColorArray(color)); - assert.equal(colorArray[0], new ColorBlender(-1.9, predictionColor).getPreferenceColorArray(color)); - assert.equal(colorArray[1], new ColorBlender(-2, predictionColor).getPreferenceColorArray(color)); - assert.equal(colorArray[2], new ColorBlender(-6, predictionColor).getPreferenceColorArray(color)); - assert.equal(colorArray[3], new ColorBlender(-20, predictionColor).getPreferenceColorArray(color)); - + assert.equal(5, new ColorBlender(10, predictionColor).getScaledValue()); + assert.equal(-2, new ColorBlender(-10, predictionColor).getScaledValue()); }); }); - describe('getColor()', function () { it('works for red and blue combination for prediction data', function () { let predictionColor = { @@ -143,41 +57,19 @@ describe('ColorBlender', function () { assert.equal('rgb(128,128,255)', new ColorBlender(-0.5, predictionColor, false).getColor()); }); - it('works for red and blue combination for preference data', function () { let predictionColor = { color1: RED_COLOR_NAME, color2: BLUE_COLOR_NAME, - 'preferenceBins': { - 'pos': [1, 8, 10], - 'neg': [2, 6, 20] - } }; - let expectedColor = rgbFromArray(PREFERENCE_GRAY); - assert.equal(expectedColor, new ColorBlender(0, predictionColor, true).getColor()); + let deepRed = 'rgb(103,0,13)'; + assert.equal(deepRed, new ColorBlender(1.0, predictionColor, true).getColor()); - expectedColor = rgbFromArray(PREFERENCE_REDS[0]); - assert.equal(expectedColor, new ColorBlender(0.1, predictionColor, true).getColor()); - expectedColor = rgbFromArray(PREFERENCE_REDS[0]); - assert.equal(expectedColor, new ColorBlender(0.9, predictionColor, true).getColor()); - expectedColor = rgbFromArray(PREFERENCE_REDS[1]); - assert.equal(expectedColor, new ColorBlender(1.0, predictionColor, true).getColor()); - expectedColor = rgbFromArray(PREFERENCE_REDS[2]); - assert.equal(expectedColor, new ColorBlender(8.0, predictionColor, true).getColor()); - expectedColor = rgbFromArray(PREFERENCE_REDS[3]); - assert.equal(expectedColor, new ColorBlender(11.0, predictionColor, true).getColor()); + let zeroGray = 'rgb(190,190,190)'; + assert.equal(zeroGray, new ColorBlender(0.0, predictionColor, true).getColor()); - // blues have only 5 items in the color array so slot index will be scaled by PREFERRED_PREFERENCE_ARRAY_LENGTH - expectedColor = rgbFromArray(PREFERENCE_BLUES[0]); - assert.equal(expectedColor, new ColorBlender(-0.1, predictionColor, true).getColor()); - expectedColor = rgbFromArray(PREFERENCE_BLUES[1]); - assert.equal(expectedColor, new ColorBlender(-2.1, predictionColor, true).getColor()); - expectedColor = rgbFromArray(PREFERENCE_BLUES[1]); - assert.equal(expectedColor, new ColorBlender(-6.0, predictionColor, true).getColor()); - expectedColor = rgbFromArray(PREFERENCE_BLUES[2]); - assert.equal(expectedColor, new ColorBlender(-20.0, predictionColor, true).getColor()); - expectedColor = rgbFromArray(PREFERENCE_BLUES[2]); - assert.equal(expectedColor, new ColorBlender(-40.0, predictionColor, true).getColor()); + let midnightBlue = 'rgb(25,25,112)'; + assert.equal(midnightBlue, new ColorBlender(-1.0, predictionColor, true).getColor()); }); }); diff --git a/pred/config.py b/pred/config.py index 8037dfc..33cea87 100644 --- a/pred/config.py +++ b/pred/config.py @@ -154,12 +154,13 @@ def _load_prediction_lists(self, prediction_data_ary): fix_script = prediction_data['fix_script'] sort_max_guess = prediction_data['sort_max_guess'] type = prediction_data.get('type', 'PREDICTION') - preference_bins = prediction_data.get('preference_bins', None) + preference_min = prediction_data.get('preference_min', None) + preference_max = prediction_data.get('preference_max', None) core_offset = prediction_data.get('core_offset', None) core_length = prediction_data.get('core_length', None) family = prediction_data.get('family', None) prediction = PredictionSettings(name, url, self.genomename, fix_script, sort_max_guess, type, - preference_bins, core_offset, core_length, family) + preference_min, preference_max, core_offset, core_length, family) self.prediction_lists.append(prediction) def get_model_types_str(self): @@ -178,7 +179,7 @@ def __init__(self, genome, name, source_table, common_name, common_lookup_table= class PredictionSettings(object): - def __init__(self, name, url, genome, fix_script, sort_max_guess, data_type, preference_bins, + def __init__(self, name, url, genome, fix_script, sort_max_guess, data_type, preference_min, preference_max, core_offset, core_length, family): self.name = name self.url = url @@ -186,7 +187,8 @@ def __init__(self, name, url, genome, fix_script, sort_max_guess, data_type, pre self.fix_script = fix_script self.sort_max_guess = sort_max_guess self.data_type = data_type - self.preference_bins = preference_bins + self.preference_min = preference_min + self.preference_max = preference_max self.core_offset = core_offset self.core_length = core_length self.family = family @@ -199,7 +201,8 @@ def get_data(self): return { 'name': self.name, 'data_type': self.data_type, - 'preference_bins': self.preference_bins, + 'preference_min': self.preference_min, + 'preference_max': self.preference_max, 'core_offset': self.core_offset, 'core_length': self.core_length, 'family': self.family diff --git a/pred/queries/predictionqueryparts.py b/pred/queries/predictionqueryparts.py index 7604f06..ca20fc8 100644 --- a/pred/queries/predictionqueryparts.py +++ b/pred/queries/predictionqueryparts.py @@ -1,6 +1,9 @@ from pred.queries.querybuilder import QueryPart +RANGE_OPERATOR = '@>' # contains range - excludes predictions not completely inside gene TSS range + + def _query_part(sql): return QueryPart(sql, []) @@ -26,11 +29,11 @@ def custom_range_list_query(list_id, model_name): from custom_range_list left outer join prediction on prediction.chrom = custom_range_list.chrom -and custom_range_list.range && prediction.range +and custom_range_list.range {} prediction.range and model_name = %s where custom_range_list.id = %s -group by seq""", [model_name, list_id]) +group by seq""".format(RANGE_OPERATOR), [model_name, list_id]) def select_prediction_values(table_name="gene_prediction", first_field="common_name"): @@ -80,10 +83,10 @@ def filter_gene_list(gene_list, model_name, upstream, downstream): return QueryPart(beginning_sql + """model_name = %s and case strand when '+' then - (gene_begin + %s) >= start_range and end_range >= (gene_begin - %s) + int4range(gene_begin - %s, gene_begin + %s) {} int4range(start_range, end_range) else - (gene_begin + %s) >= start_range and end_range >= (gene_begin - %s) -end""", params) + int4range(gene_begin - %s, gene_begin + %s) {} int4range(start_range, end_range) +end""".format(RANGE_OPERATOR, RANGE_OPERATOR), params) def items_not_in_gene_list(list_id, gene_list_filter, custom_gene_name_type): diff --git a/tests/test_genelistquery.py b/tests/test_genelistquery.py index 2fa3eab..c240c3a 100644 --- a/tests/test_genelistquery.py +++ b/tests/test_genelistquery.py @@ -22,9 +22,9 @@ model_name = %s and case strand when '+' then - (gene_begin + %s) >= start_range and end_range >= (gene_begin - %s) + int4range(gene_begin - %s, gene_begin + %s) @> int4range(start_range, end_range) else - (gene_begin + %s) >= start_range and end_range >= (gene_begin - %s) + int4range(gene_begin - %s, gene_begin + %s) @> int4range(start_range, end_range) end where id = %s @@ -55,9 +55,9 @@ model_name = %s and case strand when '+' then - (gene_begin + %s) >= start_range and end_range >= (gene_begin - %s) + int4range(gene_begin - %s, gene_begin + %s) @> int4range(start_range, end_range) else - (gene_begin + %s) >= start_range and end_range >= (gene_begin - %s) + int4range(gene_begin - %s, gene_begin + %s) @> int4range(start_range, end_range) end where id = %s diff --git a/tests/test_integration.py b/tests/test_integration.py index 98f3a97..7ed3c1b 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -215,7 +215,6 @@ def test_prediction_query(self): self.assertEqual(len(values), 3) pred_value_set = set([v['value'] for v in values]) self.assertIn(0.4, pred_value_set) - self.assertIn(0.3, pred_value_set) self.assertIn(0.1, pred_value_set) def test_prediction_max_sort_query(self): @@ -238,7 +237,6 @@ def test_prediction_max_sort_query(self): self.assertEqual(len(values), 3) pred_value_set = set([v['value'] for v in values]) self.assertIn(0.4, pred_value_set) - self.assertIn(0.3, pred_value_set) self.assertIn(0.1, pred_value_set) def test_custom_gene_list_no_results(self): @@ -315,7 +313,7 @@ def test_custom_gene_list_with_lc_results(self): def test_custom_range_list(self): db = create_db_connection(TestWithPostgres.config.dbconfig) - custom_list_key = save_custom_file(db, 'john', RANGE_TYPE, "chr1 11873 11883") + custom_list_key = save_custom_file(db, 'john', RANGE_TYPE, "chr1 11873 11895") params = { SearchArgs.GENE_LIST: CUSTOM_RANGES_LIST, SearchArgs.CUSTOM_LIST_DATA: custom_list_key, @@ -348,7 +346,7 @@ def test_custom_range_list_bad_range(self): def test_custom_range_list_no_chr(self): db = create_db_connection(TestWithPostgres.config.dbconfig) - custom_list_key = save_custom_file(db, 'john', RANGE_TYPE, "1 11873 11883") + custom_list_key = save_custom_file(db, 'john', RANGE_TYPE, "1 11873 11895") params = { SearchArgs.GENE_LIST: CUSTOM_RANGES_LIST, SearchArgs.CUSTOM_LIST_DATA: custom_list_key, diff --git a/tests/test_maxpredictionquery.py b/tests/test_maxpredictionquery.py index 8c5c873..412483b 100644 --- a/tests/test_maxpredictionquery.py +++ b/tests/test_maxpredictionquery.py @@ -10,9 +10,9 @@ model_name = %s and case strand when '+' then - (gene_begin + %s) >= start_range and end_range >= (gene_begin - %s) + int4range(gene_begin - %s, gene_begin + %s) @> int4range(start_range, end_range) else - (gene_begin + %s) >= start_range and end_range >= (gene_begin - %s) + int4range(gene_begin - %s, gene_begin + %s) @> int4range(start_range, end_range) end{} group by gene_id order by max(abs(value)) desc{} @@ -36,9 +36,9 @@ model_name = %s and case strand when '+' then - (gene_begin + %s) >= start_range and end_range >= (gene_begin - %s) + int4range(gene_begin - %s, gene_begin + %s) @> int4range(start_range, end_range) else - (gene_begin + %s) >= start_range and end_range >= (gene_begin - %s) + int4range(gene_begin - %s, gene_begin + %s) @> int4range(start_range, end_range) end and gene_id in (select gene_id from max_prediction_names) group by gene_id @@ -58,9 +58,9 @@ model_name = %s and case strand when '+' then - (gene_begin + %s) >= start_range and end_range >= (gene_begin - %s) + int4range(gene_begin - %s, gene_begin + %s) @> int4range(start_range, end_range) else - (gene_begin + %s) >= start_range and end_range >= (gene_begin - %s) + int4range(gene_begin - %s, gene_begin + %s) @> int4range(start_range, end_range) end group by gene_id order by max(abs(value)) desc @@ -85,9 +85,9 @@ model_name = %s and case strand when '+' then - (gene_begin + %s) >= start_range and end_range >= (gene_begin - %s) + int4range(gene_begin - %s, gene_begin + %s) @> int4range(start_range, end_range) else - (gene_begin + %s) >= start_range and end_range >= (gene_begin - %s) + int4range(gene_begin - %s, gene_begin + %s) @> int4range(start_range, end_range) end and gene_id in (select gene_id from max_prediction_names) group by gene_id diff --git a/tests/test_predictionquery.py b/tests/test_predictionquery.py index 48505a9..a207664 100644 --- a/tests/test_predictionquery.py +++ b/tests/test_predictionquery.py @@ -21,9 +21,9 @@ model_name = %s and case strand when '+' then - (gene_begin + %s) >= start_range and end_range >= (gene_begin - %s) + int4range(gene_begin - %s, gene_begin + %s) @> int4range(start_range, end_range) else - (gene_begin + %s) >= start_range and end_range >= (gene_begin - %s) + int4range(gene_begin - %s, gene_begin + %s) @> int4range(start_range, end_range) end group by gene_id order by gene_id{}""" @@ -52,9 +52,9 @@ model_name = %s and case strand when '+' then - (gene_begin + %s) >= start_range and end_range >= (gene_begin - %s) + int4range(gene_begin - %s, gene_begin + %s) @> int4range(start_range, end_range) else - (gene_begin + %s) >= start_range and end_range >= (gene_begin - %s) + int4range(gene_begin - %s, gene_begin + %s) @> int4range(start_range, end_range) end group by gene_id ) as foo""" diff --git a/tests/test_rangelistquery.py b/tests/test_rangelistquery.py index 95d008f..569ec44 100644 --- a/tests/test_rangelistquery.py +++ b/tests/test_rangelistquery.py @@ -18,7 +18,7 @@ from custom_range_list left outer join prediction on prediction.chrom = custom_range_list.chrom -and custom_range_list.range && prediction.range +and custom_range_list.range @> prediction.range and model_name = %s where custom_range_list.id = %s @@ -45,7 +45,7 @@ from custom_range_list left outer join prediction on prediction.chrom = custom_range_list.chrom -and custom_range_list.range && prediction.range +and custom_range_list.range @> prediction.range and model_name = %s where custom_range_list.id = %s diff --git a/util/create_conf.py b/util/create_conf.py index cf1e3a7..b7116de 100644 --- a/util/create_conf.py +++ b/util/create_conf.py @@ -41,29 +41,15 @@ def items(self, *args, **kwargs): SORT_MAX_GUESS = yaml_config['SORT_MAX_GUESS'] MODEL_BASE_URL = yaml_config['MODEL_BASE_URL'] MODEL_FAMILY_ORDER = yaml_config['MODEL_FAMILY_ORDER'] -PREFERENCE_BINS = {} -for item in yaml_config['PREFERENCE_BINS']: +PREF_MIN_MAX = {} +for item in yaml_config['PREF_MIN_MAX']: genome = item['genome'] - name = item['name'] - preference_bins = item['preference_bins'] - PREFERENCE_BINS[(genome, name)] = preference_bins - - -def fix_pref_bins(bins): - for bin_name in ['neg','pos']: - bins[bin_name] = fix_bin(bins[bin_name]) - return bins - - -def fix_bin(bin): - """ - Remove outer indexes make sure values are positive and sorted. - :param bin: list of values - :return: [float] fixed array of bin values - """ - inner_items = bin[1:len(bin)-1] - return sorted([abs(x) for x in inner_items]) + name = item['name'] #re.sub('_\d\d\d\d', '', item['name']) + pref_min = item['pref_min'] + pref_max = item['pref_max'] + PREF_MIN_MAX[(genome, name)] = (pref_min, pref_max) +print(PREF_MIN_MAX) def create_config_file(trackhub_data, output_filename): """ @@ -81,7 +67,8 @@ def create_config_file(trackhub_data, output_filename): pred_idx = 1 for track, url, type, tracks_yaml in trackhub_data.get_track_data(genome, track_filename): sort_max_guess = SORT_MAX_GUESS.get(track, SORT_MAX_GUESS_DEFAULT) - preference_bins = PREFERENCE_BINS.get((genome, track), None) + pref_min, pref_max = PREF_MIN_MAX.get((genome, track), ('','')) + print(pref_min, pref_max, genome, track) prediction_data = { 'idx': pred_idx, 'name': track, @@ -92,9 +79,9 @@ def create_config_file(trackhub_data, output_filename): 'core_offset': tracks_yaml.get_core_offset(track), 'core_length': tracks_yaml.get_core_length(track), 'family': tracks_yaml.get_family(track, type), + 'preference_min': pref_min, + 'preference_max': pref_max, } - if preference_bins: - prediction_data['preference_bins'] = fix_pref_bins(preference_bins) pred_idx += 1 prediction_lists.append(prediction_data) prediction_lists = sorted(prediction_lists, key=prediction_sort_key) diff --git a/util/create_conf.yaml b/util/create_conf.yaml index e609a14..911505a 100644 --- a/util/create_conf.yaml +++ b/util/create_conf.yaml @@ -31,119 +31,102 @@ SORT_MAX_GUESS: 'E2f4_0009': 0.65 'Runx1_0010': 0.7 'Runx2_0011': 0.8 - 'E2f1_0007_vs_E2f3_0008': 16 - 'E2f1_0007_vs_E2f4_0009': 16 - 'E2f3_0008_vs_E2f4_0009': 16 - 'Elk1_0004_vs_Ets1_0005': 16 - 'Elk1_0004_vs_Gabpa_0006': 16 - 'Ets1_0005_vs_Gabpa_0006': 16 - 'Mad1_0002_vs_Max_0003': 16 - 'Mad1_0002_vs_c-Myc_0001': 16 - 'Max_0003_vs_c-Myc_0001': 16 - 'Runx1_0010_vs_Runx2_0011': 16 + 'E2f1_0007_vs_E2f3_0008' : 16 + 'E2f1_0007_vs_E2f4_0009' : 16 + 'E2f3_0008_vs_E2f4_0009' : 16 + 'Elk1_0004_vs_Ets1_0005' : 16 + 'Elk1_0004_vs_Gabpa_0006' : 16 + 'Ets1_0005_vs_Gabpa_0006' : 16 + 'Mad1_0002_vs_Max_0003' : 16 + 'Mad1_0002_vs_c-Myc_0001' : 16 + 'Max_0003_vs_c-Myc_0001' : 16 + 'Runx1_0010_vs_Runx2_0011' : 16 -# Determines color shown for preference value in heatmap -PREFERENCE_BINS: +PREF_MIN_MAX: - genome: hg19 name: E2f1_0007_vs_E2f3_0008 - preference_bins: - neg: [-16.98, -7.57, -6.48, -5.58, -4.92, -4.47, -3.84, -3.41, -2.94, -2.58] - pos: [2.58, 2.77, 2.95, 3.14, 3.38, 3.66, 3.92, 4.29, 4.85, 9.59] + pref_min: -16.98 + pref_max: 9.59 - genome: hg19 name: E2f1_0007_vs_E2f4_0009 - preference_bins: - neg: [-11.44, -6.14, -5.5, -4.68, -4.08, -3.64, -3.31, -3.02, -2.75, -2.58] - pos: [2.58, 2.86, 3.12, 3.41, 3.67, 3.95, 4.3, 4.73, 5.39, 9.88] + pref_min: -11.44 + pref_max: 9.88 - genome: hg19 name: E2f3_0008_vs_E2f4_0009 - preference_bins: - neg: [-8.05, -4.63, -4.08, -3.66, -3.4, -3.22, -3.04, -2.85, -2.71, -2.58] - pos: [2.58, 2.71, 2.89, 3.07, 3.29, 3.58, 3.91, 4.36, 5.03, 8.33] + pref_min: -8.05 + pref_max: 8.33 - genome: hg19 name: Elk1_0004_vs_Ets1_0005 - preference_bins: - neg: [-17.24, -7.33, -6.05, -5.25, -4.65, -4.15, -3.7, -3.29, -2.92, -2.58] - pos: [2.58, 3.91, 5.19, 6.46, 7.79, 9.21, 10.57, 11.89, 13.54, 25.3] + pref_min: -17.24 + pref_max: 25.3 - genome: hg19 name: Elk1_0004_vs_Gabpa_0006 - preference_bins: - neg: [-13.29, -6.41, -5.43, -4.8, -4.34, -3.93, -3.57, -3.22, -2.9, -2.58] - pos: [2.58, 3.08, 3.6, 4.11, 4.67, 5.24, 5.73, 6.35, 7.1, 15.66] + pref_min: -13.29 + pref_max: 15.66 - genome: hg19 name: Ets1_0005_vs_Gabpa_0006 - preference_bins: - neg: [-19.33, -6.68, -5.77, -5.11, -4.59, -4.13, -3.73, -3.33, -2.96, -2.58] - pos: [2.58, 3.12, 3.71, 4.38, 5.15, 6.06, 7.12, 8.36, 9.87, 15.85] -- genome: hg19 - name: Mad1_0002_vs_c-Myc_0001 - preference_bins: - neg: [-12.14, -4.66, -4.64, -3.91, -3.84, -3.64, -3.27, -2.92, -2.58] - pos: [2.58, 2.73, 2.89, 3.05, 3.23, 3.39, 3.58, 3.84, 4.22, 6.85] + pref_min: -19.33 + pref_max: 15.85 - genome: hg19 name: Mad1_0002_vs_Max_0003 - preference_bins: - neg: [-7.43, -6.07, -5.71, -5.45, -4.37, -3.54, -3.22, -2.98, -2.77, -2.58] - pos: [2.58, 2.64, 2.74, 2.86, 3.0, 3.19, 3.3, 3.46, 3.63, 6.28] + pref_min: -7.43 + pref_max: 6.28 +- genome: hg19 + name: Mad1_0002_vs_c-Myc_0001 + pref_min: -12.14 + pref_max: 6.85 - genome: hg19 name: Max_0003_vs_c-Myc_0001 - preference_bins: - neg: [-8.24, -4.13, -3.69, -3.42, -3.23, -3.05, -2.91, -2.79, -2.68, -2.58] - pos: [2.58, 2.73, 2.88, 3.01, 3.18, 3.39, 3.63, 3.95, 4.43, 8.59] + pref_min: -8.24 + pref_max: 8.59 - genome: hg19 name: Runx1_0010_vs_Runx2_0011 - preference_bins: - neg: [-3.6, -3.425, -3.25, -2.9, -2.84, -2.79, -2.7, -2.63, -2.58] - pos: [2.58, 2.6, 2.63, 2.66, 2.7, 2.74, 2.8, 2.84, 2.97, 4.36] + pref_min: -3.6 + pref_max: 4.36 +- genome: hg38 + name: Mad1_0002_vs_c-Myc_0001 + pref_min: -12.14 + pref_max: 6.85 - genome: hg38 name: E2f1_0007_vs_E2f3_0008 - preference_bins: - neg: [-16.98, -7.58, -6.49, -5.64, -4.92, -4.5, -3.85, -3.42, -2.94, -2.58] - pos: [2.58, 2.76, 2.95, 3.13, 3.36, 3.65, 3.92, 4.29, 4.85, 9.59] + pref_min: -16.98 + pref_max: 9.59 - genome: hg38 name: E2f1_0007_vs_E2f4_0009 - preference_bins: - neg: [-11.44, -6.14, -5.49, -4.67, -4.08, -3.64, -3.31, -3.02, -2.75, -2.58] - pos: [2.58, 2.87, 3.14, 3.44, 3.67, 3.95, 4.31, 4.76, 5.39, 9.88] + pref_min: -11.44 + pref_max: 9.88 - genome: hg38 name: E2f3_0008_vs_E2f4_0009 - preference_bins: - neg: [-8.05, -4.63, -4.07, -3.65, -3.39, -3.21, -3.03, -2.85, -2.71, -2.58] - pos: [2.58, 2.71, 2.87, 3.04, 3.26, 3.54, 3.87, 4.3, 4.98, 8.33] + pref_min: -8.05 + pref_max: 8.33 - genome: hg38 name: Elk1_0004_vs_Ets1_0005 - preference_bins: - neg: [-17.24, -7.24, -6.01, -5.25, -4.65, -4.16, -3.7, -3.29, -2.92, -2.58] - pos: [2.58, 3.9, 5.18, 6.44, 7.76, 9.17, 10.53, 11.86, 13.51, 25.3] + pref_min: -17.24 + pref_max: 25.3 - genome: hg38 name: Elk1_0004_vs_Gabpa_0006 - preference_bins: - neg: [-13.29, -6.51, -5.58, -4.87, -4.39, -3.98, -3.62, -3.26, -2.91, -2.58] - pos: [2.58, 3.08, 3.59, 4.1, 4.67, 5.23, 5.72, 6.35, 7.09, 15.66] + pref_min: -13.29 + pref_max: 15.66 - genome: hg38 name: Ets1_0005_vs_Gabpa_0006 - preference_bins: - neg: [-19.33, -6.61, -5.77, -5.13, -4.62, -4.18, -3.76, -3.35, -2.97, -2.58] - pos: [2.58, 3.12, 3.71, 4.38, 5.18, 6.1, 7.18, 8.4, 9.92, 15.85] -- genome: hg38 - name: Mad1_0002_vs_c-Myc_0001 - preference_bins: - neg: [-12.14, -4.66, -4.64, -3.91, -3.84, -3.64, -3.27, -2.92, -2.58] - pos: [2.58, 2.73, 2.89, 3.05, 3.23, 3.39, 3.58, 3.85, 4.22, 6.85] + pref_min: -19.33 + pref_max: 15.85 - genome: hg38 name: Mad1_0002_vs_Max_0003 - preference_bins: - neg: [-7.43, -6.07, -5.71, -5.45, -4.37, -3.53, -3.22, -2.98, -2.77, -2.58] - pos: [2.58, 2.64, 2.74, 2.86, 3.01, 3.21, 3.32, 3.46, 3.63, 6.28] + pref_min: -7.43 + pref_max: 6.28 +- genome: hg38 + name: Mad1_0002_vs_c-Myc_0001 + pref_min: -12.14 + pref_max: 6.85 - genome: hg38 name: Max_0003_vs_c-Myc_0001 - preference_bins: - neg: [-8.24, -4.14, -3.69, -3.42, -3.23, -3.06, -2.91, -2.79, -2.68, -2.58] - pos: [2.58, 2.73, 2.88, 3.01, 3.19, 3.39, 3.63, 3.95, 4.43, 8.59] + pref_min: -8.24 + pref_max: 8.59 - genome: hg38 name: Runx1_0010_vs_Runx2_0011 - preference_bins: - neg: [-3.6, -3.425, -3.25, -2.9, -2.84, -2.79, -2.7, -2.63, -2.58] - pos: [2.58, 2.6, 2.63, 2.66, 2.7, 2.74, 2.8, 2.84, 2.97, 4.36] + pref_min: -3.6 + pref_max: 4.36 MODEL_BASE_URL: https://swift.oit.duke.edu/v1/AUTH_gcb/gordan_models