Skip to content

Batch script does not include junctions in exported image #1777

@Binlop

Description

@Binlop

I used this script in python to get screenshots with pre-created coordinates of genomic inserts. Tracks with readings and coverage are displayed, but the track with junctions is missing. The file size is about 6.5 GB, and the average insertion length is about 2-6 thousand nucleotides. IGV version 2.19.7. What could be the problem?

#!/usr/bin/env python3
import subprocess

def parse_coordinates_file(filename):
    coordinates = []
    with open(filename, 'r') as f:
        for line in f:
            parts = line.strip().split('\t')
            if len(parts) >= 2:
                coordinates.append((parts[0], parts[1]))
    return coordinates

def create_igv_batch_script(coordinates, output_dir, bam_files=None, custom_files=None, genome="hg38"):
    batch_commands = []
    batch_commands.extend([
        f"genome {genome}",
        "preference SQUISH_JUNCTION_TRACK=false",   
        "preference JUNCTION_TRACK_MIN_READS=1",
        "preference SHOW_JUNCTION_TRACK=true"
    ])

    if bam_files:
        for bam_file in bam_files:
            batch_commands.extend([
                f"load {bam_file}",
            ])

    for custom_file in custom_files:
        batch_commands.append(f"load {custom_file}")

    for gene, coord in coordinates:
        safe_name = f"{gene}_{coord.replace(':', '_').replace('-', '_')}"
        batch_commands.extend([
            f"goto {coord}",
            f"snapshot {output_dir}/{safe_name}.png"
        ])
    
    batch_commands.append("exit")
    return "\n".join(batch_commands)

def main():
    input_file = "../LINE/reverse_annotation_LINE/inserts.txt"
    output_dir = "/home/nock/VSC_Projects/LINE_expression/src/igv_screenshots"
    
    custom_files = [
        "/home/nock/VSC_Projects/LINE_expression/LINE/L1_igv.sorted.bed"
    ]
    
    coordinates = parse_coordinates_file(input_file)
    batch_script = create_igv_batch_script(
        coordinates=coordinates,
        output_dir=output_dir,
        custom_files=custom_files,
        bam_files=['/home/nock/NIMC_RNA_Seq/filtered_bam/Placenta504_sorted.bam']
    )
    
    with open("igv_batch.txt", 'w') as f:
        f.write(batch_script)
    
    subprocess.run(['igv', '-b', 'igv_batch.txt'])
    # os.remove("igv_batch.txt")

if __name__ == "__main__":
    main()
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions