Skip to content

Commit

Permalink
Merge pull request #69 from CenterForMedicalGeneticsGhent/v1.2.1
Browse files Browse the repository at this point in the history
V1.2.1
  • Loading branch information
wdmeest authored Jan 26, 2021
2 parents d994f78 + ea07cf0 commit 3436705
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 30 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ technique (the test case vs the reference cases).
This file contains aberrant segments, defined by the [`--beta`](#stage-3-predict-copy-number-alterations) or
[`--zscore`](#stage-3-predict-copy-number-alterations) parameters.

### ID_chr_statistics.bed
### ID_statistics.bed

This file contains some interesting statistics for each chromosome. The definition of the Z-scores matches the one from
This file contains some interesting statistics (per chromosome and overall). The definition of the Z-scores matches the one from
the 'ID_segments.bed'. Particularly interesting for NIPT.

# Dependencies
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env python
from setuptools import setup, find_packages

version = '1.2.0'
version = '1.2.1'
dl_version = 'master' if 'dev' in version else '{}'.format(version)

setup(
Expand Down
45 changes: 22 additions & 23 deletions wisecondorX/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,37 +152,36 @@ def tool_test(args):
sample = scale_sample(sample, int(
sample_file['binsize'].item()), int(ref_file['binsize']))

gender = predict_gender(sample, ref_file['trained_cutoff'])
if not ref_file['is_nipt']:
actual_gender = predict_gender(sample, ref_file['trained_cutoff'])
if args.gender:
actual_gender = args.gender
sample = gender_correct(sample, actual_gender)
gender = args.gender
sample = gender_correct(sample, gender)
ref_gender = gender
else:
actual_gender = 'F'

if args.gender:
actual_gender = args.gender

ref_gender = actual_gender
if args.gender:
gender = args.gender
ref_gender = 'F'

logging.info('Normalizing autosomes ...')

results_r, results_z, results_w, ref_sizes, m_lr, m_z = normalize(
args, sample, ref_file, 'A')

if not ref_file['has_male'] and actual_gender == 'M':
logging.warning('This sample is male, whilst the reference is created with fewer than 5 males. '
'The female gonosomal reference will be used for X predictions. Note that these might '
'not be accurate. If the latter is desired, create a new reference and include more '
'male samples.')
ref_gender = 'F'

elif not ref_file['has_female'] and actual_gender == 'F':
logging.warning('This sample is female, whilst the reference is created with fewer than 5 females. '
'The male gonosomal reference will be used for XY predictions. Note that these might '
'not be accurate. If the latter is desired, create a new reference and include more '
'female samples.')
ref_gender = 'M'
if not ref_file['is_nipt']:
if not ref_file['has_male'] and gender == 'M':
logging.warning('This sample is male, whilst the reference is created with fewer than 5 males. '
'The female gonosomal reference will be used for X predictions. Note that these might '
'not be accurate. If the latter is desired, create a new reference and include more '
'male samples.')
ref_gender = 'F'

elif not ref_file['has_female'] and gender == 'F':
logging.warning('This sample is female, whilst the reference is created with fewer than 5 females. '
'The male gonosomal reference will be used for XY predictions. Note that these might '
'not be accurate. If the latter is desired, create a new reference and include more '
'female samples.')
ref_gender = 'M'

logging.info('Normalizing gonosomes ...')

Expand All @@ -198,7 +197,7 @@ def tool_test(args):
'binsize': int(ref_file['binsize']),
'n_reads': n_reads,
'ref_gender': ref_gender,
'actual_gender': actual_gender,
'gender': gender,
'mask': ref_file['mask.{}'.format(ref_gender)],
'bins_per_chr': ref_file['bins_per_chr.{}'.format(ref_gender)],
'masked_bins_per_chr': ref_file['masked_bins_per_chr.{}'.format(ref_gender)],
Expand Down
2 changes: 1 addition & 1 deletion wisecondorX/newref_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def train_gender_model(args, samples):
if args.plotyfrac is not None:
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(16, 6))
ax.hist(y_fractions, bins=100, normed=True)
ax.hist(y_fractions, bins=100, density=True)
ax.plot(gmm_x, gmm_y, 'r-', label='Gaussian mixture fit')
ax.set_xlim([0, 0.02])
ax.legend(loc='best')
Expand Down
6 changes: 3 additions & 3 deletions wisecondorX/predict_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ def _generate_segments_and_aberrations_bed(rem_input, results):
int(segment[2] * rem_input['binsize']),
segment[4], segment[3]]
segments_file.write('{}\n'.format('\t'.join([str(x) for x in row])))
ploidy = 2

if (chr_name == 'X' or chr_name == 'Y') and rem_input['actual_gender'] == 'M':
ploidy = 2
if (chr_name == 'X' or chr_name == 'Y') and rem_input['ref_gender'] == 'M':
ploidy = 1
if rem_input['args'].beta is not None:
if float(segment[4]) > __get_aberration_cutoff(rem_input['args'].beta, ploidy)[1]:
Expand Down Expand Up @@ -146,7 +146,7 @@ def _generate_chr_statistics_file(rem_input, results):
stats_file.write('\t'.join([str(x) for x in row]) + '\n')

stats_file.write('Gender based on --yfrac (or manually overridden by --gender): {}\n'
.format(str(rem_input['actual_gender'])))
.format(str(rem_input['gender'])))

stats_file.write('Number of reads: {}\n'
.format(str(rem_input['n_reads'])))
Expand Down

0 comments on commit 3436705

Please sign in to comment.