Code Monkey home page Code Monkey logo

deduper's Introduction

Deduper

Part 1

Fork this repo - you should do all your work in your fork of this repository.

Write up a strategy for writing a Reference Based PCR Duplicate Removal tool. That is, given a sam file of uniquely mapped reads, remove all PCR duplicates (retain only a single copy of each read). Develop a strategy that avoids loading everything into memory. You should not write any code for this portion of the assignment. Be sure to:

  • Define the problem
  • Write examples:
    • Include a properly formated input sam file
    • Include a properly formated expected output sam file
  • Develop your algorithm using pseudocode
  • Determine high level functions
    • Description
    • Function headers
    • Test examples (for individual functions)
    • Return statement

For this portion of the assignment, you should design your algorithm for single-end data, with 96 UMIs. UMI information will be in the QNAME, like so: NS500451:154:HWKTMBGXX:1:11101:15364:1139:GAACAGGT. Discard any UMIs with errors (or error correct, if you're feeling ambitious).

Part 2

An important part of writing code is reviewing code - both your own and other's. In this portion of the assignment, you will be assigned 3 students' algorithms to review. Be sure to evaluate the following points:

  • Does the proposed algorithm make sense to you? Can you follow the logic?
  • Does the algorithm do everything it's supposed to do? (see part 1)
  • Are proposed functions reasonable? Are they "standalone" pieces of code?

You can find your assigned reviewees on Canvas. You can find your fellow students' repositories at

github.com/<user>/Deduper

Be sure to leave comments on their repositories by creating issues or by commenting on the pull request.

Part 3

Write your deduper function!

Given a SAM file of uniquely mapped reads, remove all PCR duplicates (retain only a single copy of each read). Remember:

  • Samtools sort
  • Adjust for soft clipping
  • Single-end reads
  • Known UMIs
  • Considerations:
    • Millions of reads – avoid loading everything into memory!
    • Be sure to utilize functions appropriately
    • Appropriately comment code and include doc strings
  • CHALLENGE: Include options for
    • Single-end vs paired-end
    • Known UMIs vs randomers
    • Choice of duplicate written to file

You MUST:

  • Write Python 3 compatible code
  • Include the following argparse options
    • -f, --file: required arg, absolute file path
    • -p, --paired: optional arg, designates file is paired end (not single-end)
    • -u, --umi: optional arg, designates file containing the list of UMIs (unset if randomers instead of UMIs)
    • -h, --help: optional arg, prints a USEFUL help message (see argparse docs)
      • If your script is not capable of dealing with a particular option (ex: no paired-end functionality), your script should print an error message and quit
  • Output the first read encountered if duplicates are found
    • You may include an additional argument to designate output of a different read (highest quality or random or ???)
  • Output a properly formatted SAM file with “_deduped” appended to the filename
  • Name your python script <your_last_name>_deduper.py

deduper's People

Contributors

leslie-c avatar spencerseale avatar

deduper's Issues

Peer Review

First and foremost, "this UMI is not real and should not be trusted" is easily the funniest thing I've read out of everyone's pseudocode.

  • Does the proposed algorithm make sense to you? Can you follow the logic?
    The proposed algorithm makes sense, however i'm still confused as to how you're storing your lines as a tuple. Are you overwriting it every time? Seems computationally expensive, but maybe I'm just not understanding.

  • Does the algorithm do everything it's supposed to do? (see part 1)
    The algorithm does check everything necessary however they do seem relatively short

  • Are proposed functions reasonable? Are they "standalone" pieces of code?
    There are a few functions, however I would not argue that they are standalone pieces. They do seem to co-mingle with each other, however, for this specific case I don't think that's a bad thing. It do find that in the way this code is written, it's important that these functions all talk to each other.

Code Peer Review

Does the proposed algorithm make sense to you? Can you follow the logic?
Yep the logic is well layed out in a linear fashion that is understandable.
(line33-35)You don't need to account of I's on either the forward or the reverse strand.
(line 59) does this have to be a function all on it's own? I feel like you could write it into your primary loop to save some computer time
(line 90) Wouldn't it be more efficient to combine this with the previous function (line 70) since you are using an output from that function as the input for this one?

Does the algorithm do everything it's supposed to do? (see part 1)
sort_sam.srun looks good.

something to note when you wrtie the actual function, be careful of how you index the cigar string since it'll be (int)"S" on the left side where the integer can be multiple numbers in a row.
"def pos_adjuster(this_line):
"""
adjusts index 1 of this_line tuple to true position by accounting for muliple factors
example input: (100, "AATTCCGG", True)
example output: (98, "AATTCCGG", True)
"""
if rev:
check for S at end of cigar
check for I and check for D
else:
check for S at start of cigar
return this_line"

Are proposed functions reasonable? Are they "standalone" pieces of code?
For the most part functions are well defined and should run inside the code written. The logic for a few of the functions I think could be aggregated.

Brett Youtsey- Peer Review

Thank you for clearly outlining what is considered a duplicate. Why are you holding the previous chromosome. The SAM file is sorted so you can handle each chromosome one at a time. Good descriptions and example inputs/outputs for each function. Very helpful! You need to explain what the keys/values are for UMIs_dict. Explain how you would change the read position with each case: deletion, insertion, soft-clipping, etc. Oh I see now. You use I & D to describe insertion and deletion. You should write it out the first time to make it more clear.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.