methplotlib 0.23.0__py3-none-any.whl → 0.23.2__py3-none-any.whl
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/annotation.py +27 -12
- methplotlib/import_methylation.py +4 -3
- methplotlib/plots.py +11 -10
- methplotlib/qc.py +0 -5
- methplotlib/utils.py +1 -1
- methplotlib/version.py +1 -1
- {methplotlib-0.23.0.dist-info → methplotlib-0.23.2.dist-info}/METADATA +1 -1
- methplotlib-0.23.2.dist-info/RECORD +19 -0
- methplotlib-0.23.0.dist-info/RECORD +0 -19
- {methplotlib-0.23.0.data → methplotlib-0.23.2.data}/scripts/allele_specific_modification +0 -0
- {methplotlib-0.23.0.data → methplotlib-0.23.2.data}/scripts/differential_modification +0 -0
- {methplotlib-0.23.0.dist-info → methplotlib-0.23.2.dist-info}/WHEEL +0 -0
- {methplotlib-0.23.0.dist-info → methplotlib-0.23.2.dist-info}/entry_points.txt +0 -0
- {methplotlib-0.23.0.dist-info → methplotlib-0.23.2.dist-info}/licenses/LICENSE +0 -0
- {methplotlib-0.23.0.dist-info → methplotlib-0.23.2.dist-info}/top_level.txt +0 -0
methplotlib/annotation.py
CHANGED
|
@@ -27,17 +27,16 @@ def open_gtf(gtff):
|
|
|
27
27
|
return gzip.open(gtff, "rt") if gtff.endswith(".gz") else open(gtff)
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
def good_record(
|
|
30
|
+
def good_record(fields, chromosome):
|
|
31
31
|
"""
|
|
32
32
|
Filtering on the gtf lines
|
|
33
33
|
by checking for right chromosome and right feature type
|
|
34
34
|
|
|
35
|
+
Takes the first fields of a line, as splitting off the long attributes
|
|
36
|
+
field for every line of an annotation is a waste.
|
|
35
37
|
The chromosome has to match the entire field, as a prefix match would
|
|
36
38
|
e.g. also accept chr10 up to chr19 and chr1_KI270706v1_random for chr1
|
|
37
39
|
"""
|
|
38
|
-
if line.startswith("#"):
|
|
39
|
-
return False
|
|
40
|
-
fields = line.split("\t")
|
|
41
40
|
return len(fields) > 2 and fields[0] == str(chromosome) and fields[2] in ["exon", "gene"]
|
|
42
41
|
|
|
43
42
|
|
|
@@ -100,10 +99,15 @@ def parse_annotation(gtff, window, simplify=False):
|
|
|
100
99
|
chromosomes_seen = set()
|
|
101
100
|
records = []
|
|
102
101
|
for line in open_gtf(gtff):
|
|
103
|
-
if
|
|
102
|
+
if line.startswith("#") or not line.strip():
|
|
103
|
+
continue
|
|
104
|
+
# only the fields needed to decide, the attributes are split off
|
|
105
|
+
# further down for the few lines that are of interest
|
|
106
|
+
fields = line.split("\t", 3)
|
|
107
|
+
if good_record(fields, window.chromosome):
|
|
104
108
|
records.append(get_features(line, type=type))
|
|
105
|
-
|
|
106
|
-
chromosomes_seen.add(
|
|
109
|
+
else:
|
|
110
|
+
chromosomes_seen.add(fields[0])
|
|
107
111
|
if not records and chromosomes_seen:
|
|
108
112
|
sys.stderr.write(
|
|
109
113
|
f"\nWARNING: no exons or genes of chromosome '{window.chromosome}' "
|
|
@@ -121,9 +125,13 @@ def parse_annotation(gtff, window, simplify=False):
|
|
|
121
125
|
if simplify:
|
|
122
126
|
df.drop_duplicates(subset=["chromosome", "begin", "end", "gene"], inplace=True)
|
|
123
127
|
res = []
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
128
|
+
genes = transcripts_in_window(df, window, feature="gene")
|
|
129
|
+
# grouping the features of interest once, rather than scanning the
|
|
130
|
+
# entire frame again for every gene
|
|
131
|
+
per_gene = dict(list(df[df["gene"].isin(genes)].groupby("gene")))
|
|
132
|
+
for g in genes:
|
|
133
|
+
gtable = per_gene.get(g)
|
|
134
|
+
if gtable is not None and len(gtable):
|
|
127
135
|
res.append(
|
|
128
136
|
Transcript(
|
|
129
137
|
transcript=gtable["gene"].tolist()[0],
|
|
@@ -138,8 +146,15 @@ def parse_annotation(gtff, window, simplify=False):
|
|
|
138
146
|
logging.info(f"Found {len(res)} gene(s) in the region.\n")
|
|
139
147
|
else:
|
|
140
148
|
res = []
|
|
141
|
-
|
|
142
|
-
|
|
149
|
+
transcripts = transcripts_in_window(df, window, feature="transcript")
|
|
150
|
+
# grouping the features of interest once, rather than scanning the
|
|
151
|
+
# entire frame again for every transcript
|
|
152
|
+
per_transcript = dict(list(df[df["transcript"].isin(transcripts)].groupby("transcript")))
|
|
153
|
+
for t in transcripts:
|
|
154
|
+
tr = per_transcript.get(t)
|
|
155
|
+
if tr is None or not len(tr):
|
|
156
|
+
# an annotation without transcript_id, e.g. some gff flavors
|
|
157
|
+
continue
|
|
143
158
|
res.append(
|
|
144
159
|
Transcript(
|
|
145
160
|
transcript=t,
|
|
@@ -540,9 +540,10 @@ def get_modified_reference_positions(read):
|
|
|
540
540
|
# Nake an array with all read positions for which that nucleotide exists in the read
|
|
541
541
|
# Oddly, get_forward_sequence() returns the sequence as it came from the sequencer
|
|
542
542
|
# This is the same direction as the Mm/Ml tags are specified in
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
)
|
|
543
|
+
# the positions of that nucleotide in the read, found with numpy
|
|
544
|
+
# as a python loop over every base of a long read is expensive
|
|
545
|
+
sequence = np.frombuffer(read.get_forward_sequence().encode(), dtype="S1")
|
|
546
|
+
base_index = np.flatnonzero(sequence == base.encode())
|
|
546
547
|
# Based on both arrays, find those read coordinates that have a modification
|
|
547
548
|
modified_bases = base_index[locations]
|
|
548
549
|
# Convert the array of read coordinates to reference coordinates
|
methplotlib/plots.py
CHANGED
|
@@ -189,13 +189,15 @@ def make_per_read_meth_traces_phred(
|
|
|
189
189
|
table = table.join(df_heights, on="read_name", how="outer")
|
|
190
190
|
traces = []
|
|
191
191
|
hidden = 0
|
|
192
|
-
|
|
193
|
-
|
|
192
|
+
# one row per read, to avoid scanning the entire table for every read
|
|
193
|
+
per_read = table.drop_duplicates(subset="read_name").set_index("read_name")
|
|
194
|
+
for read in per_read.index:
|
|
195
|
+
strand = per_read.at[read, "strand"]
|
|
194
196
|
try:
|
|
195
197
|
traces.append(
|
|
196
198
|
make_per_read_line_trace(
|
|
197
199
|
read_range=minmax_table.loc[read],
|
|
198
|
-
y_pos=df_heights.
|
|
200
|
+
y_pos=df_heights.at[read, "height"],
|
|
199
201
|
strand=strand,
|
|
200
202
|
)
|
|
201
203
|
)
|
|
@@ -233,17 +235,16 @@ def make_per_read_meth_traces_llr(
|
|
|
233
235
|
)
|
|
234
236
|
traces = []
|
|
235
237
|
hidden = 0
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
else
|
|
241
|
-
phase = None
|
|
238
|
+
# one row per read, to avoid scanning the entire table for every read
|
|
239
|
+
per_read = table.drop_duplicates(subset="read_name").set_index("read_name")
|
|
240
|
+
for read in per_read.index:
|
|
241
|
+
strand = per_read.at[read, "strand"]
|
|
242
|
+
phase = per_read.at[read, "HP"] if phased else None
|
|
242
243
|
try:
|
|
243
244
|
traces.append(
|
|
244
245
|
make_per_read_line_trace(
|
|
245
246
|
read_range=minmax_table.loc[read],
|
|
246
|
-
y_pos=df_heights.
|
|
247
|
+
y_pos=df_heights.at[read, "height"],
|
|
247
248
|
strand=strand,
|
|
248
249
|
phase=phase,
|
|
249
250
|
size=dotsize,
|
methplotlib/qc.py
CHANGED
|
@@ -45,7 +45,6 @@ def num_sites_bar(meth_data):
|
|
|
45
45
|
layout = dict(title="Number of called positions")
|
|
46
46
|
return plotly.offline.plot(dict(data=[trace], layout=layout),
|
|
47
47
|
output_type="div",
|
|
48
|
-
show_link=False,
|
|
49
48
|
include_plotlyjs='cdn')
|
|
50
49
|
|
|
51
50
|
|
|
@@ -72,7 +71,6 @@ def pairwise_correlation_plot(full):
|
|
|
72
71
|
|
|
73
72
|
return plotly.offline.plot(dict(data=[trace], layout=layout),
|
|
74
73
|
output_type="div",
|
|
75
|
-
show_link=False,
|
|
76
74
|
include_plotlyjs='cdn')
|
|
77
75
|
|
|
78
76
|
|
|
@@ -99,7 +97,6 @@ def pca(full):
|
|
|
99
97
|
)
|
|
100
98
|
return plotly.offline.plot(dict(data=data, layout=layout),
|
|
101
99
|
output_type="div",
|
|
102
|
-
show_link=False,
|
|
103
100
|
include_plotlyjs='cdn')
|
|
104
101
|
|
|
105
102
|
|
|
@@ -110,7 +107,6 @@ def global_box(data):
|
|
|
110
107
|
x="dataset", y="freq", title="Global frequency of modification")
|
|
111
108
|
return plotly.offline.plot(fig,
|
|
112
109
|
output_type="div",
|
|
113
|
-
show_link=False,
|
|
114
110
|
include_plotlyjs='cdn')
|
|
115
111
|
|
|
116
112
|
|
|
@@ -129,5 +125,4 @@ def modified_fraction_histogram(full):
|
|
|
129
125
|
return plotly.offline.plot(dict(data=traces,
|
|
130
126
|
layout=layout),
|
|
131
127
|
output_type="div",
|
|
132
|
-
show_link=False,
|
|
133
128
|
include_plotlyjs='cdn')
|
methplotlib/utils.py
CHANGED
|
@@ -405,5 +405,5 @@ def create_browser_output(fig, outfile, window):
|
|
|
405
405
|
def write_html_output(fig, outfile):
|
|
406
406
|
with open(outfile, "w+") as output:
|
|
407
407
|
output.write(
|
|
408
|
-
plotly.offline.plot(fig, output_type="div",
|
|
408
|
+
plotly.offline.plot(fig, output_type="div", include_plotlyjs="cdn")
|
|
409
409
|
)
|
methplotlib/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.23.
|
|
1
|
+
__version__ = "0.23.2"
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
methplotlib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
methplotlib/annotation.py,sha256=c-b5bUlVTi2Mc0QDBzsKe4V7N0ETw8BEtvY-e0ZtCjQ,7541
|
|
3
|
+
methplotlib/helpers.py,sha256=D69CLM_M8D0wNoV4p-ODr81uatfeCBUUzYdifUmjL88,432
|
|
4
|
+
methplotlib/import_methylation.py,sha256=XyI52b6GYPDlxm_JbUMFqeDkEMUu8Sg51BcT9a2aEm8,22728
|
|
5
|
+
methplotlib/methplotlib.py,sha256=Gk07ODKVfDlA33SlzgIsqRLP0j1DYng24ku87DyYrXY,6264
|
|
6
|
+
methplotlib/plots.py,sha256=MPViIwPrrYn_gx_1VYs3ZECthll3OPrbcyoVAC00cLU,14757
|
|
7
|
+
methplotlib/qc.py,sha256=jvZnkl9KNiZGstcZRt17W3Bngr5z9BmkNPTxrEjJoW4,5350
|
|
8
|
+
methplotlib/utils.py,sha256=KKdb7R6l7i8oVuybnN5srDc2iB8KDjOPoDpXr6E8nrw,14519
|
|
9
|
+
methplotlib/version.py,sha256=yninyH3Qwkx3xw1ShRaTmjGR_Q-bmMjaMjZVzxS2tLM,23
|
|
10
|
+
methplotlib/differential/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
+
methplotlib/differential/differential.py,sha256=YSWUAeMaI_yERj6oAdvyWM3vKn2laTtWp6Y8ZuwvLA4,1773
|
|
12
|
+
methplotlib-0.23.2.data/scripts/allele_specific_modification,sha256=PpBdGIiVm8M6OjM0m68OPWnsyDeXJZDnbSNCrH3CaHY,1403
|
|
13
|
+
methplotlib-0.23.2.data/scripts/differential_modification,sha256=SZ0odGaykx_cqIHh5tOKSVUCbXOdHR4PSv4Yv6V04Zw,1461
|
|
14
|
+
methplotlib-0.23.2.dist-info/licenses/LICENSE,sha256=qan9p7Fjhl7WzXuiZoaXCViH5si1PSKBNm9K2f0_51c,1073
|
|
15
|
+
methplotlib-0.23.2.dist-info/METADATA,sha256=RjlPvceeAGuHWJ7kV8NCItOj6vi8Xhm-GQ2C6cDjAW4,5718
|
|
16
|
+
methplotlib-0.23.2.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
17
|
+
methplotlib-0.23.2.dist-info/entry_points.txt,sha256=Tav-_W5yZc2G8ApYYuFLfVKU2QugXuEN8z_AjPZwORs,61
|
|
18
|
+
methplotlib-0.23.2.dist-info/top_level.txt,sha256=w1XBGUmKUyGeE0_ufRQ6Vi5lMIzDq6TwF587aofDxuQ,12
|
|
19
|
+
methplotlib-0.23.2.dist-info/RECORD,,
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
methplotlib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
methplotlib/annotation.py,sha256=JjbwXoAmb53lBJJq4W-_B1P3b2-vIrK2QlHUDavq6lk,6671
|
|
3
|
-
methplotlib/helpers.py,sha256=D69CLM_M8D0wNoV4p-ODr81uatfeCBUUzYdifUmjL88,432
|
|
4
|
-
methplotlib/import_methylation.py,sha256=7sf396Cjrkdx-JvvEYcj7IVCCQClch-Sv4YJ9kSfQH4,22561
|
|
5
|
-
methplotlib/methplotlib.py,sha256=Gk07ODKVfDlA33SlzgIsqRLP0j1DYng24ku87DyYrXY,6264
|
|
6
|
-
methplotlib/plots.py,sha256=EZRzc-B4OLjmgFlagzIdhs0S2zyuc_oSv6JqAQs3j3c,14609
|
|
7
|
-
methplotlib/qc.py,sha256=1EvpxeU7xfwKcQeNflrO4pgsZbc9gbCTcMbShumB_Mo,5590
|
|
8
|
-
methplotlib/utils.py,sha256=ffRDe2ITycIj7_5JV2NBjU6XA4qYYIK3HuWUkqhfJLI,14536
|
|
9
|
-
methplotlib/version.py,sha256=6bYcjtcATvc99ZNMjTUfPlrJP3-1WenVEc656roVn_I,23
|
|
10
|
-
methplotlib/differential/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
-
methplotlib/differential/differential.py,sha256=YSWUAeMaI_yERj6oAdvyWM3vKn2laTtWp6Y8ZuwvLA4,1773
|
|
12
|
-
methplotlib-0.23.0.data/scripts/allele_specific_modification,sha256=PpBdGIiVm8M6OjM0m68OPWnsyDeXJZDnbSNCrH3CaHY,1403
|
|
13
|
-
methplotlib-0.23.0.data/scripts/differential_modification,sha256=SZ0odGaykx_cqIHh5tOKSVUCbXOdHR4PSv4Yv6V04Zw,1461
|
|
14
|
-
methplotlib-0.23.0.dist-info/licenses/LICENSE,sha256=qan9p7Fjhl7WzXuiZoaXCViH5si1PSKBNm9K2f0_51c,1073
|
|
15
|
-
methplotlib-0.23.0.dist-info/METADATA,sha256=ekpREpDBaoqT6fQD0gTEDI3rN2sYfcgGstYss_OiAB8,5718
|
|
16
|
-
methplotlib-0.23.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
17
|
-
methplotlib-0.23.0.dist-info/entry_points.txt,sha256=Tav-_W5yZc2G8ApYYuFLfVKU2QugXuEN8z_AjPZwORs,61
|
|
18
|
-
methplotlib-0.23.0.dist-info/top_level.txt,sha256=w1XBGUmKUyGeE0_ufRQ6Vi5lMIzDq6TwF587aofDxuQ,12
|
|
19
|
-
methplotlib-0.23.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|