Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --fixedStep option for bigwigCompare #1028

Merged
merged 3 commits into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion deeptools/bigwigCompare.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ def parse_arguments(args=None):
'zeros may be wrong and this option should be used ',
action='store_true')

parser.add_argument('--fixedStep',
help='Output in fixed step of bin size (as specified by --binSize), not merging '
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If anyone has a better phrasing here that would be great. I think the PR is fine but the sentences is a bit confusing for me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WardDeb any idea?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed the wording is a bit confusing.
Perhaps:
'Write out all bins (of size --binSize) instead of merging neighbouring bins with equal values.' ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll take it along in develop for now and will make the change afterwards.

'neighboring bins with same values in the output file',
action='store_true')
return parser


Expand Down Expand Up @@ -168,7 +172,8 @@ def main(args=None):
format=args.outFileFormat,
smoothLength=False,
missingDataAsZero=not args.skipNonCoveredRegions,
extendPairedEnds=False)
extendPairedEnds=False,
fixedStep=args.fixedStep)

# Clean up temporary bigWig files, if applicable
if not args.deepBlueKeepTemp:
Expand Down
14 changes: 7 additions & 7 deletions deeptools/writeBedGraph_bam_and_bw.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def writeBedGraph_wrapper(args):
def writeBedGraph_worker(
chrom, start, end, tileSize, defaultFragmentLength,
bamOrBwFileList, func, funcArgs, extendPairedEnds=True, smoothLength=0,
skipZeroOverZero=False, missingDataAsZero=False, fixed_step=False):
skipZeroOverZero=False, missingDataAsZero=False, fixedStep=False):
r"""
Writes a bedgraph having as base a number of bam files.

Expand Down Expand Up @@ -103,12 +103,12 @@ def writeBedGraph_worker(

value = func(tileCoverage, funcArgs)

if fixed_step:
if fixedStep:
writeStart = start + tileIndex * tileSize
writeEnd = min(writeStart + tileSize, end)
try:
_file.write(toBytes("%s\t%d\t%d\t%.2f\n" % (chrom, writeStart,
writeEnd, value)))
_file.write(toBytes("{0}\t{1}\t{2}\t{3:g}\n".format(chrom, writeStart,
writeEnd, value)))
except TypeError:
_file.write(toBytes("{}\t{}\t{}\t{}\n".format(chrom, writeStart,
writeEnd, value)))
Expand All @@ -130,7 +130,7 @@ def writeBedGraph_worker(
writeStart = writeEnd
writeEnd = min(writeStart + tileSize, end)

if not fixed_step:
if not fixedStep:
# write remaining value if not a nan
if previousValue and writeStart != end and \
not np.isnan(previousValue):
Expand All @@ -146,7 +146,7 @@ def writeBedGraph(
bamOrBwFileList, outputFileName, fragmentLength,
func, funcArgs, tileSize=25, region=None, blackListFileName=None, numberOfProcessors=1,
format="bedgraph", extendPairedEnds=True, missingDataAsZero=False,
skipZeroOverZero=False, smoothLength=0, fixed_step=False, verbose=False):
skipZeroOverZero=False, smoothLength=0, fixedStep=False, verbose=False):
r"""
Given a list of bamfiles, a function and a function arguments,
this method writes a bedgraph file (or bigwig) file
Expand Down Expand Up @@ -205,7 +205,7 @@ def writeBedGraph(

res = mapReduce.mapReduce((tileSize, fragmentLength, bamOrBwFileList,
func, funcArgs, extendPairedEnds, smoothLength,
skipZeroOverZero, missingDataAsZero, fixed_step),
skipZeroOverZero, missingDataAsZero, fixedStep),
writeBedGraph_wrapper,
chromNamesAndSize,
genomeChunkLength=genomeChunkLength,
Expand Down