igvteam / igv

Integrative Genomics Viewer. Fast, efficient, scalable visualization tool for genomics data and annotations
https://igv.org
MIT License
646 stars 387 forks source link

Alignment tracks are incorrectly grouped above the coverage tracks #1576

Closed minw2828 closed 1 month ago

minw2828 commented 1 month ago

Hello,

Thank you for supporting IGV.

I wrote a script to try to load the coverage track first and then the alignment track for each bam file. However, the alignment tracks and the coverage tracks were incorrectly grouped, respectively. Additionally, the alignment tracks were incorrectly shown above the coverage tracks, as shown in the screenshot below.

Could you advise what might be the cause, and how I might be able to fix it, please?

Many thanks, Min

for bam in bams:
            panel = ET.SubElement(root, "Panel", name=generate_random_digits('Panel', 13))
            coverage_track = ET.SubElement(...)
            alignment_track = ET.SubElement(...)
Screenshot 2024-09-22 at 1 03 06 PM
jrobinso commented 1 month ago

Hi,

Sorry no I can't, I don't recognize that syntax, but "SubElement" is not part of our API.

minw2828 commented 1 month ago

Hello @jrobinso,

Thank you for your quick reply.

What do you mean "your API"?

I wanted to programmatically generate session files, ready to be loaded into IGV.

I also want to be able to use command line to open my IGV desktop app in Mac, with the correct session file loaded into my IGV app.

Could you advise how I might be able to achieve the above two goals please?

Many thanks, Min

jrobinso commented 1 month ago

Oh, sorry I didn't notice you filed both issues. Yes "API" was referring to igv.js, my mistake, I get them confused sometimes. At any rate I don't understand the syntax or language you are using here so I really can't help debug that. Trying to generate the "panels" section of the XML will be challenging. If you post the actual XML generated I might be able to spot something.

jrobinso commented 1 month ago

If you can generate a session using public files I can load it might be informative. Here are some public URLs

https://1000genomes.s3.amazonaws.com/phase3/data/HG01879/alignment/HG01879.mapped.ILLUMINA.bwa.ACB.low_coverage.20120522.bam
https://1000genomes.s3.amazonaws.com/phase3/data/HG01880/alignment/HG01880.mapped.ILLUMINA.bwa.ACB.low_coverage.20120522.bam
victorskl commented 1 month ago

Hi Jim,

Min (@minw2828) is trying to programatically generate session XML file following doc.

One caveat is that she also like to group the panel by coverage and junctions tracks along with BAM alignment track.

This seems to require following naming convention for coverage and junctions track such that their ID has to suffix with _coverage and _junctions respectively.

Failing to do so by just simply using the same as BAM alignment track ID, it ends up coverage tracks being break out from BAM track panel and, right click behaviour show as mentioned in #1575

Here are example session xml.


This will break out the corresponding coverage track into the new panel and made all 3 tracks being selected / grouped.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Session genome="hg38" locus="chr13:48303751-48481890" version="8">
    <Resources>
        <Resource index="https://bucket.s3.amazonaws.com/output/normal.aligned.hiphase.bam.bai?AWS...Expires=1727678623" path="https://bucket.s3.amazonaws.com/output/normal.aligned.hiphase.bam?AWS...Expires=1727678623" type="bam"/>
    </Resources>
    <Panel height="500" name="Panel1168237966041" width="1472">
        <Track attributeKey="normal.aligned.hiphase.bam Coverage" autoScale="true" clazz="org.broad.igv.sam.CoverageTrack" fontSize="10" id="https://bucket.s3.amazonaws.com/output/normal.aligned.hiphase.bam?AWS...Expires=1727678623" name="normal.aligned.hiphase.bam Coverage" snpThreshold="0.2" visible="true">
            <DataRange baseline="0.0" drawBaseline="true" flipAxis="false" maximum="10.0" minimum="0.0" type="LINEAR"/>
        </Track>
        <Track attributeKey="normal.aligned.hiphase.bam Junctions" autoScale="false" clazz="org.broad.igv.sam.SpliceJunctionTrack" fontSize="10" groupByStrand="false" height="60" id="https://bucket.s3.amazonaws.com/output/normal.aligned.hiphase.bam?AWS...Expires=1727678623" maxdepth="50" name="normal.aligned.hiphase.bam Junctions" visible="false"/>
        <Track attributeKey="normal.aligned.hiphase.bam" clazz="org.broad.igv.sam.AlignmentTrack" displayMode="COLLAPSED" experimentType="THIRD_GEN" fontSize="10" id="https://bucket.s3.amazonaws.com/output/normal.aligned.hiphase.bam?AWS...Expires=1727678623" name="normal.aligned.hiphase.bam" visible="true">
            <RenderOptions basemodFilter="m," colorOption="BASE_MODIFICATION" groupByOption="PHASE"/>
        </Track>
    </Panel>
    <PanelLayout dividerFractions="0.0052863436123348016,0.6916299559471366"/>
    <HiddenAttributes>
        <Attribute name="DATA FILE"/>
        <Attribute name="DATA TYPE"/>
        <Attribute name="NAME"/>
    </HiddenAttributes>
</Session>

This works.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Session genome="hg38" locus="chr13:48303751-48481890" version="8">
    <Resources>
        <Resource index="https://bucket.s3.amazonaws.com/output/normal.aligned.hiphase.bam.bai?AWS...Expires=1727678623" path="https://bucket.s3.amazonaws.com/output/normal.aligned.hiphase.bam?AWS...Expires=1727678623" type="bam"/>
    </Resources>
    <Panel height="500" name="Panel1168237966041" width="1472">
        <Track attributeKey="normal.aligned.hiphase.bam Coverage" autoScale="true" clazz="org.broad.igv.sam.CoverageTrack" fontSize="10" id="https://bucket.s3.amazonaws.com/output/normal.aligned.hiphase.bam?AWS...Expires=1727678623_coverage" name="normal.aligned.hiphase.bam Coverage" snpThreshold="0.2" visible="true">
            <DataRange baseline="0.0" drawBaseline="true" flipAxis="false" maximum="10.0" minimum="0.0" type="LINEAR"/>
        </Track>
        <Track attributeKey="normal.aligned.hiphase.bam Junctions" autoScale="false" clazz="org.broad.igv.sam.SpliceJunctionTrack" fontSize="10" groupByStrand="false" height="60" id="https://bucket.s3.amazonaws.com/output/normal.aligned.hiphase.bam?AWS...Expires=1727678623_junctions" maxdepth="50" name="normal.aligned.hiphase.bam Junctions" visible="false"/>
        <Track attributeKey="normal.aligned.hiphase.bam" clazz="org.broad.igv.sam.AlignmentTrack" displayMode="COLLAPSED" experimentType="THIRD_GEN" fontSize="10" id="https://bucket.s3.amazonaws.com/output/normal.aligned.hiphase.bam?AWS...Expires=1727678623" name="normal.aligned.hiphase.bam" visible="true">
            <RenderOptions basemodFilter="m," colorOption="BASE_MODIFICATION" groupByOption="PHASE"/>
        </Track>
    </Panel>
    <PanelLayout dividerFractions="0.0052863436123348016,0.6916299559471366"/>
    <HiddenAttributes>
        <Attribute name="DATA FILE"/>
        <Attribute name="DATA TYPE"/>
        <Attribute name="NAME"/>
    </HiddenAttributes>
</Session>

Note of S3 presigned url is intentional as it gets challenging to spot the issue for missing suffix for the coverage and junctions ID.

Anyhow. Fixing our script, it works as expected now. Thanks for your support, always.!

jrobinso commented 1 month ago

Glad you got it to work.

minw2828 commented 1 month ago

Thank you everyone! Feeling super grateful 🙏 I will close my tickets now. ☺️