|
1 | 1 | #!/usr/bin/env python
|
2 | 2 | # -*- coding: utf-8 -*-
|
3 | 3 |
|
4 |
| -"""usage: blobtools plot -i BLOBDB [-p INT] [-l INT] [-c] [-n] [-s] |
5 |
| - [-r RANK] [-x TAXRULE] [--label GROUPS...] |
6 |
| - [-o PREFIX] [-m] [--sort ORDER] [--hist HIST] [--title] |
7 |
| - [--colours FILE] [--include FILE] [--exclude FILE] |
8 |
| - [--format FORMAT] [--noblobs] [--noreads] |
9 |
| - [--refcov FILE] [--catcolour FILE] |
10 |
| - [-h|--help] |
| 4 | +"""usage: blobtools blobplot -i BLOBDB [-p INT] [-l INT] [-c] [-n] [-s] |
| 5 | + [-r RANK] [-x TAXRULE] [--label GROUPS...] |
| 6 | + [-o PREFIX] [-m] [--sort ORDER] [--hist HIST] [--title] |
| 7 | + [--colours FILE] [--include FILE] [--exclude FILE] |
| 8 | + [--format FORMAT] [--noblobs] [--noreads] |
| 9 | + [--refcov FILE] [--catcolour FILE] |
| 10 | + [-h|--help] |
11 | 11 |
|
12 | 12 | Options:
|
13 | 13 | -h --help show this
|
14 | 14 | -i, --infile BLOBDB BlobDB file (created with "blobtools create")
|
15 |
| - -p, --plotgroups INT Number of (taxonomic) groups to plot, remaining |
| 15 | + -p, --plotgroups INT Number of (taxonomic) groups to plot, remaining |
16 | 16 | groups are placed in 'other' [default: 7]
|
17 | 17 | -l, --length INT Minimum sequence length considered for plotting [default: 100]
|
18 | 18 | -c, --cindex Colour blobs by 'c index' [default: False]
|
19 | 19 | -n, --nohit Hide sequences without taxonomic annotation [default: False]
|
20 | 20 | -s, --noscale Do not scale sequences by length [default: False]
|
21 | 21 | -o, --out PREFIX Output prefix
|
22 |
| - -m, --multiplot Multi-plot. Print plot after addition of each (taxonomic) group |
| 22 | + -m, --multiplot Multi-plot. Print plot after addition of each (taxonomic) group |
23 | 23 | [default: False]
|
24 | 24 | --sort <ORDER> Sort order for plotting [default: span]
|
25 | 25 | span : plot with decreasing span
|
26 |
| - count : plot with decreasing count |
27 |
| - --hist <HIST> Data for histograms [default: span] |
| 26 | + count : plot with decreasing count |
| 27 | + --hist <HIST> Data for histograms [default: span] |
28 | 28 | span : span-weighted histograms
|
29 | 29 | count : count histograms
|
30 | 30 | --title Add title of BlobDB to plot [default: False]
|
31 | 31 | -r, --rank RANK Taxonomic rank used for colouring of blobs [default: phylum]
|
32 |
| - (Supported: species, genus, family, order, phylum, superkingdom) |
33 |
| - -x, --taxrule TAXRULE Taxrule which has been used for computing taxonomy |
| 32 | + (Supported: species, genus, family, order, phylum, superkingdom) |
| 33 | + -x, --taxrule TAXRULE Taxrule which has been used for computing taxonomy |
34 | 34 | (Supported: bestsum, bestsumorder) [default: bestsum]
|
35 |
| - --label GROUPS... Relabel (taxonomic) groups (not 'all' or 'other'), |
| 35 | + --label GROUPS... Relabel (taxonomic) groups (not 'all' or 'other'), |
36 | 36 | e.g. "Bacteria=Actinobacteria,Proteobacteria"
|
37 | 37 | --colours COLOURFILE File containing colours for (taxonomic) groups
|
38 | 38 | --exclude GROUPS.. Place these (taxonomic) groups in 'other',
|
39 | 39 | e.g. "Actinobacteria,Proteobacteria"
|
40 |
| - --format FORMAT Figure format for plot (png, pdf, eps, jpeg, |
| 40 | + --format FORMAT Figure format for plot (png, pdf, eps, jpeg, |
41 | 41 | ps, svg, svgz, tiff) [default: png]
|
42 | 42 | --noblobs Omit blobplot [default: False]
|
43 | 43 | --noreads Omit plot of reads mapping [default: False]
|
44 |
| - --refcov FILE File containing number of "total" and "mapped" reads |
| 44 | + --refcov FILE File containing number of "total" and "mapped" reads |
45 | 45 | per coverage file. (e.g.: bam0,900,100). If provided, info
|
46 |
| - will be used in read coverage plot(s). |
47 |
| - --catcolour FILE Colour plot based on categories from FILE |
48 |
| - (format : "seq\tcategory"). |
49 |
| - |
| 46 | + will be used in read coverage plot(s). |
| 47 | + --catcolour FILE Colour plot based on categories from FILE |
| 48 | + (format : "seq\tcategory"). |
| 49 | +
|
50 | 50 | """
|
51 | 51 |
|
52 | 52 | from __future__ import division
|
|
64 | 64 | #print data_dir
|
65 | 65 | args = docopt(__doc__)
|
66 | 66 | blobdb_f = args['--infile']
|
67 |
| - rank = args['--rank'] |
| 67 | + rank = args['--rank'] |
68 | 68 | c_index = args['--cindex']
|
69 | 69 | min_length = int(args['--length'])
|
70 | 70 | multiplot = args['--multiplot']
|
|
79 | 79 | labels = args['--label']
|
80 | 80 | colour_f = args['--colours']
|
81 | 81 | exclude_groups = args['--exclude']
|
82 |
| - format = args['--format'] |
| 82 | + format = args['--format'] |
83 | 83 | no_plot_blobs = args['--noblobs']
|
84 | 84 | no_plot_reads = args['--noreads']
|
85 | 85 | refcov_f = args['--refcov']
|
|
96 | 96 | # Are sort_order and hist_type sane?
|
97 | 97 | if not sort_order in ['span', 'count']:
|
98 | 98 | BtLog.error('14', sort_order)
|
99 |
| - if not hist_type in ['span', 'count']: |
| 99 | + if not hist_type in ['span', 'count']: |
100 | 100 | BtLog.error('15', hist_type)
|
101 | 101 |
|
102 | 102 | # is taxrule provided?
|
103 | 103 | if taxrule not in TAXRULES:
|
104 | 104 | BtLog.error('8', taxrule)
|
105 | 105 |
|
106 | 106 | # compute labels if supplied
|
107 |
| - |
| 107 | + |
108 | 108 | user_labels = BtPlot.parse_labels(labels)
|
109 |
| - |
| 109 | + |
110 | 110 | if (exclude_groups):
|
111 | 111 | if "," in exclude_groups:
|
112 | 112 | exclude_groups = exclude_groups.rsplit(",")
|
113 | 113 | else:
|
114 | 114 | exclude_groups = exclude_groups
|
115 |
| - |
| 115 | + |
116 | 116 | refcov_dict = {}
|
117 | 117 | if (refcov_f):
|
118 | 118 | refcov_dict = BtPlot.parseRefCov(refcov_f)
|
|
122 | 122 | BtLog.error('24')
|
123 | 123 | elif (catcolour_f):
|
124 | 124 | catcolour_dict = BtPlot.parseCatColour(catcolour_f)
|
125 |
| - else: |
| 125 | + else: |
126 | 126 | pass
|
127 | 127 |
|
128 | 128 | # Load BlobDb
|
|
137 | 137 | # Is taxrule sane and was it computed?
|
138 | 138 | if taxrule not in blobDB.taxrules:
|
139 | 139 | BtLog.error('11', taxrule, blobDB.taxrules)
|
140 |
| - |
| 140 | + |
141 | 141 | data_dict, max_cov, cov_lib_dict = blobDB.getPlotData(rank, min_length, hide_nohits, taxrule, c_index, catcolour_dict)
|
142 | 142 | plotObj = BtPlot.PlotObj(data_dict, cov_lib_dict)
|
143 | 143 | plotObj.exclude_groups = exclude_groups
|
|
150 | 150 | plotObj.max_group_plot = max_group_plot
|
151 | 151 | plotObj.group_order = BtPlot.getSortedGroups(data_dict, sort_order)
|
152 | 152 | plotObj.labels.update(plotObj.group_order)
|
153 |
| - |
| 153 | + |
154 | 154 | if (user_labels):
|
155 | 155 | for group, label in user_labels.items():
|
156 | 156 | plotObj.labels.add(label)
|
|
0 commit comments