Skip to content

Instantly share code, notes, and snippets.

View sinamajidian's full-sized avatar

Sina Majidian sinamajidian

View GitHub Profile
@sinamajidian
sinamajidian / depth_mean_stddev.py
Created October 10, 2020 07:27 — forked from williamrowell/depth_mean_stddev.py
Calculate the mean and standard deviation of a coverage depth distribution as if it were normally distributed.
#!/usr/bin/env python3
"""Coverage mean and standard deviation of autosomes
Estimate the mean and standard deviation from a mosdepth coverage BED for
positions with coverage in the range (0, 2 * non-zero mode). This estimate
behaves well for PacBio HiFi WGS of human germline aligned to either hs37d5 and
GRCh38, and may be useful for other situations as well.
$ bash mosdepth --threads 3 --no-per-base --by 500 -m "${BAM%.*}.median" "${BAM}"
$ tabix ${BAM%.*}.median.regions.bed.gz {1..22} | python depth_mean_stddev.py