#!/usr/bin/env python-i # example of using summatrix from within python # load summon matrix library from summon import matrix # read in matrix (stored in Index Format 'imat') mat = matrix.Matrix() matrix.open_matrix("human_mouse.imat", mat, format="imat") # create and show matrix viewer viewer = matrix.MatrixViewer(mat, title="human vs mouse") viewer.show()
if row not in mat: mat[row] = {} mat[row][col] = val if symmetrize: if col not in mat: mat[col] = {} mat[col][row] = val ff.close() return nnodes, nedges infile, mtype, size, view = parse_arguments(sys.argv[1:]) from summon import matrix if mtype == "hmat": mat = matrix.Matrix() matrix.open_matrix(infile, mat, format=mtype, symmetrize=True) else: mat = {} nnodes, nedges = my_open_matrix(infile, mat, mtype, True) mini = minj = maxi = maxj = 1 for i, cols in mat.iteritems(): maxi = max(maxi, i) mini = min(mini, i) for j, val in cols.iteritems(): maxj = max(maxj, j) minj = min(minj, j) maxy = maxx = max(maxi, maxj) print mini, minj, maxi, maxj if size == 0: size = maxx
#!/usr/bin/env python-i # example of using summatrix from within python # load summon matrix library from summon import matrix # read in matrix (stored in Compressed Row Format 'rmat') mat = matrix.Matrix() matrix.open_matrix("dog_human.mat", mat, format="rmat") # create and show matrix viewer viewer = matrix.MatrixViewer(mat, title="dog vs human") viewer.show()
#!/usr/bin/env python-i # use summatrix to visualize a dense matrix # # load summon matrix library import summon from summon import matrix, util # read in matrix (stored in Index Format 'imat') mat = matrix.Matrix() matrix.open_matrix("data.mat", mat, format="dmat") # set colormap mat.colormap = summon.PosNegColorMap() # read row and column labels mat.rowlabels = util.read_strings("data.rlabels") mat.collabels = util.read_strings("data.clabels") # create and show matrix viewer viewer = matrix.MatrixViewer(mat, title="unclustered data", show_labels=True, bgcolor=(1,1,1), style="quads", winsize=(400, 600)) viewer.show()
if row not in mat: mat[row] = {} mat[row][col] = val if symmetrize: if col not in mat: mat[col] = {} mat[col][row] = val ff.close() return nnodes, nedges infile, mtype, size, view = parse_arguments(sys.argv[1:]) from summon import matrix if mtype == "hmat": mat = matrix.Matrix() matrix.open_matrix(infile, mat, format = mtype, symmetrize = True) else: mat = {} nnodes, nedges = my_open_matrix(infile, mat, mtype, True) mini = minj = maxi = maxj = 1 for i, cols in mat.iteritems(): maxi = max(maxi, i) mini = min(mini, i) for j, val in cols.iteritems(): maxj = max(maxj, j) minj = min(minj, j) maxy = maxx = max(maxi, maxj) print mini, minj, maxi, maxj if size == 0: size = maxx
# example of using summatrix from within python # view a matrix in label format print print "NOTE: try quering matrix values using the following syntax:" print " mat['human']['Cow']" print # load summon matrix library import summon from summon import matrix # read in matrix (stored in Labeled Format 'limat') mat = matrix.Matrix() mat.order = "mammals_distances.labels" # set the labels needed for matrix matrix.open_matrix("mammals_distances.lmat", mat, format="lmat") # read color map for matrix mat.colormap = summon.read_color_map("mammals_distances.colormap") # create and show matrix viewer viewer = matrix.MatrixViewer(mat, title="Mammals distances", bgcolor=(1,1,1), # use white background (r,g,b) style="quads", # use squares for matrix entries show_labels=True, # show labels show_label_windows=True) # use a separate window # for labels viewer.show()