Commits

Davide Cittaro committed be39c0f

parallelized coordinate mapping

  • Participants
  • Parent commits c654a78

Comments (0)

Files changed (1)

 n = 1 << 10
 #imsize = 640
 
+v_d2xy = np.vectorize(d2xy)
+
 for chrom in csize.keys():
   if '_' in chrom: continue
   sys.stderr.write("Processing chromosome %s\n" % chrom)
   
   chrom_length = csize[chrom]
+  c_a, r_a = vd2xy(n, (n**2 - 1) * i / chrom_length)
+
   sys.stderr.write("Processing Sample1\n")
   hc = np.zeros((n, n))
   data = Sample1.get_as_array(chrom, 0, chrom_length)
   data[np.isnan(data)] = 0
   for i in xrange(0, chrom_length):
-    c, r = d2xy(n, int(round((n**2 - 1) * i / chrom_length)))
-    hc[r][c] += data[i]
+    hc[r_a[i]][c_a[i]] += data[i]
   # dump hilbert curve in image and array
   np.save("Sample1_%s" % chrom, hc)
   plt.imshow(np.log1p(hc), origin=0, alpha=0.3, cmap=plt.cm.Blues)  
   data = Sample2.get_as_array(chrom, 0, chrom_length)
   data[np.isnan(data)] = 0
   for i in xrange(0, chrom_length):
-    c, r = d2xy(n, int(round((n**2 - 1) * i / chrom_length)))
-    hc[r][c] += data[i]
+    hc[r_a[i]][c_a[i]] += data[i]
   # dump hilbert curve in image and array
   np.save("Sample2_%s" % chrom, hc)
   plt.imshow(np.log1p(hc), origin=0, alpha=0.3, cmap=plt.cm.Reds)