DELFI¶
- finaletoolkit.frag.delfi(input_file, chrom_sizes, bins_file, reference_file, blacklist_file=None, gap_file=None, output_file=None, no_gc_correct=False, gc_correct=None, remove_nocov=True, merge_bins=True, window_size=5000000, quality_threshold=30, workers=1, verbose=False)[source]¶
Compute DELFI features, replicating Cristiano et al. (2019).
- Parameters:
input_file (str) – BAM/CRAM/fragment file of paired-end reads.
chrom_sizes (str) –
.chrom.sizesfile (autosomes only to match the original scripts).bins_file (str) – BED of bins (100kb to match the original methodology).
reference_file (str) – Reference genome (
.2bitor FASTA; FASTA required for CRAM input).blacklist_file (str, optional) – BED of regions to ignore.
gap_file (str or GenomeGaps, optional) – Telomere/centromere annotations: a BED4 file, a genome name (
"b37"/"hg19"/"hg38"/"GRCh38"), or aGenomeGaps.output_file (str, optional) – Output BED/.bed.gz/.tsv/.csv path, or
"-"for stdout.no_gc_correct (bool, optional) – Skip GC correction (default
False).gc_correct (bool, optional) – Deprecated; overrides
no_gc_correctwhen set.remove_nocov (bool, optional) – Remove the two hg19 no-coverage windows of Cristiano et al. (default
True). Disable for non-hg19 references.merge_bins (bool, optional) – Merge 100kb bins to 5Mb (default
True).window_size (int, optional) – Merge window size in bp (default 5,000,000).
quality_threshold (int, optional) – Minimum mapping quality (default 30).
workers (int, optional) – Worker-process count (default 1).
- Returns:
DELFI results with the original author’s column names.
- Return type:
- finaletoolkit.frag.delfi_gc_correct(windows, alpha=0.75, it=8, verbose=False)[source]¶
GC-correct DELFI window features with a LOESS fit per feature.
For each of
short,long,num_fragsandratio, a degree-2 LOESS curve is fit over GC content and subtracted (re-centered on the feature median), producing{feature}_correctedcolumns.- Parameters:
windows (pandas.DataFrame) – DELFI windows; must contain a
gccolumn and the feature columns.alpha (float, optional) – LOESS smoothing fraction (default 0.75).
it (int, optional) – Retained for signature compatibility (unused).
verbose (bool, optional) – Print timing.
- Returns:
A copy of
windowswith{feature}_correctedcolumns added.- Return type:
- finaletoolkit.frag.delfi_merge_bins(hundred_kb_bins, gc_corrected=True, verbose=False)[source]¶
Merge 100kb DELFI bins into non-overlapping 5Mb windows per arm.
p-arms are aggregated 5’->3’; q-arms are aggregated 3’->5’ and then reversed, matching the original DELFI scripts. Partial (<50-bin) chunks at arm ends are dropped.
- Parameters:
hundred_kb_bins (pandas.DataFrame) – 100kb bins with an
armcolumn and DELFI feature columns. Whengc_correctedisTruethe*_correctedcolumns must be present.gc_corrected (bool, optional) – Whether the input carries GC-corrected columns to aggregate (default
True). Unlike the original implementation this flag is honored, so merging works with GC correction disabled.verbose (bool, optional) – Unused; kept for signature compatibility.
- Returns:
The merged 5Mb bins, with the same columns as the input (minus any
indexcolumn).- Return type: