Skip to content

Commit

Permalink
save_biasfactor_table now saves corrected coverage
Browse files Browse the repository at this point in the history
Fixes a bug so that now when --save_biasfactor_table
is specified, the corrected coverage is saved as well.
Adds the --save_corrected_coverage_table flag/parameter.
  • Loading branch information
tomazou-lab committed May 4, 2022
1 parent 07ed4d7 commit 1f90eb1
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 12 deletions.
12 changes: 11 additions & 1 deletion CHANGES.txt
@@ -1,2 +1,12 @@
v0.5.0
Complete re-fractoring and overhaul.
Complete re-fractoring and overhaul.
v0.5.1
Various minor bugfixes and improvements.
v0.5.2
Improved ray import handling
v0.5.3
Make ray-core an optional dependency in meta.yaml and provide details on this in docs
v0.5.4
LIQUORICE_summary now handles samples with numerical names correctly
v0.5.5
Fixes a bug so that now when --save_biasfactor_table is specified, the corrected coverage is saved as well. Adds the --save_corrected_coverage_table flag/parameter.
4 changes: 2 additions & 2 deletions conda-recipe/meta.yaml
@@ -1,9 +1,9 @@
package:
name: liquorice
version: 0.5.4
version: 0.5.5

source:
url: https://github.com/epigen/LIQUORICE/archive/refs/tags/v0.5.4.tar.gz
url: https://github.com/epigen/LIQUORICE/archive/refs/tags/v0.5.5.tar.gz
sha256: 476aae3c29516726cd4574b93ecb49bc89e85a931068bfba74a4d1b220361020
#path: ..

Expand Down
2 changes: 1 addition & 1 deletion dockerfile
@@ -1,3 +1,3 @@
FROM condaforge/mambaforge:4.9.2-5 as conda

RUN mamba install -c bioconda -c conda-forge liquorice==0.5.4 ray-core
RUN mamba install -c bioconda -c conda-forge liquorice==0.5.5 ray-core
2 changes: 1 addition & 1 deletion docs/source/conf.py
Expand Up @@ -25,7 +25,7 @@
author = 'Peter Peneder'

# The full version, including alpha/beta/rc tags
release = '0.5.4'
release = '0.5.5'


# -- General configuration ---------------------------------------------------
Expand Down
14 changes: 11 additions & 3 deletions liquorice/LIQUORICE.py
Expand Up @@ -34,7 +34,7 @@ def parse_args():
:return: An `argparse.ArgumentParser` object storing the arguments.
"""
parser = argparse.ArgumentParser(description="LIQUORICE: A tool for bias correction and quantification of changes "
" in coverage around regions of interest in cfDNA WGS datasets",
" in coverage around regions of interest in cfDNA WGS datasets. Documentation: https://liquorice.readthedocs.io; Publication: https://doi.org/10.1093/bioadv/vbac017.",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
required_keyword_args = parser.add_argument_group('Required named arguments')

Expand Down Expand Up @@ -186,9 +186,15 @@ def parse_args():
"is not specified)",action="store_true")

optional_keyword_args_output.add_argument(
'--save_biasfactor_table', help="If set, for each region-set, save a table of coverage and biasfactor values"
'--save_biasfactor_table', help="If set, for each region-set, save a table of bin coordinates, bin number, coverage, corrected coverage and biasfactor values"
" per bin under "
"./<samplename>/<region-set name>/coverage_and_biasfactors_per_bin.csv",
"./<samplename>/<region-set name>/coverage_and_biasfactors_per_bin.csv. (Filesize can get quite large)",
action="store_true")

optional_keyword_args_output.add_argument(
'--save_corrected_coverage_table', help="If set, for each region-set, save a table of bin coordinates, bin number, coverage, and corrected coverage "
" per bin under "
"./<samplename>/<region-set name>/coverage_per_bin.csv",
action="store_true")

return parser
Expand Down Expand Up @@ -438,6 +444,7 @@ def main():
extend_to=args.extend_to,
n_cores=n_cpus_workflows,
save_biasfactor_table=args.save_biasfactor_table,
save_corrected_coverage_table=args.save_corrected_coverage_table,
use_default_fixed_sigma_values=True,
no_chr_prefix=args.no_chr_prefix,
percentile_split_core_rois=args.percentile_split_core_regions,
Expand Down Expand Up @@ -476,6 +483,7 @@ def main():
extend_to=args.extend_to,
n_cores=n_cpus_workflows,
save_biasfactor_table=args.save_biasfactor_table,
save_corrected_coverage_table=args.save_corrected_coverage_table,
use_default_fixed_sigma_values=True,
no_chr_prefix=args.no_chr_prefix,
save_training_table=args.save_training_table,
Expand Down
20 changes: 17 additions & 3 deletions liquorice/utils/Workflows.py
Expand Up @@ -226,6 +226,7 @@ def run_liquorice_on_regionset_with_pretrained_biasmodel(
binsize: int =500, extend_to: int =20000,
use_default_fixed_sigma_values: bool =True,
save_biasfactor_table: bool =False,
save_corrected_coverage_table: bool =False,
no_chr_prefix: bool=False,
percentile_split_core_rois:bool=False,
use_this_roi_biasfactortable:typing.Union[None,str]=None) -> None:
Expand Down Expand Up @@ -272,8 +273,10 @@ def run_liquorice_on_regionset_with_pretrained_biasmodel(
:param use_default_fixed_sigma_values: If `True`, use the following contraints for the sigma values of the small,
medium, and large Gaussian, repectively: 149-150 bp, 757-758 bp, and 6078-6079 bp.
:param n_cores: Maximum number of cores to use during steps that allow multiprocessing/multithreading.
:param save_biasfactor_table: If `True`, save a table of coverage and biasfactor values per bin as
:param save_biasfactor_table: If `True`, save a table of bin coordinates, bin number, coverage, corrected coverage and biasfactor values under
"coverage_and_biasfactors_per_bin.csv".
:param save_corrected_coverage_table: If `True`, save a table of bin coordinates, bin number, coverage, and corrected coverage under
"coverage_per_bin.csv".
:param no_chr_prefix: If True, set the list of allowed chromosomes to [str(i) for i in range(1,23)] instead of
["chr"+str(i) for i in range(1,23)]
:param percentile_split_core_rois: If set, split the central region into 5 bins of variable size instead of always
Expand Down Expand Up @@ -352,6 +355,10 @@ def run_liquorice_on_regionset_with_pretrained_biasmodel(
logging.info(f"Writing bins and their bias factors to .csv")
liq_table[[col for col in liq_table.columns if not col in ["sequence","mappability"]]].to_csv(
"coverage_and_biasfactors_per_bin.csv",index=False)
if save_corrected_coverage_table:
logging.info(f"Writing bins and their bias factors to .csv")
liq_table[["chromosome","start","end","bin nr.","coverage","corrected coverage"]].to_csv(
"coverage_per_bin.csv",index=False)

# Set up an object for plotting
plotting = Plotting.Plotting(
Expand Down Expand Up @@ -452,6 +459,7 @@ def run_liquorice_train_biasmodel_on_same_regions(
save_training_table: bool = False,
use_default_fixed_sigma_values: bool =True,
save_biasfactor_table: bool =False,
save_corrected_coverage_table: bool =False,
no_chr_prefix: bool=False,
percentile_split_core_rois:bool=False,
use_cross_validated_predictions:bool=False,
Expand Down Expand Up @@ -501,8 +509,10 @@ def run_liquorice_train_biasmodel_on_same_regions(
:param use_default_fixed_sigma_values: If `True`, use the following contraints for the sigma values of the small,
medium, and large Gaussian, repectively: 149-150 bp, 757-758 bp, and 6078-6079 bp.
:param n_cores: Maximum number of cores to use during steps that allow multiprocessing/multithreading.
:param save_biasfactor_table: If `True`, save a table of coverage and biasfactor values per bin as
:param save_biasfactor_table: If `True`, save a table of bin coordinates, bin number, coverage, corrected coverage and biasfactor values under
"coverage_and_biasfactors_per_bin.csv".
:param save_corrected_coverage_table: If `True`, save a table of bin coordinates, bin number, coverage, and corrected coverage under
"coverage_per_bin.csv".
:param no_chr_prefix: If True, set the list of allowed chromosomes to [str(i) for i in range(1,23)] instead of
["chr"+str(i) for i in range(1,23)]
:param biasmodel_output_path: Path to which the trained biasmodel should be saved to. Must have a
Expand Down Expand Up @@ -616,8 +626,12 @@ def run_liquorice_train_biasmodel_on_same_regions(
# write csv
if save_biasfactor_table:
logging.info(f"Writing bins and their bias factors to .csv")
liq_table_with_corr_cov[[col for col in liq_table.columns if not col in ["sequence","mappability"]]].to_csv(
liq_table_with_corr_cov[[col for col in liq_table_with_corr_cov.columns if not col in ["sequence","mappability"]]].to_csv(
"coverage_and_biasfactors_per_bin.csv",index=False)
if save_corrected_coverage_table:
logging.info(f"Writing bins and their bias factors to .csv")
liq_table_with_corr_cov[["chromosome","start","end","bin nr.","coverage","corrected coverage"]].to_csv(
"coverage_per_bin.csv",index=False)

# Set up an object for plotting
plotting = Plotting.Plotting(
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
@@ -1,6 +1,6 @@
[metadata]
name = liquorice
version = 0.5.3
version = 0.5.5
author = Peter Peneder
author_email = peter.peneder@ccri.at
description = LIQUORICE: A tool for bias correction and quantification of changes in coverage around regions of interest in cfDNA WGS datasets
Expand Down

0 comments on commit 1f90eb1

Please sign in to comment.