Git Product home page Git Product logo

mutation_rate's Introduction

Gene features and the mutation density (cook-book)

Most following steps were running at bash (ubuntu14.04) or ipython (2.7) environment. To use the repo code:

import mutation_rate.mutation_density as md

###uncompress the attachment.

tar -xvf test.assignment.txt.tar.gz

###remove decoy/virus sequences and sort.

grep -v ^GL test.assignment.txt | sort -k1,1V -k2,2n > test.assignment.no.decoy.tsv

###split patients.

awk '{print $NF}' test.assignment.no.decoy.tsv | sort -u | while read line; do grep -w $line test.assignment.no.decoy.tsv >> $line.tsv; done

###prepare .bed file from individuals for ucsc genome browser, and modify chrMT to chrM for loading.

md.creat_bed('input')
sed -i 's/^chrMT/chrM/g'

###calculate mutation density on 1M base window.

md.create_density_csv('ucsc.hg19.fasta.fai', 1000000, 'test.assignment.no.decoy.tsv', 'test.assignment.no.decoy.1M_window.mutation_density.csv')

###get gene features from gencode.

for i in CDS UTR lincRNA; do grep -w $i gencode.v19.annotation.gtf > $i.gtf; done
grep 'gene_type \"protein_coding\"' gencode.v19.annotation.gtf >> protein_coding.gtf

###calculate gene features on 1M base window. e.g:

for i in range(22):
    n = str(i + 1)
    print 'processing chr%s.utr.csv' % n
    md.create_feature_csv('chr' + n, 'ucsc.hg19.fasta.fai', 1000000, 'utr.gtf', 'chr'+n+'.utr.csv')
    print 'chr%s is done' % n

###install R 3.2.1, bioconductor, SomatiCA to get 10000 base window GC content. need to modify the output format to run next step. (remove first column)

library(SomatiCA)
data(GCcontent)
write.csv(GCcontent, file="10000_gccontent.csv")

###calculate GC content on 1M base window. e.g:

for i in range(22):
    n = str(i + 1)
    print 'processing chr%s.gc.csv' % n
    md.create_gc_csv('chr' + n, 'ucsc.hg19.fasta.fai', 1000000, '10000_gccontent.1.csv', 'chr'+n+'.gc.csv')
    print 'chr%s is done' % n

P.S: The first attempt was to calculate GC content by UCSC data. However, the code seemed extremely inefficient to handle such a large file. (UCSC GC data is on 5 bases windows, 6.6G in size.)

mutation_rate's People

Contributors

wangfan860 avatar

Watchers

James Cloos avatar  avatar

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.