Skip to content

Commit

Permalink
Fix #337. Add --logScale and --maxFragmentLength options to bamPEFrag…
Browse files Browse the repository at this point in the history
…mentSize
  • Loading branch information
dpryan79 committed Apr 19, 2016
1 parent 7b15680 commit 90921ad
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* There is now a `subsetMatrix` script available that can be used to subset the output of computeMatrix. This is useful for preparing plots that only contain a subset of samples/region groups. Note that this isn't installed by default.
* The Galaxy wrappers were updated to include the ability to exclude blacklisted regions.
* Most functions (both at the command line and within Galaxy) that process BAM files can now filter by fragment length (--minFragmentLength and --maxFragmentLength). By default there's no filtering performed. The primary purpose of this is to facilitate ATACseq analysis, where fragment length determines whether one is processing mono-/di-/poly-nucleosome fragments. This was issue #336.
* bamPEFragmentSize now has --logScale and --maxFragmentLength options, which allow you to plot frequencies on the log scale and set the max plotted fragment length, respectively. This was issue #337.

2.2.3

Expand Down
14 changes: 13 additions & 1 deletion deeptools/bamPEFragmentSize.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ def parse_arguments():
help='Title of the plot, to be printed on top of '
'the generated image. Leave blank for no title.',
default='')
parser.add_argument('--maxFragmentLength',
help='The maximum fragment length in the histogram. A value of 0 (the default) indicates to use twice the mean fragment length',
default=0,
type=int)
parser.add_argument('--logScale',
help='Plot on the log scale',
action='store_true')
parser.add_argument('--binSize', '-bs',
metavar='INT',
help='Length in bases of the window used to sample the genome. (default 1000)',
Expand Down Expand Up @@ -109,8 +116,13 @@ def main(args=None):
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
minVal = fragment_len_dict['mean'] * 2
if args.maxFragmentLength > 0:
minVal = args.maxFragmentLength

plt.hist(fragment_len_dict['lengths'], 50,
range=(fragment_len_dict['min'], fragment_len_dict['mean'] * 2),
range=(fragment_len_dict['min'], minVal),
log=args.logScale,
normed=True)
plt.xlabel('Fragment Length')
plt.ylabel('Frequency')
Expand Down
9 changes: 9 additions & 0 deletions galaxy/wrapper/bamPEFragmentSize.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#if $advancedOpt.showAdvancedOpt == 'yes'
--binSize '$advancedOpt.binSize'
--distanceBetweenBins '$advancedOpt.distanceBetweenBins'
$advancedOpt.logScale
--maxFragmentLength '$advancedOpt.maxFragmentLength'
@blacklist@
#end if
one.bam
Expand All @@ -44,6 +46,13 @@
<param argument="--distanceBetweenBins" type="integer" value="1000000" min="0" optional="true"
label="bin spacing, in bases"
help="To reduce the computation time, not every possible genomic bin is sampled. This option allows you to set the distance between bins actually sampled from. Larger numbers are sufficient for high coverage samples, while smaller values are useful for lower coverage samples. Note that if you specify a value that results in too few (&lt;1000) reads sampled, the value will be decreased. (--distanceBetweenBins)"/>
<param argument="--logScale" type="boolean" truevalue="--logScale" falsevalue=""
label="Plot log frequencies"
help="Plot the frequencies on the log10 scale" />

<param argument="--maxFragmentLength" type="integer" min="0" value="0"
label="Maximum fragment length"
help="Maximum fragment length included in the histogram. A value of 0 (the default) denotes twice the mean fragment length" />
<expand macro="blacklist" />
</when>
</conditional>
Expand Down

0 comments on commit 90921ad

Please sign in to comment.