brentp / somalier

fast sample-swap and relatedness checks on BAMs/CRAMs/VCFs/GVCFs... "like damn that is one smart wine guy"
MIT License
262 stars 35 forks source link

Correlating the TSV columns with HTML #105

Closed SHuang-Broad closed 2 years ago

SHuang-Broad commented 2 years ago

Hi Brent,

I have a simple question regarding sex QC.

Using a 30X CCS BAM for HG00514 (unfortunately, it's named as UnnamedSample in the bam...), I got the following TSV from somalier relate

family_id | sample_id | paternal_id | maternal_id | sex | phenotype | original_pedigree_sex | gt_depth_mean | gt_depth_sd | depth_mean | depth_sd | ab_mean | ab_std | n_hom_ref | n_het | n_hom_alt | n_unknown | p_middling_ab | X_depth_mean | X_n | X_hom_ref | X_het | X_hom_alt | Y_depth_mean | Y_n

-- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- chs | UnnamedSample | 0 | 0 | 2 | 0 | female | 26.6 | 10.9 | 26.5 | 11.0 | 0.51 | 0.43 | 4964 | 3826 | 61222472 | 0.010 | 24.57 | 324 | 115 | 74 | 135 | 0.00 | 0 |  

In the HTML, here's the entry

var sample_data = [{"sample":"UnnamedSample","sex":"female","gt_depth_mean":26.56822516326648,"depth_mean":26.47785319834331,"ab_mean":0.5111052337888106,"pct_other_alleles":0.06902285407784831,"n_hom_ref":4964,"n_het":3826,"n_hom_alt":6122,"n_unknown":2472,"n_known":14912,"p_middling_ab":0.009966398997665014,"x_depth_mean":1.8498845085106,"x_hom_ref":115,"x_het":74,"x_hom_alt":135,"y_depth_mean":0.0}]

I'm curious how x_depth_mean is derived from the TSV entries (if it is indeed derived from there).

Thanks!

Steve

brentp commented 2 years ago

Hi Steve, in the html, the x_depth_mean is normalized to try to get females to ~2 and males to ~1. It uses this:

      "x_depth_mean": 2 * stats[i].x_dp.mean / stats[i].gtdp.mean,

where gtdp is the mean depth of genotyped sites in the autosome.

I think your columns must be off in the TSV table, probably n_unknown was combined with n_hom_alt . So then your tsv X_depth_mean would be 24.57

SHuang-Broad commented 2 years ago

Ah, yes, you are right. Sorry for this mistake and thanks for being patient with me.

Thank you!

brentp commented 2 years ago

no problem! glad you figured it out.