Skip to main content

Analysis of allele-specific methylation in bisulfite DNA sequencing.

Project description

pyllelic

CodeFactor Codacy Badge Codacy Badge CodeQL ci Code style: black

PyPI Anaconda-Server Badge GitHub

pyllelic: a tool for detection of allelic-specific methylation variation in bisulfite DNA sequencing files.

Pyllelic documention is available at https://paradoxdruid.github.io/pyllelic/ and see pyllelic_notebook.ipynb for a fully explored demonstration.

Quickstart

Run an interactive sample pyllelic environment in your web browser using mybinder.org:

Binder

pyllelic in action

pyllelic demo gif

Dependencies and Installation

Using Conda (preferred)

Create a new conda environment using python 3.8:

Easiest:

# Get environment.yml file from this repo
curl -L https://github.com/Paradoxdruid/pyllelic/blob/master/environment.yml?raw=true > env.yml

# Create and activate conda environment
conda env create --file=env.yml
conda activate pyllelic
or more explict step by step instructions
conda create --name pyllelic python=3.8
conda activate pyllelic
conda config --env --add channels conda-forge
conda config --env --add channels bioconda
conda config --env --add channels paradoxdruid
conda install pyllelic 

# Optional but usual use case:
conda install notebook ipywidgets

Docker container

docker pull ghcr.io/paradoxdruid/pyllelic:latest

PyPi installation

PyPi instructions

This will require independent installation of samtools, bowtie2, and bismark packages.

# PyPi
python3 -m pip install pyllelic
# or Github
python3 -m pip install git+https://github.com/Paradoxdruid/pyllelic.git

Example exploratory use in jupyter notebook

Set up files:

  from pyllelic import process
  from pathlib import Path

  # Retrieve promoter genomic sequence of region to analyze
  process.retrieve_seq("tert_genome.txt", chrom="chr5", start=1293000, end=1296000)

  # Download a reference genome and bisulfite sequencing data
  # Genome data from, e.g. http://hgdownload.soe.ucsc.edu/goldenPath/hg19
  # Fastq data from, e.g. http://hgdownload.cse.ucsc.edu/goldenPath/hg19/encodeDCC/wgEncodeHaibMethylRrbs/
  genome = Path("/{your_directory}/{genome_file_directory}")
  fastq = Path("/{your_directory}/{your_fastq_file.fastq.gz}")

  # Use bismark tool to prepare bisulfite genome and align fastq to bam file
  process.prepare_genome(genome) # can optionally give path to bowtie2 if not in PATH
  process.bismark(genome, fastq)

  # Sort and index the resultant bam file
  bamfile = Path("/{your_directory}/{bam_filename}.bam")
  process.sort_bam(bamfile)
  process.index_bam(bamfile.parent / f"{bamfile.stem}_sorted.bam")

Run pyllelic:

    from pyllelic import pyllelic

    config = pyllelic.configure(  # Specify file and directory locations
        base_path="/home/jovyan/assets/",
        prom_file="tert_genome.txt",
        prom_start=1293200,
        prom_end=1296000,
        chrom="5",
        offset=1293000,  # start position of retrieved promoter sequence
        # viz_backend="plotly",
        # fname_pattern=r"^[a-zA-Z]+_([a-zA-Z0-9]+)_.+bam$",
        # test_dir="test",
        # results_dir="results",
    )

    files_set = pyllelic.make_list_of_bam_files(config)  # finds bam files

    # Run pyllelic; make take some time depending on number of bam files
    data = pyllelic.pyllelic(config=config, files_set=files_set)

    positions = data.positions

    cell_types = data.cell_types

    means_df = data.means  # mean methylation of reads

    modes_df = data.modes  # mode methylation of reads
    
    diff_df = data.diffs  # difference mean - mode of reads

    individual_data = data.individual_data  # read methylation values

    data.save("output.xlsx")  # save methylation results

    data.save_pickle("my_run.pickle")  # save data object for later analysis
    
    data.write_means_modes_diffs(filename="Run1_")  # write output data files

    data.histogram("CELL_LINE", "POSITION")  # visualize data for a point

    data.heatmap(min_values=1)  # methylation level heatmap

    data.reads_graph()  # individual methylated / unmethylated reads graph

    data.quma_results["CELL_LINE"]  # see summary data for a cell line

Authors

This software is developed as academic software by Dr. Andrew J. Bonham at the Metropolitan State University of Denver. It is licensed under the GPL v3.0.

This software incorporates implementation from QUMA, licensed under the GPL v3.0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyllelic-0.4.8.tar.gz (10.6 MB view details)

Uploaded Source

Built Distribution

pyllelic-0.4.8-py3-none-any.whl (51.8 kB view details)

Uploaded Python 3

File details

Details for the file pyllelic-0.4.8.tar.gz.

File metadata

  • Download URL: pyllelic-0.4.8.tar.gz
  • Upload date:
  • Size: 10.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for pyllelic-0.4.8.tar.gz
Algorithm Hash digest
SHA256 f9a485f757df71fdb81601b3203370347f759f833fafc2e542c3d0f6a5f80f87
MD5 b41955fea85d583c92da222af6413e52
BLAKE2b-256 87f74f69f89157fc429b9010692345fcb71b0d54581c97eb72c377ba213777d9

See more details on using hashes here.

File details

Details for the file pyllelic-0.4.8-py3-none-any.whl.

File metadata

  • Download URL: pyllelic-0.4.8-py3-none-any.whl
  • Upload date:
  • Size: 51.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for pyllelic-0.4.8-py3-none-any.whl
Algorithm Hash digest
SHA256 9cad247c5ffbe51cf80cce0cdb2fe58f5f24fc2c8fd03a4d2fdce8fc03504351
MD5 15fa52d434d7161ff9809fe8ac4c6381
BLAKE2b-256 dcfef1e8a067e57cb9bc966d9c648c7ae6284d084d1c028e6484eb421037ed04

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page