methplotlib 0.20.1__tar.gz → 0.23.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- methplotlib-0.23.0/LICENSE +21 -0
- methplotlib-0.23.0/PKG-INFO +117 -0
- {methplotlib-0.20.1 → methplotlib-0.23.0}/README.md +11 -5
- {methplotlib-0.20.1 → methplotlib-0.23.0}/methplotlib/annotation.py +32 -13
- methplotlib-0.23.0/methplotlib/import_methylation.py +583 -0
- methplotlib-0.23.0/methplotlib/methplotlib.py +153 -0
- methplotlib-0.23.0/methplotlib/plots.py +459 -0
- {methplotlib-0.20.1 → methplotlib-0.23.0}/methplotlib/qc.py +4 -1
- {methplotlib-0.20.1 → methplotlib-0.23.0}/methplotlib/utils.py +143 -33
- methplotlib-0.23.0/methplotlib/version.py +1 -0
- methplotlib-0.23.0/methplotlib.egg-info/PKG-INFO +117 -0
- {methplotlib-0.20.1 → methplotlib-0.23.0}/methplotlib.egg-info/SOURCES.txt +2 -8
- {methplotlib-0.20.1 → methplotlib-0.23.0}/methplotlib.egg-info/entry_points.txt +0 -1
- {methplotlib-0.20.1 → methplotlib-0.23.0}/methplotlib.egg-info/requires.txt +1 -1
- {methplotlib-0.20.1 → methplotlib-0.23.0}/methplotlib.egg-info/top_level.txt +0 -1
- methplotlib-0.23.0/setup.py +59 -0
- methplotlib-0.23.0/tests/test_differential.py +123 -0
- methplotlib-0.20.1/PKG-INFO +0 -88
- methplotlib-0.20.1/README.rst +0 -100
- methplotlib-0.20.1/methplotlib/import_methylation.py +0 -305
- methplotlib-0.20.1/methplotlib/methplotlib.py +0 -135
- methplotlib-0.20.1/methplotlib/plots.py +0 -384
- methplotlib-0.20.1/methplotlib/version.py +0 -1
- methplotlib-0.20.1/methplotlib.egg-info/PKG-INFO +0 -88
- methplotlib-0.20.1/scripts/__init__.py +0 -0
- methplotlib-0.20.1/scripts/annotate_calls_by_phase.py +0 -42
- methplotlib-0.20.1/scripts/calculate_methylation_frequency.py +0 -144
- methplotlib-0.20.1/scripts/genome-wide-QC.py +0 -38
- methplotlib-0.20.1/scripts/sorting_and_multiple_testing_correction.py +0 -33
- methplotlib-0.20.1/scripts/split_calls_by_longshot_phase.py +0 -38
- methplotlib-0.20.1/scripts/split_calls_by_phase.py +0 -50
- methplotlib-0.20.1/setup.py +0 -51
- {methplotlib-0.20.1 → methplotlib-0.23.0}/MANIFEST.in +0 -0
- {methplotlib-0.20.1 → methplotlib-0.23.0}/methplotlib/__init__.py +0 -0
- {methplotlib-0.20.1 → methplotlib-0.23.0}/methplotlib/differential/__init__.py +0 -0
- {methplotlib-0.20.1 → methplotlib-0.23.0}/methplotlib/differential/differential.py +0 -0
- {methplotlib-0.20.1 → methplotlib-0.23.0}/methplotlib/helpers.py +0 -0
- {methplotlib-0.20.1 → methplotlib-0.23.0}/methplotlib.egg-info/dependency_links.txt +0 -0
- {methplotlib-0.20.1 → methplotlib-0.23.0}/scripts/allele_specific_modification +0 -0
- {methplotlib-0.20.1 → methplotlib-0.23.0}/scripts/differential_modification +0 -0
- {methplotlib-0.20.1 → methplotlib-0.23.0}/setup.cfg +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Wouter De Coster
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: methplotlib
|
|
3
|
+
Version: 0.23.0
|
|
4
|
+
Summary: Plot nucleotide modification data from nanopore sequencing
|
|
5
|
+
Home-page: https://github.com/wdecoster/methplotlib
|
|
6
|
+
Author: Wouter De Coster
|
|
7
|
+
Author-email: decosterwouter@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Keywords: nanopore methylation modification
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Science/Research
|
|
12
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Requires-Python: >=3.9
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: plotly>=4.9.0
|
|
24
|
+
Requires-Dist: numpy>=1.16.5
|
|
25
|
+
Requires-Dist: pandas>=0.23.4
|
|
26
|
+
Requires-Dist: pyranges>=0.0.77
|
|
27
|
+
Requires-Dist: fisher>=0.1.9
|
|
28
|
+
Requires-Dist: scikit-learn
|
|
29
|
+
Requires-Dist: pyfaidx
|
|
30
|
+
Requires-Dist: biopython
|
|
31
|
+
Requires-Dist: pysam
|
|
32
|
+
Dynamic: author
|
|
33
|
+
Dynamic: author-email
|
|
34
|
+
Dynamic: classifier
|
|
35
|
+
Dynamic: description
|
|
36
|
+
Dynamic: description-content-type
|
|
37
|
+
Dynamic: home-page
|
|
38
|
+
Dynamic: keywords
|
|
39
|
+
Dynamic: license
|
|
40
|
+
Dynamic: license-file
|
|
41
|
+
Dynamic: requires-dist
|
|
42
|
+
Dynamic: requires-python
|
|
43
|
+
Dynamic: summary
|
|
44
|
+
|
|
45
|
+
[](https://anaconda.org/bioconda/methplotlib)
|
|
46
|
+
[](https://anaconda.org/bioconda/methplotlib)
|
|
47
|
+
|
|
48
|
+
# METHPLOTLIB
|
|
49
|
+
|
|
50
|
+
This script generates a browser view on a window using data from
|
|
51
|
+
i) [nanopolish](https://github.com/jts/nanopolish), either as methylation calls or methylation frequencies (as processed by calculate_methylation_frequency.py). The methylation calls can additionally be phased using scripts/annotate_calls_by_phase.py and scripts/split_calls_by_phase.py
|
|
52
|
+
ii) [nanocompore](https://github.com/tleonardi/nanocompore)
|
|
53
|
+
iii) in ont-cram format with MM/ML tags according to the SAM specifications
|
|
54
|
+
iv) in bedgraph format, with 4 columns (chromosome, start, end, value) or the 5 columns written by `modkit pileup --bedgraph`
|
|
55
|
+
v) in bedMethyl format, as written by [modkit](https://github.com/nanoporetech/modkit) `pileup` (18 columns, with or without `--only-tabs`) or by `modbam2bed --extended` (14 columns). Files containing multiple modifications (e.g. 5mC and 5hmC) do not have to be split up: each modification gets its own track, and `--mods` can be used to restrict to some of them
|
|
56
|
+
|
|
57
|
+
## INSTALLATION
|
|
58
|
+
|
|
59
|
+
Creating a new conda environment:
|
|
60
|
+
`conda create -n methplotlib methplotlib`
|
|
61
|
+
|
|
62
|
+
Or using pip:
|
|
63
|
+
`pip install methplotlib`
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
## USAGE
|
|
68
|
+
```
|
|
69
|
+
methplotlib [-h] [-v] -m METHYLATION [METHYLATION ...] -n NAMES
|
|
70
|
+
[NAMES ...] -w WINDOW [-g GTF] [-b BED] [-f FASTA]
|
|
71
|
+
[--simplify] [--split] [--static STATIC] [--smooth SMOOTH]
|
|
72
|
+
[--dotsize DOTSIZE] [--example] [-o OUTFILE] [-q QCFILE]
|
|
73
|
+
|
|
74
|
+
plotting nanopolish methylation calls or frequency
|
|
75
|
+
|
|
76
|
+
optional arguments:
|
|
77
|
+
-h, --help show this help message and exit
|
|
78
|
+
-v, --version Print version and exit.
|
|
79
|
+
-m, --methylation METHYLATION [METHYLATION ...]
|
|
80
|
+
data in nanopolish, nanocompore, ont-cram or bedgraph
|
|
81
|
+
format
|
|
82
|
+
-n, --names NAMES [NAMES ...]
|
|
83
|
+
names of datasets in --methylation
|
|
84
|
+
-w, --window WINDOW window (region) to which the visualisation has to be restricted
|
|
85
|
+
-g, --gtf GTF add annotation based on a gtf file
|
|
86
|
+
-b, --bed BED add annotation based on a bed file
|
|
87
|
+
-f, --fasta FASTA required when --window is an entire chromosome, contig or transcript
|
|
88
|
+
--simplify simplify annotation track to show genes rather than transcripts
|
|
89
|
+
--split split, rather than overlay the methylation tracks
|
|
90
|
+
--static Make a static image of the browser window (filename)
|
|
91
|
+
--binary Make the nanopolish plot ignorning log likelihood nuances
|
|
92
|
+
--smooth Rolling window size for averaging frequency values (int)
|
|
93
|
+
--dotsize Control the size of dots in the per read plots (int)
|
|
94
|
+
--example Show example command and exit.
|
|
95
|
+
-o, --outfile OUTFILE File to write results to. Default:
|
|
96
|
+
methylation_browser_{chr}_{start}_{end}.html. Use
|
|
97
|
+
{region} as a shorthand for {chr}_{start}_{end} in the
|
|
98
|
+
filename. Missing paths will be created.
|
|
99
|
+
-q, --qcfile QCFILE File to write the qc report to. Default: The path in
|
|
100
|
+
outfile prefixed with qc_, default is qc_report_methyl
|
|
101
|
+
ation_browser_{chr}_{start}_{end}.html. Use {region}
|
|
102
|
+
as a shorthand for {chr}_{start}_{end} in the
|
|
103
|
+
filename. Missing paths will be created.
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Snakemake workflow
|
|
108
|
+
For streamlining nanopolish a Snakefile is included (using snakemake). The workflow uses a config file, of which an example is in this repository.
|
|
109
|
+
|
|
110
|
+
## Example data
|
|
111
|
+
The `examples` folder contains calls and frequencies for the human ACTB gene from PromethION sequencing of NA19240. An example command is available.
|
|
112
|
+
|
|
113
|
+
## Companion scripts
|
|
114
|
+
The `scripts` folder contains scripts for phasing modification calls in haplotypes based on [WhatsHap](https://whatshap.readthedocs.io/en/latest/) phasing, allele specific modification testing for phased data and differential modification testing across subjects.
|
|
115
|
+
|
|
116
|
+
## TO DO - CONTRIBUTIONS WELCOME
|
|
117
|
+
- Outlier detection (in windows) across samples
|
|
@@ -1,19 +1,25 @@
|
|
|
1
|
-
[](https://travis-ci.com/wdecoster/methplotlib)
|
|
2
|
-
[](https://conda.anaconda.org/bioconda)
|
|
3
1
|
[](https://anaconda.org/bioconda/methplotlib)
|
|
4
2
|
[](https://anaconda.org/bioconda/methplotlib)
|
|
5
3
|
|
|
6
4
|
# METHPLOTLIB
|
|
7
5
|
|
|
8
6
|
This script generates a browser view on a window using data from
|
|
9
|
-
i) [nanopolish](https://github.com/jts/nanopolish), either as methylation calls or methylation frequencies (as processed by calculate_methylation_frequency.py). The methylation calls can additionally be phased using scripts/annotate_calls_by_phase.and scripts/split_calls_by_phase.py
|
|
7
|
+
i) [nanopolish](https://github.com/jts/nanopolish), either as methylation calls or methylation frequencies (as processed by calculate_methylation_frequency.py). The methylation calls can additionally be phased using scripts/annotate_calls_by_phase.py and scripts/split_calls_by_phase.py
|
|
10
8
|
ii) [nanocompore](https://github.com/tleonardi/nanocompore)
|
|
11
|
-
iii) in ont-cram format with MM/
|
|
12
|
-
iv) in bedgraph format
|
|
9
|
+
iii) in ont-cram format with MM/ML tags according to the SAM specifications
|
|
10
|
+
iv) in bedgraph format, with 4 columns (chromosome, start, end, value) or the 5 columns written by `modkit pileup --bedgraph`
|
|
11
|
+
v) in bedMethyl format, as written by [modkit](https://github.com/nanoporetech/modkit) `pileup` (18 columns, with or without `--only-tabs`) or by `modbam2bed --extended` (14 columns). Files containing multiple modifications (e.g. 5mC and 5hmC) do not have to be split up: each modification gets its own track, and `--mods` can be used to restrict to some of them
|
|
13
12
|
|
|
14
13
|
## INSTALLATION
|
|
14
|
+
|
|
15
|
+
Creating a new conda environment:
|
|
16
|
+
`conda create -n methplotlib methplotlib`
|
|
17
|
+
|
|
18
|
+
Or using pip:
|
|
15
19
|
`pip install methplotlib`
|
|
16
20
|
|
|
21
|
+
|
|
22
|
+
|
|
17
23
|
## USAGE
|
|
18
24
|
```
|
|
19
25
|
methplotlib [-h] [-v] -m METHYLATION [METHYLATION ...] -n NAMES
|
|
@@ -31,11 +31,14 @@ def good_record(line, chromosome):
|
|
|
31
31
|
"""
|
|
32
32
|
Filtering on the gtf lines
|
|
33
33
|
by checking for right chromosome and right feature type
|
|
34
|
+
|
|
35
|
+
The chromosome has to match the entire field, as a prefix match would
|
|
36
|
+
e.g. also accept chr10 up to chr19 and chr1_KI270706v1_random for chr1
|
|
34
37
|
"""
|
|
35
|
-
if line.startswith(
|
|
36
|
-
return True
|
|
37
|
-
else:
|
|
38
|
+
if line.startswith("#"):
|
|
38
39
|
return False
|
|
40
|
+
fields = line.split("\t")
|
|
41
|
+
return len(fields) > 2 and fields[0] == str(chromosome) and fields[2] in ["exon", "gene"]
|
|
39
42
|
|
|
40
43
|
|
|
41
44
|
def get_features(gtfline, type="gtf"):
|
|
@@ -54,8 +57,10 @@ def parse_attributes(attributes, type="gtf"):
|
|
|
54
57
|
"""
|
|
55
58
|
attribute_delimiter = {"gtf": "; ", "gff": ";"}
|
|
56
59
|
kv_delimiter = {"gtf": " ", "gff": "="}
|
|
60
|
+
# the last attribute of a record keeps the trailing delimiter,
|
|
61
|
+
# which would otherwise end up in the name shown when hovering
|
|
57
62
|
info = {
|
|
58
|
-
i.split(kv_delimiter[type])[0]: i.split(kv_delimiter[type])[1].replace('"', "")
|
|
63
|
+
i.split(kv_delimiter[type])[0]: i.split(kv_delimiter[type])[1].replace('"', "").rstrip(";")
|
|
59
64
|
for i in attributes.split(attribute_delimiter[type])
|
|
60
65
|
if i.startswith(("gene_name", "transcript_id", "locus_tag"))
|
|
61
66
|
}
|
|
@@ -67,17 +72,19 @@ def parse_attributes(attributes, type="gtf"):
|
|
|
67
72
|
|
|
68
73
|
def transcripts_in_window(df, window, feature="transcript"):
|
|
69
74
|
"""
|
|
70
|
-
Return the transcript names
|
|
71
|
-
|
|
75
|
+
Return the transcript names of the exons overlapping the window
|
|
76
|
+
|
|
77
|
+
Testing for overlap rather than for a begin or end within the window,
|
|
78
|
+
as otherwise a feature spanning the entire window would be missed
|
|
72
79
|
"""
|
|
73
80
|
return df.loc[
|
|
74
|
-
df["begin"]
|
|
81
|
+
(df["begin"] <= window.end) & (df["end"] >= window.begin),
|
|
75
82
|
feature,
|
|
76
83
|
].unique()
|
|
77
84
|
|
|
78
85
|
|
|
79
86
|
def assign_colors_to_genes(transcripts):
|
|
80
|
-
genes =
|
|
87
|
+
genes = dict.fromkeys([t.gene for t in transcripts])
|
|
81
88
|
colordict = {g: c for g, c in zip(genes, plcolors * 100)}
|
|
82
89
|
for t in transcripts:
|
|
83
90
|
t.color = colordict[t.gene]
|
|
@@ -90,12 +97,24 @@ def parse_annotation(gtff, window, simplify=False):
|
|
|
90
97
|
"""
|
|
91
98
|
type = annot_file_sniffer(gtff)
|
|
92
99
|
logging.info(f"Parsing {type} file...")
|
|
100
|
+
chromosomes_seen = set()
|
|
101
|
+
records = []
|
|
102
|
+
for line in open_gtf(gtff):
|
|
103
|
+
if good_record(line, window.chromosome):
|
|
104
|
+
records.append(get_features(line, type=type))
|
|
105
|
+
elif line.strip() and not line.startswith("#"):
|
|
106
|
+
chromosomes_seen.add(line.split("\t")[0])
|
|
107
|
+
if not records and chromosomes_seen:
|
|
108
|
+
sys.stderr.write(
|
|
109
|
+
f"\nWARNING: no exons or genes of chromosome '{window.chromosome}' "
|
|
110
|
+
f"in {gtff}.\n"
|
|
111
|
+
f"The annotation contains {len(chromosomes_seen)} chromosomes, "
|
|
112
|
+
f"such as {', '.join(sorted(chromosomes_seen)[:5])}.\n"
|
|
113
|
+
"Do the chromosome names in --window match those in your annotation "
|
|
114
|
+
"(e.g. '15' versus 'chr15')?\n"
|
|
115
|
+
)
|
|
93
116
|
df = pd.DataFrame(
|
|
94
|
-
data=
|
|
95
|
-
get_features(line, type=type)
|
|
96
|
-
for line in open_gtf(gtff)
|
|
97
|
-
if good_record(line, window.chromosome)
|
|
98
|
-
],
|
|
117
|
+
data=records,
|
|
99
118
|
columns=["chromosome", "begin", "end", "strand", "gene", "transcript"],
|
|
100
119
|
)
|
|
101
120
|
logging.info("Loaded GTF file, processing...")
|