Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • moser
    Junior Member
    • Oct 2011
    • 6

    #1

    HTSeq to calculate strand specific coverage of pe reads

    I try to get strand specific coverage for paired-end RNA reads (using the first read in pair as the counting strand) from a sam-file (sorted by readname).
    So far i found a solution using R, but for larger files (starting from 5 Gbyte), its just not feasible to do it with R as it takes ages.
    By looking at HTSeq which can handle paired-end reads as bundles, i thought i could get strand specific coverage using the HTSeq.pair_SAM_alignments() method but didnt succeed so far...

    Code:
    import HTSeq
    import pysam
    import itertools
    
    sam_reader = HTSeq.SAM_Reader( "test.sam")
    
    cover = HTSeq.GenomicArray( "auto", stranded=True, typecode='i' )
    
    for bundle in HTSeq.pair_SAM_alignments( sam_reader, bundle=True ):
            if len(bundle) != 1:
                    continue
            left_almnt, right_almnt = bundle[0]  # extract pair
            if not left_almnt.aligned and right_almnt.aligned:
                    continue
    
            cover[ left_almnt.iv ] += 1 
    
           #left_almnt equals left read from 5' end of pair NOT first read in pair
    
    cover.write_bedgraph_file( "test-plus.wig", "+" )
    cover.write_bedgraph_file( "test-minus.wig", "-" )
    This gives me the strand specific coverage of the LEFT reads in pair.

    I would like to:
    - Find FIRST read in pair
    - get its strand direction and change its mate's (LAST read in pair) strand direction to that of the FIRST read in pair
    -count coverage of FIRST and LAST read in pair according to strand direction

    Could anyone help me help with this task?
    Maybe someone could show how to find FIRST read in pair with HTSeq?

    Thank you,
    Michel
  • dpryan
    Devon Ryan
    • Jul 2011
    • 3478

    #2
    Why bother scripting it when htseq-count already does that?

    Comment

    • moser
      Junior Member
      • Oct 2011
      • 6

      #3
      I thought htseq-count is for counting reads in features.
      I would like to have per base coverage not counts per feature.
      Or you mean by feeding a per-base-gff file as feature and do the counting to get coverage?

      Comment

      • dpryan
        Devon Ryan
        • Jul 2011
        • 3478

        #4
        Ah, I misunderstood what you wanted. I'm not sure that HTSeq provides all of the interface that you want. I'm sure you can do that strictly with pysam, though, at least unless your reads are coordinate sorted.

        Comment

        Latest Articles

        Collapse

        • SEQadmin2
          16S/ITS Profiling vs. Shotgun Metagenomics: What Changes in Your Workflow?
          by SEQadmin2




          NGS has revolutionized clinical microbiology by offering new ways to identify and surveil pathogens without prior knowledge of the target. One popular approach is 16S rRNA and ITS amplicon sequencing, which targets specific microbial markers. But studies are increasingly incorporating shotgun metagenomics, a technique that sequences all DNA from a sample without targeting specific microbial markers. This approach allows more detailed taxonomic classification, detection...
          Today, 06:46 AM
        • SEQadmin2
          Multiomic Liquid Biopsy: What DNA/RNA Panels Reveal That DNA Alone Can’t
          by SEQadmin2



          Tumors contain complex mixtures of cell populations that evolve in response to treatment and host-specific factors. Tissue biopsies provide only static snapshots of a tumor’s state. But what if we could follow that evolution over time using a minimally invasive technique?

          Liquid biopsies can detect tumor-derived material circulating in the bloodstream, providing a way to study treatment response, detect emerging resistance, and discover new biomarkers. Circulating
          ...
          10-14-2026, 09:55 AM

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by SEQadmin2, 10-28-2026, 09:57 AM
        0 responses
        22 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 10-28-2026, 09:51 AM
        0 responses
        14 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 10-22-2026, 11:13 AM
        0 responses
        67 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 10-22-2026, 10:48 AM
        0 responses
        47 views
        0 reactions
        Last Post SEQadmin2  
        Working...