Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • dmacmillan
    Member
    • Jan 2012
    • 49

    Pysam Fetching Incorrect Coordinates

    Hello everyone. I am using pysam to fetch the reads overlapping a given region, however, I am finding that pysam returns a list of reads whose positions do not correspond with the region coordinates that I input. The BAM file is indexed with samtools index 'file.bam'

    For example, I want to fetch this region: chr3:50617849-50618103

    I do so with the following code (inside python command line):
    Code:
    import pysam
    bam = pysam.AlignmentFile('file.bam')
    reads = bam.fetch('chr3',50617849,50618103)
    for read in reads:
        print read.pos
    The first coordinate printed is 50335428, which is outside the scope of my input region completely.

    Does anybody know why this is happening? The BAM file was created from a STAR alignment of paired-end reads against the hg19 human reference genome in case that matters.
  • dpryan
    Devon Ryan
    • Jul 2011
    • 3478

    #2
    Right, but does the read stretch into or span that region? You're not asking for reads starting in that interval, you're asking for those that intersect it in any way (including splicing over it).

    Comment

    • dmacmillan
      Member
      • Jan 2012
      • 49

      #3
      Well the distance from that read to the actual start location is ~280,000 nucleotides. I suppose then the read would have to be spliced? Here is one of the reads in question:

      Code:
      ABC-ST978_0126:2:1307:16045:21543#0     403     2       50335428 3
              91M317386N10M   2       50335207        101     GGGGTCTGTAACCACCAGGTCTATAAAACAGCCGACCCAATCTACTTGCTGGCCTTCTGTCTTCCAGTAGTCCTCCTAGTCCACCACTAGGAGGACTAGGA       array('B', [66, 66, 66, 64, 66, 66, 66, 65, 63, 64, 64, 66, 66, 66, 66, 65, 66, 66, 66, 66, 66, 67, 66, 65, 66, 66, 66, 66, 66, 66, 66, 68, 68, 70, 70, 72, 72, 71, 72, 71, 71, 71, 69, 70, 72, 71, 71, 72, 71, 70, 70, 71, 72, 72, 72, 72, 72, 71, 71, 71, 72, 71, 71, 72, 72, 72, 72, 71, 72, 71, 69, 72, 71, 69, 72, 71, 71, 72, 72, 72, 71, 70, 70, 72, 70, 69, 72, 72, 70, 70, 70, 70, 70, 68, 66, 68, 68, 68, 65, 64, 64])    [('NH', 2), ('HI', 2), ('AS', 189), ('nM', 0)]
      I suppose that 317386N region is the gap?

      Comment

      • dpryan
        Devon Ryan
        • Jul 2011
        • 3478

        #4
        Yup, it's a spliced read, which you can tell from the N cigar operator.

        Comment

        • dmacmillan
          Member
          • Jan 2012
          • 49

          #5
          Interesting, glad I know this now. Thanks!

          Comment

          • dpryan
            Devon Ryan
            • Jul 2011
            • 3478

            #6
            No problem, I've been tripped up by this as well. In case you ever use the pileup() functions, keep in mind that this will happen there as well.

            Comment

            Latest Articles

            Collapse

            • SEQadmin2
              Nine Things a Sample Prep Scientist Thinks About Before Sequencing
              by SEQadmin2


              I’m not a sequencing expert. I’m a purification scientist who uses NGS to evaluate workflows my group develops. With this perspective, we think about the sample first and the NGS workflow second. The sequencer is an exceptionally honest reporter, but it can only report on what you give it, so whether you get clean, interpretable data from an NGS workflow is largely determined before you begin.


              Here are nine questions we think about, in roughly the order they matter, before...
              06-18-2026, 07:11 AM
            • SEQadmin2
              From Collection to Sequencing: Why Sample Preparation and Preservation Define Sequencing Data
              by SEQadmin2


              Data variability is still an issue in sequencing technologies despite the advances in reproducibility and accuracy of these platforms. But the problem does not originate in the sequencing itself, but in the previous steps, before the sample reaches the sequencer.


              The first step is collection, followed by preservation and sample preparation for analysis. Most scientists overlook those steps, but not being careful might just be skewing the experiment’s results.
              ...
              06-02-2026, 10:05 AM

            ad_right_rmr

            Collapse

            News

            Collapse

            Topics Statistics Last Post
            Started by SEQadmin2, 06-17-2026, 06:09 AM
            0 responses
            30 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 06-09-2026, 11:58 AM
            0 responses
            44 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 06-05-2026, 10:09 AM
            0 responses
            51 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 06-04-2026, 08:59 AM
            0 responses
            51 views
            0 reactions
            Last Post SEQadmin2  
            Working...