Skip to content

Commit

Permalink
Merge pull request #59 from CenterForMedicalGeneticsGhent/v1.1.6
Browse files Browse the repository at this point in the history
fixed #58
  • Loading branch information
matthdsm authored Aug 10, 2020
2 parents 0a8eb52 + e210bcb commit 37ed043
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
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.1.5'
version = '1.1.6'
dl_version = 'master' if 'dev' in version else '{}'.format(version)

setup(
Expand Down
10 changes: 5 additions & 5 deletions wisecondorX/include/plotter.R
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,12 @@ for (ab in input$results_c){
dot.cols[start:end] = color.C
}
} else {
if (z < -zcutoff){
dot.cols[start:end] = color.B
}
if (z > zcutoff){
dot.cols[start:end] = color.C
if (is.na(z)){
dot.cols[start:end] = 'grey'
next
}
if (z < -zcutoff) dot.cols[start:end] = color.B
if (z > zcutoff) dot.cols[start:end] = color.C
}
}

Expand Down
10 changes: 8 additions & 2 deletions wisecondorX/overall_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
import subprocess
import sys
import math

import numpy as np

Expand Down Expand Up @@ -69,7 +70,6 @@ def exec_R(json_dict):
except subprocess.CalledProcessError as e:
logging.critical('Rscript failed: {}'.format(e))
sys.exit()

os.remove(json_dict['infile'])
if 'outfile' in json_dict.keys():
json_out = json.load(open(json_dict['outfile']))
Expand All @@ -89,13 +89,19 @@ def get_z_score(results_c, results):
segment_nr = results_nr[segment[0]][segment[1]:segment[2]]
segment_rr = results_r[segment[0]][segment[1]:segment[2]]
segment_nr = [segment_nr[i] for i in range(len(segment_nr)) if segment_rr[i] != 0]
for i in range(len(segment_nr)):
for ii in range(len(segment_nr[i])):
if not np.isfinite(segment_nr[i][ii]):
segment_nr[i][ii] = np.nan
segment_w = results_w[segment[0]][segment[1]:segment[2]]
segment_w = [segment_w[i] for i in range(len(segment_w)) if segment_rr[i] != 0]
null_segments = [np.ma.average(x, weights=segment_w) for x in np.transpose(segment_nr)]
null_segments = [np.ma.average(np.ma.masked_array(x, np.isnan(x)), weights=segment_w) for x in np.transpose(segment_nr)]
null_mean = np.ma.mean([x for x in null_segments if np.isfinite(x)])
null_sd = np.ma.std([x for x in null_segments if np.isfinite(x)])
z = (segment[3] - null_mean) / null_sd
z = min(z, 1000) ; z = max(z, -1000)
if math.isnan(null_mean) or math.isnan(null_sd):
z = 'NaN'
zs.append(z)
return zs

Expand Down
2 changes: 2 additions & 0 deletions wisecondorX/predict_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ def _generate_segments_and_aberrations_bed(rem_input, results):
abberations_file.write('{}\tgain\n'.format('\t'.join([str(x) for x in row])))
elif float(segment[4]) < __get_aberration_cutoff(rem_input['args'].beta, ploidy)[0]:
abberations_file.write('{}\tloss\n'.format('\t'.join([str(x) for x in row])))
elif isinstance(segment[3], str):
continue
else:
if float(segment[3]) > rem_input['args'].zscore:
abberations_file.write('{}\tgain\n'.format('\t'.join([str(x) for x in row])))
Expand Down

0 comments on commit 37ed043

Please sign in to comment.