Skip to content

Commit

Permalink
group autoscale color build out
Browse files Browse the repository at this point in the history
  • Loading branch information
turner committed Oct 12, 2023
1 parent d658da3 commit e65e21d
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 198 deletions.
170 changes: 29 additions & 141 deletions dev/multi-select/multi-select-examples.html
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
]
};

const overlay_tracks_config =
const group_autoscale_config =
{
"version": "2.16.0",
"showSampleNames": false,
Expand All @@ -200,48 +200,6 @@
"type": "sequence",
"order": -9007199254740991
},
{
"name": "Homo sapiens A549 SIN3A ",
"url": "https://www.encodeproject.org/files/ENCFF582HJY/@@download/ENCFF582HJY.bigWig",
"color": "#ff2987",
"metadata": {
"Biosample": "Homo sapiens A549",
"AssayType": "ChIP-seq",
"Target": "SIN3A ",
"BioRep": "3",
"TechRep": "3_1",
"OutputType": "fold change over control",
"Format": "bigWig",
"Lab": "Michael Snyder, Stanford",
"Accession": "ENCFF582HJY",
"Experiment": "ENCSR513XQX"
},
"order": 1,
"format": "bigwig",
"type": "wig",
"height": 128
},
{
"name": "Homo sapiens A549 treated with 0.02% ethanol for 1 hour YY1 ",
"url": "https://www.encodeproject.org/files/ENCFF085ITE/@@download/ENCFF085ITE.bigWig",
"color": "#83f902",
"metadata": {
"Biosample": "Homo sapiens A549 treated with 0.02% ethanol for 1 hour",
"AssayType": "ChIP-seq",
"Target": "YY1 ",
"BioRep": "1",
"TechRep": "1_1",
"OutputType": "fold change over control",
"Format": "bigWig",
"Lab": "Richard Myers, HAIB",
"Accession": "ENCFF085ITE",
"Experiment": "ENCSR000BPM"
},
"order": 1,
"format": "bigwig",
"type": "wig",
"height": 128
},
{
"name": "Homo sapiens angular gyrus tissue male adult (81 years) H3K36me3 ",
"url": "https://www.encodeproject.org/files/ENCFF202ZTM/@@download/ENCFF202ZTM.bigWig",
Expand All @@ -261,102 +219,57 @@
"order": 1,
"format": "bigwig",
"type": "wig",
"height": 128
"height": 128,
// "autoscaleGroup": 'annaBirna'
},
{
"name": "Refseq Genes",
"format": "refgene",
"id": "hg19_genes",
"url": "https://hgdownload.soe.ucsc.edu/goldenPath/hg19/database/ncbiRefSeq.txt.gz",
"indexed": false,
"removable": false,
"order": 1000000,
"infoURL": "https://www.ncbi.nlm.nih.gov/gene/?term=$$",
"type": "annotation",
"height": 70
}
]
};

const overlay_throws_error_config =
{
"version": "2.16.0",
"showSampleNames": false,
"reference": {
"id": "hg19",
"name": "Human (GRCh37/hg19)",
"fastaURL": "https://igv-genepattern-org.s3.amazonaws.com/genomes/seq/hg19/hg19.fasta",
"indexURL": "https://igv-genepattern-org.s3.amazonaws.com/genomes/seq/hg19/hg19.fasta.fai",
"cytobandURL": "https://igv-genepattern-org.s3.amazonaws.com/genomes/seq/hg19/cytoBand.txt",
"aliasURL": "https://s3.amazonaws.com/igv.org.genomes/hg19/hg19_alias.tab",
"chromosomeOrder": "chr1, chr2, chr3, chr4, chr5, chr6, chr7, chr8, chr9, chr10, chr11, chr12, chr13, chr14, chr15, chr16, chr17, chr18, chr19, chr20, chr21, chr22, chrX, chrY"
},
"locus": "chr5:1-180,915,260",
"roi": [],
"tracks": [
{
"type": "sequence",
"order": -9007199254740991
name: "ENCODE bigwig",
url: 'https://www.encodeproject.org/files/ENCFF206QIK/@@download/ENCFF206QIK.bigWig',
// autoscaleGroup: 'annaBirna'
},
{
"name": "Homo sapiens A549 CTCF ",
"url": "https://www.encodeproject.org/files/ENCFF023NXW/@@download/ENCFF023NXW.bigWig",
"name": "Homo sapiens A549 SIN3A ",
"url": "https://www.encodeproject.org/files/ENCFF582HJY/@@download/ENCFF582HJY.bigWig",
"color": "#ff2987",
"metadata": {
"Biosample": "Homo sapiens A549",
"AssayType": "ChIP-seq",
"Target": "CTCF ",
"BioRep": "1",
"TechRep": "1_1",
"OutputType": "signal p-value",
"Target": "SIN3A ",
"BioRep": "3",
"TechRep": "3_1",
"OutputType": "fold change over control",
"Format": "bigWig",
"Lab": "John Stamatoyannopoulos, UW",
"Accession": "ENCFF023NXW",
"Experiment": "ENCSR000DPF"
"Lab": "Michael Snyder, Stanford",
"Accession": "ENCFF582HJY",
"Experiment": "ENCSR513XQX"
},
"order": 0,
"order": 1,
"format": "bigwig",
"type": "wig"
"type": "wig",
"height": 128,
"autoscaleGroup": 'billyBobThornton'
},
{
"name": "Homo sapiens A549 treated with 0.02% ethanol for 1 hour H3K9ac ",
"url": "https://www.encodeproject.org/files/ENCFF537QDO/@@download/ENCFF537QDO.bigWig",
"color": "rgb(100,0,0)",
"name": "Homo sapiens A549 treated with 0.02% ethanol for 1 hour YY1 ",
"url": "https://www.encodeproject.org/files/ENCFF085ITE/@@download/ENCFF085ITE.bigWig",
"color": "#83f902",
"metadata": {
"Biosample": "Homo sapiens A549 treated with 0.02% ethanol for 1 hour",
"AssayType": "ChIP-seq",
"Target": "H3K9ac ",
"Target": "YY1 ",
"BioRep": "1",
"TechRep": "1_1",
"OutputType": "fold change over control",
"Format": "bigWig",
"Lab": "Bradley Bernstein, Broad",
"Accession": "ENCFF537QDO",
"Experiment": "ENCSR000ASV"
},
"order": 3,
"format": "bigwig",
"type": "wig",
"height": 128
},
{
"name": "Homo sapiens A549 treated with 0.02% ethanol for 1 hour SIN3A ",
"url": "https://www.encodeproject.org/files/ENCFF620FRR/@@download/ENCFF620FRR.bigWig",
"metadata": {
"Biosample": "Homo sapiens A549 treated with 0.02% ethanol for 1 hour",
"AssayType": "ChIP-seq",
"Target": "SIN3A ",
"BioRep": "1,2",
"TechRep": "1_1,2_1",
"OutputType": "signal p-value",
"Format": "bigWig",
"Lab": "Richard Myers, HAIB",
"Accession": "ENCFF620FRR",
"Experiment": "ENCSR000BRM"
"Accession": "ENCFF085ITE",
"Experiment": "ENCSR000BPM"
},
"order": 3,
"order": 1,
"format": "bigwig",
"type": "wig",
"height": 128
"height": 128,
"autoscaleGroup": 'billyBobThornton'
},
{
"name": "Refseq Genes",
Expand All @@ -373,31 +286,6 @@
]
};

const group_autoscale_config = {
genome: "hg19",
locus: "myc",
tracks: [

{
"url": "https://www.encodeproject.org/files/ENCFF754TJH/@@download/ENCFF754TJH.bigWig",
"name": "Encode bigwig",
color: 'rgb(255,0,0)',
height: 256,
"metadata" : {
"Foo": "bar",
"Bar": 999.999
}
},
{
"url": "https://s3-us-west-2.amazonaws.com/ilmn.igv-test/test2.bigWig",
color: 'rgb(0,0,255)',
"name": "Big BigWig",
height: 256
},

]
};

igv.createBrowser(document.getElementById("myDiv"), group_autoscale_config).then(function (browser) {})


Expand Down
76 changes: 38 additions & 38 deletions dev/wig/wigs.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,44 +34,44 @@
// color: '#f00',
indexed: false
},
// {
// name: 'All negative points',
// url: '../../test/data/wig/allNegativewig.bedgraph',
// indexed: false,
// graphType: "points",
// guideLines: [
// {dotted: true, y: 0, color: "green"},
// {dotted: true, y: -0.25, color: "blue"},
// {dotted: true, y: -0.5, color: "red"}
// ]
// },
// {
// name: 'All pos points',
// url: '../../test/data/wig/allPositive.bedgraph',
// indexed: false,
// graphType: "points",
// guideLines: [
// {dotted: true, y: 0, color: "green"},
// {dotted: true, y: 0.25, color: "blue"},
// {dotted: true, y: 0.5, color: "red"}
// ]
// },
// {
// name: 'Mixed_pos_neg_points',
// url: '../../test/data/wig/mixedPosNeg.bedgraph',
// indexed: false,
// graphType: "points",
// guideLines: [
// {dotted: true, y: 0, color: "green"},
// {dotted: true, y: -0.5, color: "blue"},
// {dotted: true, y: 0.5, color: "red"}
// ]
// },
// {
// name: 'Mixed pos neg bars',
// url: '../../test/data/wig/mixedPosNeg.bedgraph',
// indexed: false
// },
{
name: 'All negative points',
url: '../../test/data/wig/allNegativewig.bedgraph',
indexed: false,
graphType: "points",
guideLines: [
{dotted: true, y: 0, color: "green"},
{dotted: true, y: -0.25, color: "blue"},
{dotted: true, y: -0.5, color: "red"}
]
},
{
name: 'All pos points',
url: '../../test/data/wig/allPositive.bedgraph',
indexed: false,
graphType: "points",
guideLines: [
{dotted: true, y: 0, color: "green"},
{dotted: true, y: 0.25, color: "blue"},
{dotted: true, y: 0.5, color: "red"}
]
},
{
name: 'Mixed_pos_neg_points',
url: '../../test/data/wig/mixedPosNeg.bedgraph',
indexed: false,
graphType: "points",
guideLines: [
{dotted: true, y: 0, color: "green"},
{dotted: true, y: -0.5, color: "blue"},
{dotted: true, y: 0.5, color: "red"}
]
},
{
name: 'Mixed pos neg bars',
url: '../../test/data/wig/mixedPosNeg.bedgraph',
indexed: false
},
]
};

Expand Down
16 changes: 11 additions & 5 deletions js/trackView.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import SampleNameViewport from './sample/sampleNameViewport.js'
import MenuPopup from "./ui/menuPopup.js"
import {autoScaleGroupColorHash, getMultiSelectedTrackViews, multiTrackSelectExclusionTypes} from "./ui/menuUtils.js"
import { ENABLE_MULTI_TRACK_SELECTION, setMultiTrackSelectionState, setDragHandleSelectionState } from './ui/multiTrackSelectButton.js'
import {hexToRGB} from "./util/colorPalletes.js"
import {colorPalettes, hexToRGB} from "./util/colorPalletes.js"

const igv_axis_column_width = 50
const scrollbarExclusionTypes = new Set(['sequence', 'ruler', 'ideogram'])
Expand Down Expand Up @@ -134,9 +134,9 @@ class TrackView {

this.track.isMultiSelection = event.target.checked

if (this.track.autoscaleGroup && false === event.target.checked) {
this.track.autoscaleGroup = undefined
}
// if (this.track.autoscaleGroup && false === event.target.checked) {
// this.track.autoscaleGroup = undefined
// }

setDragHandleSelectionState(this, this.dragHandle, event.target.checked)

Expand Down Expand Up @@ -921,7 +921,13 @@ class TrackView {
axisCanvasContext.scale(dpi, dpi)

if (this.track.autoscaleGroup) {
const rgba = IGVColor.addAlpha(autoScaleGroupColorHash[ this.track.autoscaleGroup ], 0.25)

if (undefined === autoScaleGroupColorHash[ this.track.autoscaleGroup ]) {
const colorPalette = colorPalettes['Dark2']
const randomIndex = Math.floor(Math.random() * colorPalettes['Dark2'].length)
autoScaleGroupColorHash[ this.track.autoscaleGroup ] = colorPalette[ randomIndex ]
}
const rgba = IGVColor.addAlpha(autoScaleGroupColorHash[ this.track.autoscaleGroup ], 0.75)
this.track.paintAxis(axisCanvasContext, width, height, rgba)
} else {
this.track.paintAxis(axisCanvasContext, width, height, undefined)
Expand Down
7 changes: 5 additions & 2 deletions js/ui/menuPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,13 @@ class MenuPopup {

if (isMultiSelectedTrackView(trackView)) {

if (true === item.doTrackOverlay) {
trackView.browser.multiSelectedTrackViews = getMultiSelectedTrackViews(trackView.browser)

if (true === item.doAllMultiSelectedTracks) {
item.click.call(trackView.track, e)
} else {
for (const { track } of getMultiSelectedTrackViews(trackView.browser)) {

for (const { track } of trackView.browser.multiSelectedTrackViews) {
item.click.call(track, e)
}
}
Expand Down
16 changes: 7 additions & 9 deletions js/ui/menuUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,22 +136,20 @@ function groupAutoScaleMenuItem() {

function click(e) {

const trackViews = getMultiSelectedTrackViews(this.browser)

const autoScaleGroupID = `auto-scale-group-${DOMUtils.guid()}`

const colorPalette = colorPalettes['Set1']
const colorPalette = colorPalettes['Dark2']
const randomIndex = Math.floor(Math.random() * colorPalette.length)

const autoScaleGroupID = `auto-scale-group-${ DOMUtils.guid() }`
autoScaleGroupColorHash[ autoScaleGroupID ] = colorPalette[randomIndex]

for (const trackView of trackViews) {
trackView.track.autoscaleGroup = autoScaleGroupID
for (const { track } of this.browser.multiSelectedTrackViews) {
track.autoscaleGroup = autoScaleGroupID
}

this.browser.updateViews()
}

return { object, click }
return { object, doAllMultiSelectedTracks:true, click }

}

Expand Down Expand Up @@ -197,7 +195,7 @@ function trackOverlayMenuItem() {

}

return { object, doTrackOverlay:true, click }
return { object, doAllMultiSelectedTracks:true, click }

}

Expand Down
Loading

0 comments on commit e65e21d

Please sign in to comment.