bsxplorer.RegionStat.filter
- RegionStat.filter(context: Literal['CG', 'CHG', 'CHH'] | None = None, op: Literal['<=', '<', '>', '>='] | None = None, p_value: float = 0.05, min_n: int = 0)[source]
Filter RegionStat class by P-value of methylation in selected context or minimal region counts.
E.g. \(P_{CG}\leq0.05\) or \(N_{CG}\geq20\)
Minimal counts are compared only with \(\geq\) operation.
- Parameters:
context – Methylation context (CG, CHG, CHH).
op – Comparative operation (<=, <, >, >=).
p_value – P-value for operation.
min_n – Minimal counts for cytosines methylated in selected context.
- Returns:
Filtered class.
- Return type:
Examples
>>> data = BinomialData("./A_thaliana.binom.pq").region_pvalue(genome) >>> data shape: (3, 11) ┌─────────┬────────┬─────────┬───────┬───────┬────────┬────────┬────────┬────────┬────────┬────────┐ │ chr ┆ strand ┆ id ┆ start ┆ end ┆ p_valu ┆ p_valu ┆ p_valu ┆ total_ ┆ total_ ┆ total_ │ │ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ e_cont ┆ e_cont ┆ e_cont ┆ contex ┆ contex ┆ contex │ │ cat ┆ cat ┆ str ┆ u64 ┆ u64 ┆ ext_CG ┆ ext_CH ┆ ext_CH ┆ t_CG ┆ t_CHG ┆ t_CHH │ │ ┆ ┆ ┆ ┆ ┆ --- ┆ G ┆ H ┆ --- ┆ --- ┆ --- │ │ ┆ ┆ ┆ ┆ ┆ f64 ┆ --- ┆ --- ┆ i64 ┆ i64 ┆ i64 │ │ ┆ ┆ ┆ ┆ ┆ ┆ f64 ┆ f64 ┆ ┆ ┆ │ ╞═════════╪════════╪═════════╪═══════╪═══════╪════════╪════════╪════════╪════════╪════════╪════════╡ │ NC_0030 ┆ + ┆ gene-AT ┆ 3631 ┆ 5899 ┆ 1.0 ┆ 1.0 ┆ 1.0 ┆ 60 ┆ 82 ┆ 251 │ │ 70.9 ┆ ┆ 1G01010 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │ │ NC_0030 ┆ - ┆ gene-AT ┆ 6788 ┆ 9130 ┆ 0.9992 ┆ 1.0 ┆ 1.0 ┆ 31 ┆ 55 ┆ 295 │ │ 70.9 ┆ ┆ 1G01020 ┆ ┆ ┆ 65 ┆ ┆ ┆ ┆ ┆ │ │ NC_0030 ┆ + ┆ gene-AT ┆ 11101 ┆ 11372 ┆ 1.0 ┆ 1.0 ┆ 1.0 ┆ 1 ┆ 8 ┆ 43 │ │ 70.9 ┆ ┆ 1G03987 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │ └─────────┴────────┴─────────┴───────┴───────┴────────┴────────┴────────┴────────┴────────┴────────┘ >>> data.filter("CG", "<", 0.05, 20) shape: (3, 11) ┌────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┐ │ chr ┆ strand ┆ id ┆ start ┆ end ┆ p_valu ┆ p_valu ┆ p_valu ┆ total_ ┆ total_ ┆ total_ │ │ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ e_cont ┆ e_cont ┆ e_cont ┆ contex ┆ contex ┆ contex │ │ cat ┆ cat ┆ str ┆ u64 ┆ u64 ┆ ext_CG ┆ ext_CH ┆ ext_CH ┆ t_CG ┆ t_CHG ┆ t_CHH │ │ ┆ ┆ ┆ ┆ ┆ --- ┆ G ┆ H ┆ --- ┆ --- ┆ --- │ │ ┆ ┆ ┆ ┆ ┆ f64 ┆ --- ┆ --- ┆ i64 ┆ i64 ┆ i64 │ │ ┆ ┆ ┆ ┆ ┆ ┆ f64 ┆ f64 ┆ ┆ ┆ │ ╞════════╪════════╪════════╪════════╪════════╪════════╪════════╪════════╪════════╪════════╪════════╡ │ NC_003 ┆ + ┆ gene-A ┆ 23121 ┆ 31227 ┆ 9.9920 ┆ 1.0 ┆ 1.0 ┆ 123 ┆ 171 ┆ 604 │ │ 070.9 ┆ ┆ T1G010 ┆ ┆ ┆ e-16 ┆ ┆ ┆ ┆ ┆ │ │ ┆ ┆ 40 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │ │ NC_003 ┆ - ┆ gene-A ┆ 121067 ┆ 130577 ┆ 0.0048 ┆ 1.0 ┆ 1.0 ┆ 233 ┆ 338 ┆ 1169 │ │ 070.9 ┆ ┆ T1G013 ┆ ┆ ┆ 71 ┆ ┆ ┆ ┆ ┆ │ │ ┆ ┆ 20 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │ │ NC_003 ┆ - ┆ gene-A ┆ 192634 ┆ 193670 ┆ 0.0005 ┆ 0.2612 ┆ 0.9915 ┆ 20 ┆ 22 ┆ 143 │ │ 070.9 ┆ ┆ T1G015 ┆ ┆ ┆ 71 ┆ 87 ┆ 5 ┆ ┆ ┆ │ │ ┆ ┆ 30 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │ └────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┘