gnomad.sample_qc.sex

gnomad.sample_qc.sex.adjusted_sex_ploidy_expr(…)

Create an entry expression to convert males to haploid on non-PAR X/Y and females to missing on Y.

gnomad.sample_qc.sex.adjust_sex_ploidy(mt, …)

Convert males to haploid on non-PAR X/Y, sets females to missing on Y.

gnomad.sample_qc.sex.get_ploidy_cutoffs(ht, …)

Get chromosome X and Y ploidy cutoffs for XY and XX samples.

gnomad.sample_qc.sex.get_sex_expr(…)

Create a struct with X_karyotype, Y_karyotype, and sex_karyotype.

gnomad.sample_qc.sex.adjusted_sex_ploidy_expr(locus_expr, gt_expr, karyotype_expr, xy_karyotype_str='XY', xx_karyotype_str='XX')[source]

Create an entry expression to convert males to haploid on non-PAR X/Y and females to missing on Y.

Parameters
  • locus_expr (LocusExpression) – Locus

  • gt_expr (CallExpression) – Genotype

  • karyotype_expr (StringExpression) – Karyotype

  • xy_karyotype_str (str) – Male sex karyotype representation

  • xx_karyotype_str (str) – Female sex karyotype representation

Return type

CallExpression

Returns

Genotype adjusted for sex ploidy

gnomad.sample_qc.sex.adjust_sex_ploidy(mt, sex_expr, male_str='male', female_str='female')[source]

Convert males to haploid on non-PAR X/Y, sets females to missing on Y.

Parameters
  • mt (MatrixTable) – Input MatrixTable

  • sex_expr (StringExpression) – Expression pointing to sex in MT (if not male_str or female_str, no change)

  • male_str (str) – String for males (default ‘male’)

  • female_str (str) – String for females (default ‘female’)

Return type

MatrixTable

Returns

MatrixTable with fixed ploidy for sex chromosomes

gnomad.sample_qc.sex.get_ploidy_cutoffs(ht, f_stat_cutoff, normal_ploidy_cutoff=5, aneuploidy_cutoff=6)[source]

Get chromosome X and Y ploidy cutoffs for XY and XX samples.

Note

This assumes the input hail Table has the fields f_stat, chrX_ploidy, and chrY_ploidy.

Return a tuple of sex chromosome ploidy cutoffs: ((x_ploidy_cutoffs), (y_ploidy_cutoffs)). x_ploidy_cutoffs: (upper cutoff for single X, (lower cutoff for double X, upper cutoff for double X), lower cutoff for triple X) y_ploidy_cutoffs: ((lower cutoff for single Y, upper cutoff for single Y), lower cutoff for double Y)

Uses the normal_ploidy_cutoff parameter to determine the ploidy cutoffs for XX and XY karyotypes. Uses the aneuploidy_cutoff parameter to determine the cutoffs for sex aneuploidies.

Note that f-stat is used only to split the samples into roughly ‘XX’ and ‘XY’ categories and is not used in the final karyotype annotation.

Parameters
  • ht (Table) – Table with f_stat and sex chromosome ploidies

  • f_stat_cutoff (float) – f-stat to roughly divide ‘XX’ from ‘XY’ samples. Assumes XX samples are below cutoff and XY are above cutoff.

  • normal_ploidy_cutoff (int) – Number of standard deviations to use when determining sex chromosome ploidy cutoffs for XX, XY karyotypes.

  • aneuploidy_cutoff (int) – Number of standard deviations to use when sex chromosome ploidy cutoffs for aneuploidies.

Return type

Tuple[Tuple[float, Tuple[float, float], float], Tuple[Tuple[float, float], float]]

Returns

Tuple of ploidy cutoff tuples: ((x_ploidy_cutoffs), (y_ploidy_cutoffs))

gnomad.sample_qc.sex.get_sex_expr(chr_x_ploidy, chr_y_ploidy, x_ploidy_cutoffs, y_ploidy_cutoffs)[source]

Create a struct with X_karyotype, Y_karyotype, and sex_karyotype.

Note that X0 is currently returned as ‘X’.

Parameters
  • chr_x_ploidy (NumericExpression) – Chromosome X ploidy (or relative ploidy)

  • chr_y_ploidy (NumericExpression) – Chromosome Y ploidy (or relative ploidy)

  • x_ploidy_cutoffs (Tuple[float, Tuple[float, float], float]) – Tuple of X chromosome ploidy cutoffs: (upper cutoff for single X, (lower cutoff for double X, upper cutoff for double X), lower cutoff for triple X)

  • y_ploidy_cutoffs (Tuple[Tuple[float, float], float]) – Tuple of Y chromosome ploidy cutoffs: ((lower cutoff for single Y, upper cutoff for single Y), lower cutoff for double Y)

Return type

StructExpression

Returns

Struct containing X_karyotype, Y_karyotype, and sex_karyotype