Skip to content

Commit

Permalink
Updated normalization
Browse files Browse the repository at this point in the history
  • Loading branch information
arnavm committed Aug 5, 2020
1 parent b0ee976 commit d5f66e0
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 4 deletions.
3 changes: 3 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ Welcome to blockify's documentation!
pages/commands/normalize
pages/commands/downsample
pages/api/segmentation
pages/api/annotation
pages/api/normalization
pages/api/downsampling



Expand Down
5 changes: 5 additions & 0 deletions docs/source/pages/api/annotation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
API: annotation (peak calling)
==========================

.. automodule:: blockify.annotation
:members:
5 changes: 5 additions & 0 deletions docs/source/pages/api/downsampling.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
API: downsampling
==========================

.. automodule:: blockify.downsampling
:members:
5 changes: 5 additions & 0 deletions docs/source/pages/api/normalization.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
API: normalization
==========================

.. automodule:: blockify.normalization
:members:
2 changes: 1 addition & 1 deletion docs/source/pages/api/segmentation.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
API: Segmentation
API: segmentation
==========================

.. automodule:: blockify.segmentation
Expand Down
22 changes: 20 additions & 2 deletions lib/blockify/normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@


def validateNormalizationArguments(input_file, regions_bed, libraryFactor, lengthFactor):
"""Validates parameters passed via the command line."""
# Check that the input file is sorted
assert utilities.isSortedBEDObject(input_file), "input file must be sorted"
# Check that regions is also sorted
Expand All @@ -24,6 +25,24 @@ def validateNormalizationArguments(input_file, regions_bed, libraryFactor, lengt


def normalize(input_file, regions_bed, libraryFactor, lengthFactor):
"""Primary segmentation method
Parameters
----------
input_file: BedTool object
BedTool object (instantiated from pybedtools) for input data
regions_bed: BedTool object
BedTool object (instantiated from pybedtools) for regions over which we are normalizing input_file
libraryFactor: float
Scalar to normalize by input_file's library size.
lengthFactor: float or None
Scalar to normalize by each block's length. If None, no length normalization is performed.
Returns
-------
bedgraph: BedTool
A BedTool object in bedGraph format, using the intervals supplied in regions_bed
"""

# input_file and regions_bed are BedTool objects
# Calculate library scaling constant, which is the total number
# Validate normalization arguments
Expand Down Expand Up @@ -55,9 +74,8 @@ def normalize(input_file, regions_bed, libraryFactor, lengthFactor):
)


# Normalize the rate of events in a file over a set of regions
# Thin wrapper for normalize()
def normalize_from_command_line(args):
"""Wrapper function for the command line function ``blockify normalize``"""
input_file = BedTool(args.input)
# If regions has been supplied, use it;
if args.regions:
Expand Down
2 changes: 1 addition & 1 deletion lib/blockify/segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def segment(input_file, method, p0=None, prior=None):
method: str
String specifying whether to use OP or PELT for the segmentation
p0: float, optional
Float used to parameterize the prior on the total number of blocks; must be in the interval [0, 1]
Float used to parameterize the prior on the total number of blocks; must be in the interval [0, 1]. Default: 0.05
prior: float, optional
Explicit value for the total number of priors (specifying this is not recommended)
Expand Down

0 comments on commit d5f66e0

Please sign in to comment.