seismicrna.filterscan package

seismicrna.filterscan.run(input_path: Iterable[str | Path] = Sentinel.UNSET, *, branch: str = '', tmp_pfx: str | Path = './tmp', keep_tmp: bool = False, brotli_level: int = 10, force: bool = False, num_cpus: int = 4, tile_length: int = 0, tile_min_overlap: float = 0.5, erase_tiles: bool = True, pair_fdr: float = 0.05, min_pairs: int = 2, pair_distance_percentile: float = 95.0, endpoint_window: int = 2, min_nearby_pairs: int = 2, min_cluster_length: int = 20, max_cluster_length: int = 1200, gap_mode: str = 'omit', region_coords: Iterable[tuple[str, int, int]] = (), region_primers: Iterable[tuple[str, DNA, DNA]] = (), primer_gap: int = 0, regions_file: str | None = None, count_del: bool = True, count_ins: bool = True, no_mut: Iterable[str] = (), only_mut: Iterable[str] = (), probe: str = 'DMS', mask_a: bool | None = None, mask_c: bool | None = None, mask_g: bool | None = None, mask_u: bool | None = None, mask_polya: int | None = None, mask_pos: Iterable[tuple[str, int]] = (), mask_pos_file: Iterable[str | Path] = (), drop_read: Iterable[str] = (), drop_read_file: Iterable[str | Path] = (), drop_discontig: bool = True, min_ncov_read: int = 1, min_fcov_read: float = 0.0, min_finfo_read: float = 0.95, max_fmut_read: float = 1.0, min_mut_gap: int | None = None, mut_collisions: str = 'auto', min_ninfo_pos: int = 1000, max_fmut_pos: float = 1.0, quick_unbias: bool = True, quick_unbias_thresh: float = 0.001, max_filter_iter: int = 0, filter_pos_table: bool = True, filter_read_table: bool = True, self_contained: bool = False)

Scan an RNA for domains of correlated base pairs.

Parameters:
  • branch (str) – Create a new branch of the workflow with this name [keyword-only, default: ‘’]

  • tmp_pfx (str | pathlib._local.Path) – Write all temporary files to a directory with this prefix [keyword-only, default: ‘./tmp’]

  • keep_tmp (bool) – Keep temporary files after finishing [keyword-only, default: False]

  • brotli_level (int) – Compress pickle files with this level of Brotli (0 - 11) [keyword-only, default: 10]

  • force (bool) – Force all tasks to run, overwriting any existing output files [keyword-only, default: False]

  • num_cpus (int) – Use up to this many CPUs simultaneously [keyword-only, default: 4]

  • tile_length (int) – Make each tile this length (if 0, use 2x the median read length) [keyword-only, default: 0]

  • tile_min_overlap (float) – Make adjacent tiles overlap by at least this fraction of length [keyword-only, default: 0.5]

  • erase_tiles (bool) – Erase the filter reports/batches from the tiling step [keyword-only, default: True]

  • pair_fdr (float) – Find correlated pairs at this false discovery rate (FDR) [keyword-only, default: 0.05]

  • min_pairs (int) – Cluster only the regions with at least this many correlated pairs [keyword-only, default: 2]

  • pair_distance_percentile (float) – Among pairs that survive the endpoint-peak filter, drop any pair whose L1 (Manhattan) distance to its nearest surviving neighbor exceeds this percentile of all such distances. Pairs more isolated than this threshold are treated as noise. [keyword-only, default: 95.0]

  • endpoint_window (int) – When testing whether a position is a significant hub of correlated pair endpoints, aggregate counts over a window of this many adjacent positions: forward (pos5, pos5+1, …, pos5+window) for 5’ ends, backward (pos3-window, …, pos3) for 3’ ends. Larger values boost statistical power for helices whose endpoints are not always at exactly the same position. [keyword-only, default: 2]

  • min_nearby_pairs (int) – Minimum number of other surviving pairs that must lie within the pair-distance-percentile L1 threshold for a pair to be kept. Setting this above 1 filters out small coincidental clusters of noise pairs (‘buddy noise’) at the cost of potentially clipping domain edges. [keyword-only, default: 2]

  • min_cluster_length (int) – Cluster only the regions with at least this many positions [keyword-only, default: 20]

  • max_cluster_length (int) – Cluster only the regions with no more than this many positions [keyword-only, default: 1200]

  • gap_mode (str) – If there are gaps between regions to cluster, OMIT (do not cluster) the gaps, INSERT a new region into each gap, or EXPAND the existing regions to fill the gaps [keyword-only, default: ‘omit’]

  • region_coords (Iterable) – Select a region of a reference given its 5’ and 3’ end coordinates [keyword-only, default: ()]

  • region_primers (Iterable) – Select a region of a reference given its forward and reverse primers [keyword-only, default: ()]

  • primer_gap (int) – Leave a gap of this many bases between the primer and the region [keyword-only, default: 0]

  • regions_file (str | None) – Select regions of references from coordinates/primers in a CSV file [keyword-only, default: None]

  • count_del (bool) – Count deletions as mutations [keyword-only, default: True]

  • count_ins (bool) – Count insertions as mutations [keyword-only, default: True]

  • no_mut (Iterable) – Do not count this type of mutation (overrides –count-del/ins) [keyword-only, default: ()]

  • only_mut (Iterable) – Count only this type of mutation (overrides other mutation settings) [keyword-only, default: ()]

  • probe (str) – Use the default options for this chemical probe [keyword-only, default: ‘DMS’]

  • mask_a (bool | None) – Mask positions with base A [keyword-only, default: None]

  • mask_c (bool | None) – Mask positions with base C [keyword-only, default: None]

  • mask_g (bool | None) – Mask positions with base G [keyword-only, default: None]

  • mask_u (bool | None) – Mask positions with base U [keyword-only, default: None]

  • mask_polya (int | None) – Mask stretches of at least this many consecutive A bases (0 disables); defaults to 5 for chemical probes, 0 for none [keyword-only, default: None]

  • mask_pos (Iterable) – Mask this position in this reference [keyword-only, default: ()]

  • mask_pos_file (Iterable) – Mask positions in references from a file [keyword-only, default: ()]

  • drop_read (Iterable) – Drop the read with this name [keyword-only, default: ()]

  • drop_read_file (Iterable) – Drop the reads with names in this file [keyword-only, default: ()]

  • drop_discontig (bool) – Drop paired-end reads with discontiguous mates [keyword-only, default: True]

  • min_ncov_read (int) – Drop reads with fewer than this many bases covering the region [keyword-only, default: 1]

  • min_fcov_read (float) – Drop reads covering less than this fraction of the region [keyword-only, default: 0.0]

  • min_finfo_read (float) – Drop reads with less than this fraction of informative base calls [keyword-only, default: 0.95]

  • max_fmut_read (float) – Drop reads with more than this fraction of mutated base calls [keyword-only, default: 1.0]

  • min_mut_gap (int | None) – Filter out mutations separated by fewer than this many bases [keyword-only, default: None]

  • mut_collisions (str) – If two mutations are closer than –min-mut-gap positions, MERGE the mutations, DROP the read, or AUTO-select based on the probe. [keyword-only, default: ‘auto’]

  • min_ninfo_pos (int) – Mask positions with fewer than this many informative base calls [keyword-only, default: 1000]

  • max_fmut_pos (float) – Mask positions with more than this fraction of mutated base calls [keyword-only, default: 1.0]

  • quick_unbias (bool) – Correct observer bias using a quick (typically linear time) heuristic [keyword-only, default: True]

  • quick_unbias_thresh (float) – Treat mutated fractions under this threshold as 0 with –quick-unbias [keyword-only, default: 0.001]

  • max_filter_iter (int) – Stop the filter step after this many iterations (0 for no limit) [keyword-only, default: 0]

  • filter_pos_table (bool) – Tabulate relationships per position for filter data [keyword-only, default: True]

  • filter_read_table (bool) – Tabulate relationships per read for filter data [keyword-only, default: True]

  • self_contained (bool) – Write self-contained batch files that do not require loading predecessor batches (Filter and Cluster steps), at the cost of larger files on disk [keyword-only, default: False]

Subpackages

Submodules

class seismicrna.filterscan.io.FilterScanFile

Bases: HasRegFilePath, ABC

classmethod get_step()

Step of the workflow.

class seismicrna.filterscan.io.FilterScanIO

Bases: FilterScanFile, RegFileIO, ABC

seismicrna.filterscan.main.run(input_path: Iterable[str | Path] = Sentinel.UNSET, *, branch: str = '', tmp_pfx: str | Path = './tmp', keep_tmp: bool = False, brotli_level: int = 10, force: bool = False, num_cpus: int = 4, tile_length: int = 0, tile_min_overlap: float = 0.5, erase_tiles: bool = True, pair_fdr: float = 0.05, min_pairs: int = 2, pair_distance_percentile: float = 95.0, endpoint_window: int = 2, min_nearby_pairs: int = 2, min_cluster_length: int = 20, max_cluster_length: int = 1200, gap_mode: str = 'omit', region_coords: Iterable[tuple[str, int, int]] = (), region_primers: Iterable[tuple[str, DNA, DNA]] = (), primer_gap: int = 0, regions_file: str | None = None, count_del: bool = True, count_ins: bool = True, no_mut: Iterable[str] = (), only_mut: Iterable[str] = (), probe: str = 'DMS', mask_a: bool | None = None, mask_c: bool | None = None, mask_g: bool | None = None, mask_u: bool | None = None, mask_polya: int | None = None, mask_pos: Iterable[tuple[str, int]] = (), mask_pos_file: Iterable[str | Path] = (), drop_read: Iterable[str] = (), drop_read_file: Iterable[str | Path] = (), drop_discontig: bool = True, min_ncov_read: int = 1, min_fcov_read: float = 0.0, min_finfo_read: float = 0.95, max_fmut_read: float = 1.0, min_mut_gap: int | None = None, mut_collisions: str = 'auto', min_ninfo_pos: int = 1000, max_fmut_pos: float = 1.0, quick_unbias: bool = True, quick_unbias_thresh: float = 0.001, max_filter_iter: int = 0, filter_pos_table: bool = True, filter_read_table: bool = True, self_contained: bool = False)

Scan an RNA for domains of correlated base pairs.

Parameters:
  • branch (str) – Create a new branch of the workflow with this name [keyword-only, default: ‘’]

  • tmp_pfx (str | pathlib._local.Path) – Write all temporary files to a directory with this prefix [keyword-only, default: ‘./tmp’]

  • keep_tmp (bool) – Keep temporary files after finishing [keyword-only, default: False]

  • brotli_level (int) – Compress pickle files with this level of Brotli (0 - 11) [keyword-only, default: 10]

  • force (bool) – Force all tasks to run, overwriting any existing output files [keyword-only, default: False]

  • num_cpus (int) – Use up to this many CPUs simultaneously [keyword-only, default: 4]

  • tile_length (int) – Make each tile this length (if 0, use 2x the median read length) [keyword-only, default: 0]

  • tile_min_overlap (float) – Make adjacent tiles overlap by at least this fraction of length [keyword-only, default: 0.5]

  • erase_tiles (bool) – Erase the filter reports/batches from the tiling step [keyword-only, default: True]

  • pair_fdr (float) – Find correlated pairs at this false discovery rate (FDR) [keyword-only, default: 0.05]

  • min_pairs (int) – Cluster only the regions with at least this many correlated pairs [keyword-only, default: 2]

  • pair_distance_percentile (float) – Among pairs that survive the endpoint-peak filter, drop any pair whose L1 (Manhattan) distance to its nearest surviving neighbor exceeds this percentile of all such distances. Pairs more isolated than this threshold are treated as noise. [keyword-only, default: 95.0]

  • endpoint_window (int) – When testing whether a position is a significant hub of correlated pair endpoints, aggregate counts over a window of this many adjacent positions: forward (pos5, pos5+1, …, pos5+window) for 5’ ends, backward (pos3-window, …, pos3) for 3’ ends. Larger values boost statistical power for helices whose endpoints are not always at exactly the same position. [keyword-only, default: 2]

  • min_nearby_pairs (int) – Minimum number of other surviving pairs that must lie within the pair-distance-percentile L1 threshold for a pair to be kept. Setting this above 1 filters out small coincidental clusters of noise pairs (‘buddy noise’) at the cost of potentially clipping domain edges. [keyword-only, default: 2]

  • min_cluster_length (int) – Cluster only the regions with at least this many positions [keyword-only, default: 20]

  • max_cluster_length (int) – Cluster only the regions with no more than this many positions [keyword-only, default: 1200]

  • gap_mode (str) – If there are gaps between regions to cluster, OMIT (do not cluster) the gaps, INSERT a new region into each gap, or EXPAND the existing regions to fill the gaps [keyword-only, default: ‘omit’]

  • region_coords (Iterable) – Select a region of a reference given its 5’ and 3’ end coordinates [keyword-only, default: ()]

  • region_primers (Iterable) – Select a region of a reference given its forward and reverse primers [keyword-only, default: ()]

  • primer_gap (int) – Leave a gap of this many bases between the primer and the region [keyword-only, default: 0]

  • regions_file (str | None) – Select regions of references from coordinates/primers in a CSV file [keyword-only, default: None]

  • count_del (bool) – Count deletions as mutations [keyword-only, default: True]

  • count_ins (bool) – Count insertions as mutations [keyword-only, default: True]

  • no_mut (Iterable) – Do not count this type of mutation (overrides –count-del/ins) [keyword-only, default: ()]

  • only_mut (Iterable) – Count only this type of mutation (overrides other mutation settings) [keyword-only, default: ()]

  • probe (str) – Use the default options for this chemical probe [keyword-only, default: ‘DMS’]

  • mask_a (bool | None) – Mask positions with base A [keyword-only, default: None]

  • mask_c (bool | None) – Mask positions with base C [keyword-only, default: None]

  • mask_g (bool | None) – Mask positions with base G [keyword-only, default: None]

  • mask_u (bool | None) – Mask positions with base U [keyword-only, default: None]

  • mask_polya (int | None) – Mask stretches of at least this many consecutive A bases (0 disables); defaults to 5 for chemical probes, 0 for none [keyword-only, default: None]

  • mask_pos (Iterable) – Mask this position in this reference [keyword-only, default: ()]

  • mask_pos_file (Iterable) – Mask positions in references from a file [keyword-only, default: ()]

  • drop_read (Iterable) – Drop the read with this name [keyword-only, default: ()]

  • drop_read_file (Iterable) – Drop the reads with names in this file [keyword-only, default: ()]

  • drop_discontig (bool) – Drop paired-end reads with discontiguous mates [keyword-only, default: True]

  • min_ncov_read (int) – Drop reads with fewer than this many bases covering the region [keyword-only, default: 1]

  • min_fcov_read (float) – Drop reads covering less than this fraction of the region [keyword-only, default: 0.0]

  • min_finfo_read (float) – Drop reads with less than this fraction of informative base calls [keyword-only, default: 0.95]

  • max_fmut_read (float) – Drop reads with more than this fraction of mutated base calls [keyword-only, default: 1.0]

  • min_mut_gap (int | None) – Filter out mutations separated by fewer than this many bases [keyword-only, default: None]

  • mut_collisions (str) – If two mutations are closer than –min-mut-gap positions, MERGE the mutations, DROP the read, or AUTO-select based on the probe. [keyword-only, default: ‘auto’]

  • min_ninfo_pos (int) – Mask positions with fewer than this many informative base calls [keyword-only, default: 1000]

  • max_fmut_pos (float) – Mask positions with more than this fraction of mutated base calls [keyword-only, default: 1.0]

  • quick_unbias (bool) – Correct observer bias using a quick (typically linear time) heuristic [keyword-only, default: True]

  • quick_unbias_thresh (float) – Treat mutated fractions under this threshold as 0 with –quick-unbias [keyword-only, default: 0.001]

  • max_filter_iter (int) – Stop the filter step after this many iterations (0 for no limit) [keyword-only, default: 0]

  • filter_pos_table (bool) – Tabulate relationships per position for filter data [keyword-only, default: True]

  • filter_read_table (bool) – Tabulate relationships per read for filter data [keyword-only, default: True]

  • self_contained (bool) – Write self-contained batch files that do not require loading predecessor batches (Filter and Cluster steps), at the cost of larger files on disk [keyword-only, default: False]

class seismicrna.filterscan.report.FilterScanReport(**kwargs: Any | Callable[[Report], Any])

Bases: RegReport, FilterScanIO

classmethod get_file_seg_type()

Type of the last segment in the path.

classmethod get_param_report_fields()

Parameter fields of the report.

classmethod get_result_report_fields()

Result fields of the report.

seismicrna.filterscan.write.filterscan(idmut_report_file: Path, *, branch: str, tmp_pfx: str | Path, keep_tmp: bool, brotli_level: int, force: bool, num_cpus: int, tile_length: int, tile_min_overlap: float, erase_tiles: bool, pair_fdr: float, min_pairs: int, pair_distance_percentile: float, endpoint_window: int, min_nearby_pairs: int, min_cluster_length: int, max_cluster_length: int, gap_mode: str, region_coords: Iterable[tuple[str, int, int]], region_primers: Iterable[tuple[str, DNA, DNA]], primer_gap: int, regions_file: Path | None, count_del: bool, count_ins: bool, no_mut: Iterable[str], only_mut: Iterable[str], probe: str, mask_a: bool | None, mask_c: bool | None, mask_g: bool | None, mask_u: bool | None, mask_polya: int | None, mask_pos: Iterable[tuple[str, int]], mask_pos_file: Iterable[str | Path], drop_read: Iterable[str], drop_read_file: Iterable[str | Path], drop_discontig: bool, min_ncov_read: int, min_fcov_read: float, min_finfo_read: float, max_fmut_read: float, min_mut_gap: int | None, mut_collisions: str, min_ninfo_pos: int, max_fmut_pos: float, quick_unbias: bool, quick_unbias_thresh: float, max_filter_iter: int, filter_pos_table: bool, filter_read_table: bool, self_contained: bool)

Scan one IDmut dataset for domains of correlated base pairs.

Run the filter step over overlapping tiles spanning the RNA, detect domains of correlated base pairs, filter the reads over each domain, and write a FilterScanReport recording the domain coordinates. The tiles are then deleted, leaving the domain filter results for clusterscan to cluster.