Skip to content

Commit b01c957

Browse files
authored
Merge pull request #24 from Akanksha2511/ListerLab/master
updated
2 parents 2a33fc5 + 9384d5f commit b01c957

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

scripts/HOME-pairwise

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,14 @@ def main(c,nop):
5454
val.append(functools.reduce(mergeo, d_rep.values()))
5555
df=functools.reduce(merge, val)
5656
df.pos=df.pos.astype(int)
57+
df.chr=df.pos.astype(str)
5758
df=ho.fill_na(df)
5859
else:
5960
val.append(functools.reduce(merge, d_rep.values()))
6061
df=functools.reduce(merge, val)
61-
62+
preordered = ["chr", "pos", "strand", "type"]
63+
new_cols = preordered + [co for co in df.columns if co not in preordered]
64+
df=df.reindex(columns=new_cols)
6265
df=df.sort_values(['pos'])
6366
df.to_csv(o.outputpath+'/temp_HOME/'+sample_name1+"_format_{c}.txt".format(c=c),header=True, index=False,sep='\t')
6467
df_path.append(o.outputpath+'/temp_HOME/'+sample_name1+"_format_{c}.txt".format(c=c))
@@ -147,8 +150,10 @@ def main(c,nop):
147150
df3=ho.pval_format_withrep(df_path[0])
148151

149152
smooth_exp_val=ho.smoothing(*df3.exp_val)
153+
150154
df3['smooth_val']=(smooth_exp_val-min(smooth_exp_val))/(max(smooth_exp_val)-min(smooth_exp_val))
151-
155+
df3=df3.fillna(0)
156+
df3.to_csv(o.outputpath+'/temp_HOME'+'/chunks/'+sample_name1+"VS"+sample_name2+"_df_{c}.txt".format(c=c),header=True, index=False,sep='\t')
152157
else:
153158

154159
df3=ho.pval_cal_withoutrep(df1)
@@ -158,7 +163,7 @@ def main(c,nop):
158163
input_file_path=os.getcwd()+'/training_data/training_data_CG.txt'
159164
model_path=os.getcwd()+'/saved_model/CG/'
160165
k=ho.norm_slidingwin_predict_CG(df3,input_file_path,model_path)
161-
166+
162167
len_cutoff=10
163168
tr=o.pruncutoff
164169
dmrs=ho.clustandtrim_CG(k,df3,sc,tr,dis_thres,ncb,prn,len_cutoff)
@@ -437,7 +442,8 @@ if __name__ == "__main__":
437442
#s=[ os.path.splitext(os.path.basename(x))[0] for x in glob.glob(input_files[0][0]+'/*.tsv')]
438443
s=[f.split('.')[0] for dp, dn, filenames in os.walk(o.outputpath+'/temp_HOME') for f in filenames if os.path.splitext(f)[1] == '.tsv']
439444
s = Counter(s)
440-
s=[kv for kv, v in s.iteritems() if v > 1]
445+
coun_s=len(os.walk(o.outputpath+'/temp_HOME').next()[1])
446+
s=[kv for kv, v in s.iteritems() if v == (coun_s)]
441447
os.chdir(cwd)
442448

443449

0 commit comments

Comments
 (0)