Git Product home page Git Product logo

nanopore-methylation's Introduction

nanopore-methylation

By adapting EM algorithm in a Hidden Markov Model (HMM), we are able to cluster nanopore reads into their parental haplotypes. One can choose use all nanopore data from the chromosome or reads mapped to imprinted regions. By analysing nanopore reads raw signals, there should be one haplotype group shows where methylation happened. And we are able to located methylated bases.

Handle NA12878 data

imprinted_regions = read_imprinted_data("data/ip_gene_pos.txt")  
SNPS = load_VCF("data/chr19.vcf")  
READS = load_sam_file("data/chr19_merged.sam", "19", SNPS) # specify chromosome number  

Find READS overlapping with any human imprinted region

o = get_overlapped_reads(READS, imprinted_regions)

Save pre-processed data

save_objects("data/snps.obj", SNPS)
save_objects("data/READS.obj", READS)
save_objects("data/reads_ir.obj", o)

Load pre-processed data

all_snps = load_objects("../data/snps.obj")
reads = load_objects("../data/READS.obj")
reads_ir = load_objects("data/reads_ir.obj")

HMM clusters nanopore reads into 2 possible haplotypes

Simulation

dummy_reads = load_objects("../data/dummy/dr1.obj")
dummy_snps = load_objects("../data/dummy/ds1.obj")
dm1 = run_model(dummy_snps, dummy_reads, 10)
dm2 = run_model(dummy_snps, dummy_reads, 10)
compare_models(dm1, dm2)

Run model

# Update all SNP sites
model = run_model(all_snps, reads, iter_num=100) # can choose to run model iter_num times
# Update part of SNP sites
model = run_model(all_snps, reads, 100, updateAll=False, p=0.5) # randomly choose 50% SNP sites to update

# Result: haplotypes (dict): {"m1": {snp_id: allele}, "m2": {snp_id: allele}}
haplotypes = model.get_haplotypes()  # each SNP site returns one allele

# Other results:
# Alleles clusters saved in a dictionary {"m1": {snp_id: [allele1, allele2]}, "m2": {snp_id: [allele1, allele2]}}
alleles_dict = model1.get_alleles()
sorted_alleles_dict = model1.get_ordered_alleles() # sorted by SNP positions
# haplotype strings, "-" on unassigned positions
h1, h2 = model1.align_alleles()

# Use trained model to cluster new nanopore reads data set (traning and new data set must from the same chr)
haplotypes_dict = model1.cluster(new_reads)

# Compare model grouping results
model2 = run_model(all_snps, reads, iter_num=100)
compare_models(model1, model2) # return common/different alleles and their positions

# Compare results of two trained models clustering new data set
compare_clustering(model1, model2, new_data)

nanopore-methylation's People

Contributors

haotianteng avatar yaoli3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.