ModDotPlot 0.9.7__tar.gz → 0.9.8__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ModDotPlot
3
- Version: 0.9.7
3
+ Version: 0.9.8
4
4
  Author: Michael Schatz, Adam Phillippy
5
5
  Author-email: Alex Sweeten <alex.sweeten@nih.gov>
6
6
  Maintainer-email: Alex Sweeten <alex.sweeten@nih.gov>
@@ -87,11 +87,11 @@ If you use ModDotPlot for your research, please cite our software!
87
87
 
88
88
  ## About
89
89
 
90
- _ModDotPlot_ is a dot plot visualization tool designed for large sequences and whole genomes. _ModDotPlot_ is the spiritual successor to [StainedGlass](https://mrvollger.github.io/StainedGlass/). The core algorithm breaks an input sequence down into intervals of sketched *k*-mers called **mod**imizers, and rapidly approximating the Average Nucleotide Identity between pairwise combinations of these intervals. This significantly reduces the computational time required to produce these plots, enough to view multiple layers of resolution in real time!
90
+ _ModDotPlot_ is a dot plot visualization tool designed to be used at scale, both for smaller sequences and whole genomes. _ModDotPlot_ is the spiritual successor to [StainedGlass](https://mrvollger.github.io/StainedGlass/). The core algorithm breaks an input sequence down into intervals of sketched *k*-mers called **mod**imizers. This enables the rapid approximation of the Average Nucleotide Identity between combinations of intervals!
91
91
 
92
92
  ![](images/demo.gif)
93
93
 
94
- If you're interested in learning more about ModDotPlot and tandem repeats, you can watch my in-depth [YouTube video tutorial](https://www.youtube.com/watch?v=_7sQaljB_ys&t=2321s&pp=ygUXYWxleCBzd2VldGVuIG1vZGRvdHBsb3Q%3D) from the [BioDiversity Genomics Academy](https://thebgacademy.org).
94
+ If you're interested in learning more about _ModDotPlot_ and how to visualize tandem repeats, we have an in-depth [YouTube video tutorial](https://www.youtube.com/watch?v=_7sQaljB_ys&t=2321s&pp=ygUXYWxleCBzd2VldGVuIG1vZGRvdHBsb3Q%3D) hosted by the [BioDiversity Genomics Academy](https://thebgacademy.org).
95
95
 
96
96
  ---
97
97
 
@@ -126,11 +126,11 @@ Finally, confirm that the installation was installed correctly and that your ver
126
126
  | | | | (_) | (_| | | |__| | (_) | |_ | | | | (_) | |_
127
127
  |_| |_|\___/ \__,_| |_____/ \___/ \__| |_| |_|\___/ \__|
128
128
 
129
- v0.9.7
129
+ v0.9.8
130
130
 
131
131
  usage: moddotplot [-h] {interactive,static} ...
132
132
 
133
- ModDotPlot: Visualization of Complex Repeat Structures
133
+ ModDotPlot: Visualization of Tandem Repeats
134
134
 
135
135
  positional arguments:
136
136
  {interactive,static} Choose mode: interactive or static
@@ -138,7 +138,7 @@ positional arguments:
138
138
  static Static mode commands
139
139
 
140
140
  options:
141
- -h, --help show this help message and exit`
141
+ -h, --help show this help message and exit
142
142
  ```
143
143
  ---
144
144
 
@@ -171,7 +171,7 @@ _ModDotPlot_ supports highly customizable plotting features in static mode. See
171
171
  moddotplot interactive <ARGS>
172
172
  ```
173
173
 
174
- Running _ModDotPlot_ in interactive mode will launch a [Dash application](https://plotly.com/dash/) on your machine's localhost. Open any web browser and go to `http://127.0.0.1:<PORT_NUMBER>` to view the interactive plot (this should happen automatically, but depending on your environment you might need to copy and paste this URL into your web browser). Running `Ctrl+C` on the command line will exit the Dash application. The default port number used by Dash is `8050`, but this can be customized using the `--port` command (see [interactive mode commands](#interactive-mode-commands) for further info).
174
+ Running _ModDotPlot_ in interactive mode will launch a [Dash application](https://plotly.com/dash/) on your machine's localhost. Open any web browser and go to `http://127.0.0.1:<PORT_NUMBER>` to view the interactive plot (this should happen automatically, but depending on your environment you might need to copy and paste this URL into your web browser). Running `Ctrl+C` on the command line will exit the Dash application. The default port number used by Dash is `8050`, but this can be customized using the `--port` command (see [interactive mode commands](#interactive-mode-commands) for further info, and [Sample run - Port Forwarding](#sample-run---port-forwarding) for tips on running interactive mode on an HPC environment).
175
175
 
176
176
  ---
177
177
 
@@ -275,9 +275,17 @@ By default, vectorized outputs rasterize the actual dotplot (not the axis). This
275
275
 
276
276
  Window size. Unlike interactive mode, only one matrix will be created, so this represents the *only* window size. Default is set to `n/1000` (eg. 3000bp for a 3Mbp sequence).
277
277
 
278
+ `--region <list of strs>`
279
+
280
+ Plot only a particular range for a given sequence. Syntax is UCSC style (chr:start-end).
281
+
278
282
  `--palette <str>`
279
283
 
280
- List of accepted palettes can be found [here](https://jiffyclub.github.io/palettable/colorbrewer/). The syntax is to have the name of the palette, followed by an underscore with the number of colors, eg. `OrRd_8`. Default is `Spectral_11`.
284
+ List of accepted palettes can be found [here](https://jiffyclub.github.io/palettable/colorbrewer/). Palettes are segregated into 3 types: _Diverging_, _Qualitative_, and _Sequential_. Syntax is the name of the palette, followed by an underscore and the number of colors, eg. `OrRd_8`. Default is `Spectral_11`.
285
+
286
+ `--breakpoints <list of ints>`
287
+
288
+ Add custom identity threshold breakpoints. Note that the number of breakpoints must be equal to the number of colors + 1, otherwise an error will occur.
281
289
 
282
290
  `--palette-orientation <bool>`
283
291
 
@@ -287,10 +295,6 @@ Flip sequential order of color palette. Set to `-` by default for divergent pale
287
295
 
288
296
  List of custom colors in hexcode format can be entered sequentially, mapped from low to high identity.
289
297
 
290
- `--breakpoints <list of ints>`
291
-
292
- Add custom identity threshold breakpoints. Note that the number of breakpoints must be equal to the number of colors + 1.
293
-
294
298
  `-t / --axes-ticks <list of ints>`
295
299
 
296
300
  Custom tickmarks for x and y axis. Values outside of the `--axes-limits` will not be shown.
@@ -515,3 +519,5 @@ For bug reports or general usage questions, please raise a GitHub issue, or emai
515
519
  - Mac users might encounter the following unexpected command line output: `/bin/sh: lscpu: command not found`. This is a known issue with Plotnine, the Python plotting library used by ModDotPlot. This can be safely ignored.
516
520
 
517
521
  - If you encounter an error with the following traceback: `rv = reductor(4) TypeError: cannot pickle 'generator' object`, ths means that you have a newer version of Plotnine that is incompatible with ModDotPlot. Please uninstall plotnine and reinstall version 0.12.4 `pip install plotnine==0.12.4`.
522
+
523
+ - The error ` UserWarning: h5py is running against HDF5 1.xx.x when it was built against 1.xx.x, this may cause problems` is due to the h5py library used by cooler having conflicting versions in the dependency tree. This can also be safely ignored, but if you want to remove this message run `pip uninstall -y h5py` `pip install --no-binary=h5py h5py`
@@ -35,11 +35,11 @@ If you use ModDotPlot for your research, please cite our software!
35
35
 
36
36
  ## About
37
37
 
38
- _ModDotPlot_ is a dot plot visualization tool designed for large sequences and whole genomes. _ModDotPlot_ is the spiritual successor to [StainedGlass](https://mrvollger.github.io/StainedGlass/). The core algorithm breaks an input sequence down into intervals of sketched *k*-mers called **mod**imizers, and rapidly approximating the Average Nucleotide Identity between pairwise combinations of these intervals. This significantly reduces the computational time required to produce these plots, enough to view multiple layers of resolution in real time!
38
+ _ModDotPlot_ is a dot plot visualization tool designed to be used at scale, both for smaller sequences and whole genomes. _ModDotPlot_ is the spiritual successor to [StainedGlass](https://mrvollger.github.io/StainedGlass/). The core algorithm breaks an input sequence down into intervals of sketched *k*-mers called **mod**imizers. This enables the rapid approximation of the Average Nucleotide Identity between combinations of intervals!
39
39
 
40
40
  ![](images/demo.gif)
41
41
 
42
- If you're interested in learning more about ModDotPlot and tandem repeats, you can watch my in-depth [YouTube video tutorial](https://www.youtube.com/watch?v=_7sQaljB_ys&t=2321s&pp=ygUXYWxleCBzd2VldGVuIG1vZGRvdHBsb3Q%3D) from the [BioDiversity Genomics Academy](https://thebgacademy.org).
42
+ If you're interested in learning more about _ModDotPlot_ and how to visualize tandem repeats, we have an in-depth [YouTube video tutorial](https://www.youtube.com/watch?v=_7sQaljB_ys&t=2321s&pp=ygUXYWxleCBzd2VldGVuIG1vZGRvdHBsb3Q%3D) hosted by the [BioDiversity Genomics Academy](https://thebgacademy.org).
43
43
 
44
44
  ---
45
45
 
@@ -74,11 +74,11 @@ Finally, confirm that the installation was installed correctly and that your ver
74
74
  | | | | (_) | (_| | | |__| | (_) | |_ | | | | (_) | |_
75
75
  |_| |_|\___/ \__,_| |_____/ \___/ \__| |_| |_|\___/ \__|
76
76
 
77
- v0.9.7
77
+ v0.9.8
78
78
 
79
79
  usage: moddotplot [-h] {interactive,static} ...
80
80
 
81
- ModDotPlot: Visualization of Complex Repeat Structures
81
+ ModDotPlot: Visualization of Tandem Repeats
82
82
 
83
83
  positional arguments:
84
84
  {interactive,static} Choose mode: interactive or static
@@ -86,7 +86,7 @@ positional arguments:
86
86
  static Static mode commands
87
87
 
88
88
  options:
89
- -h, --help show this help message and exit`
89
+ -h, --help show this help message and exit
90
90
  ```
91
91
  ---
92
92
 
@@ -119,7 +119,7 @@ _ModDotPlot_ supports highly customizable plotting features in static mode. See
119
119
  moddotplot interactive <ARGS>
120
120
  ```
121
121
 
122
- Running _ModDotPlot_ in interactive mode will launch a [Dash application](https://plotly.com/dash/) on your machine's localhost. Open any web browser and go to `http://127.0.0.1:<PORT_NUMBER>` to view the interactive plot (this should happen automatically, but depending on your environment you might need to copy and paste this URL into your web browser). Running `Ctrl+C` on the command line will exit the Dash application. The default port number used by Dash is `8050`, but this can be customized using the `--port` command (see [interactive mode commands](#interactive-mode-commands) for further info).
122
+ Running _ModDotPlot_ in interactive mode will launch a [Dash application](https://plotly.com/dash/) on your machine's localhost. Open any web browser and go to `http://127.0.0.1:<PORT_NUMBER>` to view the interactive plot (this should happen automatically, but depending on your environment you might need to copy and paste this URL into your web browser). Running `Ctrl+C` on the command line will exit the Dash application. The default port number used by Dash is `8050`, but this can be customized using the `--port` command (see [interactive mode commands](#interactive-mode-commands) for further info, and [Sample run - Port Forwarding](#sample-run---port-forwarding) for tips on running interactive mode on an HPC environment).
123
123
 
124
124
  ---
125
125
 
@@ -223,9 +223,17 @@ By default, vectorized outputs rasterize the actual dotplot (not the axis). This
223
223
 
224
224
  Window size. Unlike interactive mode, only one matrix will be created, so this represents the *only* window size. Default is set to `n/1000` (eg. 3000bp for a 3Mbp sequence).
225
225
 
226
+ `--region <list of strs>`
227
+
228
+ Plot only a particular range for a given sequence. Syntax is UCSC style (chr:start-end).
229
+
226
230
  `--palette <str>`
227
231
 
228
- List of accepted palettes can be found [here](https://jiffyclub.github.io/palettable/colorbrewer/). The syntax is to have the name of the palette, followed by an underscore with the number of colors, eg. `OrRd_8`. Default is `Spectral_11`.
232
+ List of accepted palettes can be found [here](https://jiffyclub.github.io/palettable/colorbrewer/). Palettes are segregated into 3 types: _Diverging_, _Qualitative_, and _Sequential_. Syntax is the name of the palette, followed by an underscore and the number of colors, eg. `OrRd_8`. Default is `Spectral_11`.
233
+
234
+ `--breakpoints <list of ints>`
235
+
236
+ Add custom identity threshold breakpoints. Note that the number of breakpoints must be equal to the number of colors + 1, otherwise an error will occur.
229
237
 
230
238
  `--palette-orientation <bool>`
231
239
 
@@ -235,10 +243,6 @@ Flip sequential order of color palette. Set to `-` by default for divergent pale
235
243
 
236
244
  List of custom colors in hexcode format can be entered sequentially, mapped from low to high identity.
237
245
 
238
- `--breakpoints <list of ints>`
239
-
240
- Add custom identity threshold breakpoints. Note that the number of breakpoints must be equal to the number of colors + 1.
241
-
242
246
  `-t / --axes-ticks <list of ints>`
243
247
 
244
248
  Custom tickmarks for x and y axis. Values outside of the `--axes-limits` will not be shown.
@@ -463,3 +467,5 @@ For bug reports or general usage questions, please raise a GitHub issue, or emai
463
467
  - Mac users might encounter the following unexpected command line output: `/bin/sh: lscpu: command not found`. This is a known issue with Plotnine, the Python plotting library used by ModDotPlot. This can be safely ignored.
464
468
 
465
469
  - If you encounter an error with the following traceback: `rv = reductor(4) TypeError: cannot pickle 'generator' object`, ths means that you have a newer version of Plotnine that is incompatible with ModDotPlot. Please uninstall plotnine and reinstall version 0.12.4 `pip install plotnine==0.12.4`.
470
+
471
+ - The error ` UserWarning: h5py is running against HDF5 1.xx.x when it was built against 1.xx.x, this may cause problems` is due to the h5py library used by cooler having conflicting versions in the dependency tree. This can also be safely ignored, but if you want to remove this message run `pip uninstall -y h5py` `pip install --no-binary=h5py h5py`
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "ModDotPlot"
7
- version = "0.9.7"
7
+ version = "0.9.8"
8
8
  requires-python = ">= 3.7"
9
9
  dependencies = [
10
10
  "pysam",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ModDotPlot
3
- Version: 0.9.7
3
+ Version: 0.9.8
4
4
  Author: Michael Schatz, Adam Phillippy
5
5
  Author-email: Alex Sweeten <alex.sweeten@nih.gov>
6
6
  Maintainer-email: Alex Sweeten <alex.sweeten@nih.gov>
@@ -87,11 +87,11 @@ If you use ModDotPlot for your research, please cite our software!
87
87
 
88
88
  ## About
89
89
 
90
- _ModDotPlot_ is a dot plot visualization tool designed for large sequences and whole genomes. _ModDotPlot_ is the spiritual successor to [StainedGlass](https://mrvollger.github.io/StainedGlass/). The core algorithm breaks an input sequence down into intervals of sketched *k*-mers called **mod**imizers, and rapidly approximating the Average Nucleotide Identity between pairwise combinations of these intervals. This significantly reduces the computational time required to produce these plots, enough to view multiple layers of resolution in real time!
90
+ _ModDotPlot_ is a dot plot visualization tool designed to be used at scale, both for smaller sequences and whole genomes. _ModDotPlot_ is the spiritual successor to [StainedGlass](https://mrvollger.github.io/StainedGlass/). The core algorithm breaks an input sequence down into intervals of sketched *k*-mers called **mod**imizers. This enables the rapid approximation of the Average Nucleotide Identity between combinations of intervals!
91
91
 
92
92
  ![](images/demo.gif)
93
93
 
94
- If you're interested in learning more about ModDotPlot and tandem repeats, you can watch my in-depth [YouTube video tutorial](https://www.youtube.com/watch?v=_7sQaljB_ys&t=2321s&pp=ygUXYWxleCBzd2VldGVuIG1vZGRvdHBsb3Q%3D) from the [BioDiversity Genomics Academy](https://thebgacademy.org).
94
+ If you're interested in learning more about _ModDotPlot_ and how to visualize tandem repeats, we have an in-depth [YouTube video tutorial](https://www.youtube.com/watch?v=_7sQaljB_ys&t=2321s&pp=ygUXYWxleCBzd2VldGVuIG1vZGRvdHBsb3Q%3D) hosted by the [BioDiversity Genomics Academy](https://thebgacademy.org).
95
95
 
96
96
  ---
97
97
 
@@ -126,11 +126,11 @@ Finally, confirm that the installation was installed correctly and that your ver
126
126
  | | | | (_) | (_| | | |__| | (_) | |_ | | | | (_) | |_
127
127
  |_| |_|\___/ \__,_| |_____/ \___/ \__| |_| |_|\___/ \__|
128
128
 
129
- v0.9.7
129
+ v0.9.8
130
130
 
131
131
  usage: moddotplot [-h] {interactive,static} ...
132
132
 
133
- ModDotPlot: Visualization of Complex Repeat Structures
133
+ ModDotPlot: Visualization of Tandem Repeats
134
134
 
135
135
  positional arguments:
136
136
  {interactive,static} Choose mode: interactive or static
@@ -138,7 +138,7 @@ positional arguments:
138
138
  static Static mode commands
139
139
 
140
140
  options:
141
- -h, --help show this help message and exit`
141
+ -h, --help show this help message and exit
142
142
  ```
143
143
  ---
144
144
 
@@ -171,7 +171,7 @@ _ModDotPlot_ supports highly customizable plotting features in static mode. See
171
171
  moddotplot interactive <ARGS>
172
172
  ```
173
173
 
174
- Running _ModDotPlot_ in interactive mode will launch a [Dash application](https://plotly.com/dash/) on your machine's localhost. Open any web browser and go to `http://127.0.0.1:<PORT_NUMBER>` to view the interactive plot (this should happen automatically, but depending on your environment you might need to copy and paste this URL into your web browser). Running `Ctrl+C` on the command line will exit the Dash application. The default port number used by Dash is `8050`, but this can be customized using the `--port` command (see [interactive mode commands](#interactive-mode-commands) for further info).
174
+ Running _ModDotPlot_ in interactive mode will launch a [Dash application](https://plotly.com/dash/) on your machine's localhost. Open any web browser and go to `http://127.0.0.1:<PORT_NUMBER>` to view the interactive plot (this should happen automatically, but depending on your environment you might need to copy and paste this URL into your web browser). Running `Ctrl+C` on the command line will exit the Dash application. The default port number used by Dash is `8050`, but this can be customized using the `--port` command (see [interactive mode commands](#interactive-mode-commands) for further info, and [Sample run - Port Forwarding](#sample-run---port-forwarding) for tips on running interactive mode on an HPC environment).
175
175
 
176
176
  ---
177
177
 
@@ -275,9 +275,17 @@ By default, vectorized outputs rasterize the actual dotplot (not the axis). This
275
275
 
276
276
  Window size. Unlike interactive mode, only one matrix will be created, so this represents the *only* window size. Default is set to `n/1000` (eg. 3000bp for a 3Mbp sequence).
277
277
 
278
+ `--region <list of strs>`
279
+
280
+ Plot only a particular range for a given sequence. Syntax is UCSC style (chr:start-end).
281
+
278
282
  `--palette <str>`
279
283
 
280
- List of accepted palettes can be found [here](https://jiffyclub.github.io/palettable/colorbrewer/). The syntax is to have the name of the palette, followed by an underscore with the number of colors, eg. `OrRd_8`. Default is `Spectral_11`.
284
+ List of accepted palettes can be found [here](https://jiffyclub.github.io/palettable/colorbrewer/). Palettes are segregated into 3 types: _Diverging_, _Qualitative_, and _Sequential_. Syntax is the name of the palette, followed by an underscore and the number of colors, eg. `OrRd_8`. Default is `Spectral_11`.
285
+
286
+ `--breakpoints <list of ints>`
287
+
288
+ Add custom identity threshold breakpoints. Note that the number of breakpoints must be equal to the number of colors + 1, otherwise an error will occur.
281
289
 
282
290
  `--palette-orientation <bool>`
283
291
 
@@ -287,10 +295,6 @@ Flip sequential order of color palette. Set to `-` by default for divergent pale
287
295
 
288
296
  List of custom colors in hexcode format can be entered sequentially, mapped from low to high identity.
289
297
 
290
- `--breakpoints <list of ints>`
291
-
292
- Add custom identity threshold breakpoints. Note that the number of breakpoints must be equal to the number of colors + 1.
293
-
294
298
  `-t / --axes-ticks <list of ints>`
295
299
 
296
300
  Custom tickmarks for x and y axis. Values outside of the `--axes-limits` will not be shown.
@@ -515,3 +519,5 @@ For bug reports or general usage questions, please raise a GitHub issue, or emai
515
519
  - Mac users might encounter the following unexpected command line output: `/bin/sh: lscpu: command not found`. This is a known issue with Plotnine, the Python plotting library used by ModDotPlot. This can be safely ignored.
516
520
 
517
521
  - If you encounter an error with the following traceback: `rv = reductor(4) TypeError: cannot pickle 'generator' object`, ths means that you have a newer version of Plotnine that is incompatible with ModDotPlot. Please uninstall plotnine and reinstall version 0.12.4 `pip install plotnine==0.12.4`.
522
+
523
+ - The error ` UserWarning: h5py is running against HDF5 1.xx.x when it was built against 1.xx.x, this may cause problems` is due to the h5py library used by cooler having conflicting versions in the dependency tree. This can also be safely ignored, but if you want to remove this message run `pip uninstall -y h5py` `pip install --no-binary=h5py h5py`
@@ -1,4 +1,4 @@
1
- VERSION = "0.9.7"
1
+ VERSION = "0.9.8"
2
2
  COLS = [
3
3
  "#query_name",
4
4
  "query_start",
@@ -141,8 +141,10 @@ def partitionOverlaps(
141
141
  kmer_list.append(lst[final_start_index:seq_len])
142
142
 
143
143
  # Test that last value was added on correctly
144
-
145
- assert kmer_list[-1][-1] == lst[-1]
144
+ try:
145
+ assert kmer_list[-1][-1] == lst[-1]
146
+ except (AssertionError, IndexError) as e:
147
+ print(f"Error: Last k-mer does not match original sequence: {e}\n")
146
148
  return kmer_list
147
149
 
148
150
 
@@ -352,6 +354,9 @@ def selfContainmentMatrix(
352
354
  n = len(mod_set)
353
355
  progress_thresholds = round(n / 77)
354
356
 
357
+ if progress_thresholds == 0:
358
+ progress_thresholds = 1
359
+
355
360
  printProgressBar(0, n, prefix="Progress:", suffix="Complete", length=40)
356
361
  containment_matrix = np.empty((n, n))
357
362
 
@@ -410,6 +415,8 @@ def pairwiseContainmentMatrix(
410
415
  """
411
416
  n = max(len(mod_set_y), len(mod_set_x))
412
417
  progress_thresholds = round(n / 77)
418
+ if progress_thresholds == 0:
419
+ progress_thresholds = 1
413
420
 
414
421
  if not supress_progress:
415
422
  printProgressBar(0, n, prefix="Progress:", suffix="Complete", length=40)
@@ -28,7 +28,6 @@ import json
28
28
  import numpy as np
29
29
  import pickle
30
30
  import os
31
- import cooler
32
31
 
33
32
 
34
33
  def get_parser():
@@ -230,6 +229,13 @@ def get_parser():
230
229
  help="Window size, or the length in genomic coordinates of each interval. Default is set to (genome length)/(resolution)",
231
230
  )
232
231
 
232
+ static_parser.add_argument(
233
+ "--region",
234
+ default=None,
235
+ help="Genomic region to analyze. Syntax is seq_id:start-end (e.g. chr1:100000-200000).",
236
+ nargs="+",
237
+ )
238
+
233
239
  static_parser.add_argument(
234
240
  "-id",
235
241
  "--identity",
@@ -405,7 +411,6 @@ def main():
405
411
  axes = []
406
412
  for i in range(len(matrices)):
407
413
  matrix_axes = []
408
- counter = 0
409
414
  for matrix in matrices[i]:
410
415
  x_axis = [
411
416
  j * round(metadata[i]["x_size"] / matrix.shape[0])
@@ -937,6 +942,48 @@ def main():
937
942
  seq_length = len(sequences[i][1])
938
943
  seq_name = sequences[i][0]
939
944
  seq_range = extractRegion(seq_name)
945
+ if seq_range:
946
+ seq_name = seq_range[0]
947
+ # If region, then I only want to use the subsequence.
948
+ try:
949
+ if args.region:
950
+ subseq_start_pos = None
951
+ subseq_end_pos = None
952
+ for region in args.region:
953
+ chrom, lower_bound, upper_bound = extractRegion(region)
954
+ if chrom == seq_name:
955
+ subseq_start_pos = lower_bound
956
+ subseq_end_pos = upper_bound
957
+ seq_start_pos = lower_bound
958
+ # Validate bounds
959
+ if subseq_start_pos < 1 or subseq_end_pos > seq_length:
960
+ print(
961
+ f"Error: region {region} is out of bounds for {seq_name}. Will use entire sequence.\n"
962
+ )
963
+ subseq_start_pos = 1
964
+ subseq_end_pos = seq_length
965
+ seq_name = sequences[i][0]
966
+ break
967
+ print(
968
+ f"Using region {seq_name}:{subseq_start_pos}-{subseq_end_pos}\n"
969
+ )
970
+ # Change sequence length, and use a subsequence instead.
971
+ seq_length = (
972
+ subseq_end_pos - subseq_start_pos + 1 - args.kmer
973
+ )
974
+ seq_range = seq_name, subseq_start_pos, subseq_end_pos
975
+ seq_name = (
976
+ f"{seq_name}:{subseq_start_pos}-{subseq_end_pos}"
977
+ )
978
+ if not subseq_end_pos or not subseq_start_pos:
979
+ print(
980
+ f"Error: region {args.region} not found in {seq_name}. Will use entire sequence.\n"
981
+ )
982
+ seq_range = None
983
+ except Exception as e:
984
+ print(
985
+ f"Error obtaining region for {seq_name}. Will use entire sequence: {e}\n"
986
+ )
940
987
  if not seq_range:
941
988
  seq_start_pos = 1
942
989
  else:
@@ -972,17 +1019,33 @@ def main():
972
1019
  print(f"\tWindow size w: {win}\n")
973
1020
  print(f"\tModimizer sketch size: {expectation}\n")
974
1021
  print(f"\tPlot Resolution r: {res}\n")
975
- self_mat = createSelfMatrix(
976
- seq_length,
977
- sequences[i][1],
978
- win,
979
- seq_sparsity,
980
- args.delta,
981
- args.kmer,
982
- args.identity,
983
- args.ambiguous,
984
- expectation,
985
- )
1022
+ if args.region and seq_range:
1023
+ subseq = sequences[i][1][
1024
+ subseq_start_pos : (subseq_end_pos - args.kmer + 1)
1025
+ ]
1026
+ self_mat = createSelfMatrix(
1027
+ seq_length,
1028
+ subseq,
1029
+ win,
1030
+ seq_sparsity,
1031
+ args.delta,
1032
+ args.kmer,
1033
+ args.identity,
1034
+ args.ambiguous,
1035
+ expectation,
1036
+ )
1037
+ else:
1038
+ self_mat = createSelfMatrix(
1039
+ seq_length,
1040
+ sequences[i][1],
1041
+ win,
1042
+ seq_sparsity,
1043
+ args.delta,
1044
+ args.kmer,
1045
+ args.identity,
1046
+ args.ambiguous,
1047
+ expectation,
1048
+ )
986
1049
  bed = convertMatrixToBed(
987
1050
  self_mat,
988
1051
  win,
@@ -1093,11 +1156,96 @@ def main():
1093
1156
  larger_seq_start_pos = 1
1094
1157
  else:
1095
1158
  larger_seq_start_pos = int(larger_seq_range[1])
1159
+ larger_seq_name = larger_seq_range[0]
1096
1160
  smaller_seq_range = extractRegion(smaller_seq_name)
1097
- if not larger_seq_range:
1161
+ if not smaller_seq_range:
1098
1162
  smaller_seq_start_pos = 1
1099
1163
  else:
1100
1164
  smaller_seq_start_pos = int(smaller_seq_range[1])
1165
+ smaller_seq_name = smaller_seq_range[0]
1166
+
1167
+ try:
1168
+ if args.region:
1169
+ subseq_start_pos = None
1170
+ subseq_end_pos = None
1171
+ for region in args.region:
1172
+ chrom, lower_bound, upper_bound = extractRegion(region)
1173
+ if chrom == larger_seq_name:
1174
+ larger_subseq_start_pos = lower_bound
1175
+ larger_subseq_end_pos = upper_bound
1176
+ larger_seq_start_pos = lower_bound
1177
+ # Validate bounds
1178
+ if (
1179
+ larger_seq_start_pos < 1
1180
+ or larger_subseq_end_pos > larger_length
1181
+ ):
1182
+ print(
1183
+ f"Error: region {region} is out of bounds for {larger_seq_name}. Will use entire sequence.\n"
1184
+ )
1185
+ larger_subseq_start_pos = 1
1186
+ larger_subseq_end_pos = larger_length
1187
+ larger_seq_name = sequences[i][0]
1188
+ break
1189
+ print(
1190
+ f"Using region {larger_seq_name}:{larger_subseq_start_pos}-{larger_subseq_end_pos}\n"
1191
+ )
1192
+ # Change sequence length, and use a subsequence instead.
1193
+ larger_length = (
1194
+ larger_subseq_end_pos
1195
+ - larger_subseq_start_pos
1196
+ + 1
1197
+ - args.kmer
1198
+ )
1199
+ larger_seq_range = (
1200
+ larger_seq_name,
1201
+ larger_subseq_start_pos,
1202
+ larger_subseq_end_pos,
1203
+ )
1204
+ larger_seq_name = f"{larger_seq_name}:{larger_subseq_start_pos}-{larger_subseq_end_pos}"
1205
+
1206
+ if chrom == smaller_seq_name:
1207
+ smaller_subseq_start_pos = lower_bound
1208
+ smaller_subseq_end_pos = upper_bound
1209
+ smaller_seq_start_pos = lower_bound
1210
+ # Validate bounds
1211
+ if (
1212
+ smaller_seq_start_pos < 1
1213
+ or smaller_subseq_end_pos > smaller_length
1214
+ ):
1215
+ print(
1216
+ f"Error: region {region} is out of bounds for {smaller_seq_name}. Will use entire sequence.\n"
1217
+ )
1218
+ smaller_subseq_start_pos = 1
1219
+ smaller_subseq_end_pos = smaller_length
1220
+ smaller_seq_name = sequences[j][0]
1221
+ break
1222
+ print(
1223
+ f"Using region {smaller_seq_name}:{smaller_subseq_start_pos}-{smaller_subseq_end_pos}\n"
1224
+ )
1225
+ # Change sequence length, and use a subsequence instead.
1226
+ smaller_length = (
1227
+ smaller_subseq_end_pos
1228
+ - smaller_subseq_start_pos
1229
+ + 1
1230
+ - args.kmer
1231
+ )
1232
+ smaller_seq_range = (
1233
+ smaller_seq_name,
1234
+ smaller_subseq_start_pos,
1235
+ smaller_subseq_end_pos,
1236
+ )
1237
+ smaller_seq_name = f"{smaller_seq_name}:{smaller_subseq_start_pos}-{smaller_subseq_end_pos}"
1238
+ # This is wrong. Might be fine to leave alone
1239
+ if not larger_subseq_end_pos or not larger_subseq_start_pos:
1240
+ print(
1241
+ f"Error: region {args.region} not found in {seq_name}. Will use entire sequence.\n"
1242
+ )
1243
+ seq_range = None
1244
+ except Exception as e:
1245
+ print(
1246
+ f"Error obtaining region for {seq_name}. Will use entire sequence: {e}\n"
1247
+ )
1248
+
1101
1249
  win = args.window
1102
1250
  res = args.resolution
1103
1251
  if args.window:
@@ -1117,7 +1265,6 @@ def main():
1117
1265
  f"Computing pairwise identity matrix for {larger_seq_name} and {smaller_seq_name}... \n"
1118
1266
  )
1119
1267
  # TODO: Logging here
1120
- # print(f"\tSparsity value s: {seq_sparsity}\n")
1121
1268
  print(
1122
1269
  f"\tSequence length {larger_seq_name}: {larger_length + args.kmer - 1}\n"
1123
1270
  )
@@ -1128,19 +1275,52 @@ def main():
1128
1275
  print(f"\tModimizer sketch size: {expectation}\n")
1129
1276
  print(f"\tPlot Resolution r: {res}\n")
1130
1277
 
1131
- pair_mat = createPairwiseMatrix(
1132
- smaller_length,
1133
- larger_length,
1134
- smaller_seq,
1135
- larger_seq,
1136
- win,
1137
- seq_sparsity,
1138
- args.delta,
1139
- args.kmer,
1140
- args.identity,
1141
- args.ambiguous,
1142
- expectation,
1143
- )
1278
+ if args.region and (larger_seq_range or smaller_seq_range):
1279
+ if larger_seq_range:
1280
+ larger_subseq = larger_seq[
1281
+ larger_subseq_start_pos : (
1282
+ larger_subseq_end_pos - args.kmer + 1
1283
+ )
1284
+ ]
1285
+ else:
1286
+ larger_subseq = larger_seq
1287
+
1288
+ if smaller_seq_range:
1289
+ smaller_subseq = smaller_seq[
1290
+ smaller_subseq_start_pos : (
1291
+ smaller_subseq_end_pos - args.kmer + 1
1292
+ )
1293
+ ]
1294
+ else:
1295
+ smaller_subseq = smaller_seq
1296
+
1297
+ pair_mat = createPairwiseMatrix(
1298
+ smaller_length,
1299
+ larger_length,
1300
+ smaller_subseq,
1301
+ larger_subseq,
1302
+ win,
1303
+ seq_sparsity,
1304
+ args.delta,
1305
+ args.kmer,
1306
+ args.identity,
1307
+ args.ambiguous,
1308
+ expectation,
1309
+ )
1310
+ else:
1311
+ pair_mat = createPairwiseMatrix(
1312
+ smaller_length,
1313
+ larger_length,
1314
+ smaller_seq,
1315
+ larger_seq,
1316
+ win,
1317
+ seq_sparsity,
1318
+ args.delta,
1319
+ args.kmer,
1320
+ args.identity,
1321
+ args.ambiguous,
1322
+ expectation,
1323
+ )
1144
1324
  # Throw error if the matrix is empty
1145
1325
  if np.all(pair_mat == 0) and (not (args.grid or args.grid_only)):
1146
1326
  print(
@@ -13,21 +13,28 @@ tab_b = bytes.maketrans(b"ACTG", b"TGAC")
13
13
 
14
14
 
15
15
  def extractRegion(seq_name):
16
- """Check if seq_name contains a region and extract the bounds."""
17
- # Define the regular expression to match the format "chrY:50-3000"
18
- region_pattern = r"([a-zA-Z0-9]+):(\d+)-(\d+)"
16
+ """Extract chromosome and region from seq_name.
17
+
18
+ Supports:
19
+ - Standard format: "chrY:50-3000"
20
+ - Extended format: "HG002_chr13_MATERNAL:1-4000000:1000000-3000000"
21
+ (keeps the last range).
22
+ """
23
+ # Match chromosome + one or more ranges separated by colons
24
+ region_pattern = r"^([a-zA-Z0-9_]+)(?::(\d+-\d+))+"
19
25
 
20
26
  match = re.match(region_pattern, seq_name)
21
27
  if match:
22
- # Extract chromosome, lower bound, and upper bound
23
28
  chrom = match.group(1)
24
- lower_bound = int(match.group(2))
25
- upper_bound = int(match.group(3))
26
-
27
- return chrom, lower_bound, upper_bound
28
- else:
29
- # No region found
30
- return None
29
+ # Get all ranges (everything after the chrom)
30
+ ranges = re.findall(r"(\d+)-(\d+)", seq_name)
31
+ if ranges:
32
+ # Take the last range
33
+ lower_bound, upper_bound = map(int, ranges[-1])
34
+ return chrom, lower_bound, upper_bound
35
+
36
+ # No match
37
+ return None
31
38
 
32
39
 
33
40
  def generateKmersFromFasta(seq: Sequence[str], k: int, quiet: bool) -> Iterable[int]:
@@ -1980,6 +1980,11 @@ def create_plots(
1980
1980
  )
1981
1981
  if os.path.exists(f"{anno_prefix}.svg"):
1982
1982
  os.remove(f"{anno_prefix}.svg")
1983
+ cairosvg.svg2png(
1984
+ url=f"{tri_prefix}_ANNOTATED.svg",
1985
+ write_to=f"{tri_prefix}_ANNOTATED.png",
1986
+ dpi=dpi,
1987
+ )
1983
1988
  try:
1984
1989
  if vector_format != "svg":
1985
1990
  if vector_format == "pdf":
File without changes
File without changes