Skip to content

Commit

Permalink
Revert output format (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
leraman authored and matthdsm committed Jun 21, 2018
1 parent b8a2e7d commit 943a6b5
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions wisecondorX/wisetools.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ def get_weights(distances):

def generate_txt_output(args, json_out):
bed_file = open(args.outid + "_bins.bed", "w")
bed_file.write("chr\tstart\tend\tid\tzscore\tratio\n")
bed_file.write("chr\tstart\tend\tid\tratio\tzscore\n")
results_r = json_out["results_r"]
results_z = json_out["results_z"]
results_w = json_out["results_w"]
Expand All @@ -453,24 +453,24 @@ def generate_txt_output(args, json_out):
if z == 0:
z = "NaN"
feat_str = chr + ":" + str(feat) + "-" + str(feat + binsize - 1)
it = [chr, feat, feat + binsize - 1, feat_str, z, r]
it = [chr, feat, feat + binsize - 1, feat_str, r, z]
it = [str(x) for x in it]
bed_file.write("\t".join(it) + "\n")
feat += binsize
bed_file.close()

segments_file = open(args.outid + "_segments.bed", "w")
ab_file = open(args.outid + "_aberrations.bed", "w")
segments_file.write("chr\tstart\tend\tzscore\tratio\n")
ab_file.write("chr\tstart\tend\tzscore\tratio\ttype\n")
segments_file.write("chr\tstart\tend\tratio\tzscore\n")
ab_file.write("chr\tstart\tend\tratio\tzscore\ttype\n")
segments = json_out["cbs_calls"]
for segment in segments:
chr = str(int(segment[0]))
if chr == "23":
chr = "X"
if chr == "24":
chr = "Y"
it = [chr, int(segment[1] * binsize + 1), int((segment[2] + 1) * binsize), segment[3], segment[4]]
it = [chr, int(segment[1] * binsize + 1), int((segment[2] + 1) * binsize), segment[4], segment[3]]
it = [str(x) for x in it]
segments_file.write("\t".join(it) + "\n")
if float(segment[4]) > np.log2(1. + args.beta / 4):
Expand All @@ -481,7 +481,7 @@ def generate_txt_output(args, json_out):
segments_file.close()

statistics_file = open(args.outid + "_chr_statistics.txt", "w")
statistics_file.write("chr\tzscore\tratio.mean\tratio.median\n")
statistics_file.write("chr\tratio.mean\tratio.median\tzscore\n")
chrom_scores = []
for chr_i in range(len(results_r)):
chr = str(chr_i + 1)
Expand All @@ -498,9 +498,9 @@ def generate_txt_output(args, json_out):
chrom_ratio_median = np.median(R)

statistics_file.write(str(chr)
+ "\t" + str(stouffer)
+ "\t" + str(chrom_ratio_median)
+ "\t" + str(chrom_ratio_mean)
+ "\t" + str(stouffer)
+ "\n")
chrom_scores.append(chrom_ratio_mean)

Expand Down

0 comments on commit 943a6b5

Please sign in to comment.