Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dump JSD matrix to a tsv file #2

Open
lljotall opened this issue Aug 11, 2017 · 1 comment
Open

Dump JSD matrix to a tsv file #2

lljotall opened this issue Aug 11, 2017 · 1 comment

Comments

@lljotall
Copy link

Hello KatolaZ,

First, I would like to say that it is very nice of you to share your code with the community.

I wrote a function to dump the JSD matrix to a .tsv file, that can be easily exported to other platforms, such as R or MATLAB. It can be extended to dump the JSD_aprox matrix as well. If you think it could be useful for others, feel free to add it to your project!

def dump_JSD_tsv(self, output_filename = 'JSD.tsv', force_compute=False):
  if self.JSD == None:
      if force_compute:
          self.compute_JSD_matrix()
      else:
          print "Error!!! call to dump_JSD_tsv but JSD matrix has not been computed!!!"
          sys.exit(1)

  f = open(output_filename, "w")
  # column names
  f.write('\t')
  for i in range(len(self.layers)):
    f.write(str(i)+'\t')
  f.write('\n')

  for i in range(len(self.layers)):
    f.write(str(i)+'\t') # rowname
    for j in range(len(self.layers)):
      f.write(str(self.JSD[i][j])+'\t')
    f.write('\n')

I also suggest replacing self.len in lines 320 and 321 for len(self.layers)

Have a good one!

@KatolaZ
Copy link
Owner

KatolaZ commented Aug 31, 2017

Hi @lljotall
sorry but I was on vacation, with scarce internet access. Will have a look at your code in the next days and incorporate it. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants