def plot_single_matrix(args): cwd = os.getcwd() subdir = args.subdir os.chdir(subdir) FRETfile = args.trace FRETr = np.loadtxt(FRETfile) # Calculate transition matrix tmatrix = tmcalc.get_T_matrix(FRETr, spacing=args.spacing, framestep=args.fstep) # Unflatten matrix if necessary if tmcalc.check_matrix(tmatrix): tmatrix = tmcalc.unflatten_matrix(tmatrix) # Plot matrix if "color" in args.plot_type: diff = False ptm.plot_matrix(tmatrix, "Transition Matrix", 0, 0.5, diff) if "spy" in args.plot_type: ptm.spy_matrix(tmatrix, "Non-Zero Transitions")
def plot_difference_matrix(args): subdir = args.subdir cwd = os.getcwd() os.chdir("%s/%s" % (cwd, subdir[0])) T_matrix_1 = np.loadtxt(args.files[0]) if check_matrix(T_matrix_1): T_matrix_1 = unflatten_matrix(T_matrix_1) os.chdir(cwd) os.chdir("%s/%s" % (cwd, subdir[1])) T_matrix_2 = np.loadtxt(args.files[1]) if check_matrix(T_matrix_2): T_matrix_2 = unflatten_matrix(T_matrix_2) os.chdir(cwd) c_direc = "%s/tmatrix_compare" % (cwd) if not os.path.isdir(c_direc): os.mkdir(c_direc) os.chdir(c_direc) diff_matrix = T_matrix_1 - T_matrix_2 if args.iter != None: iter = args.iter title = "Transition Differences Iter %d and %d" % (iter[0], iter[1]) else: title = "Transition Differences" ptm.plot_matrix(diff_matrix, title, -0.5, 0.5, diff=True)
def plot_difference_matrix(args): subdir = args.subdir cwd = os.getcwd() os.chdir("%s/%s"%(cwd,subdir[0])) T_matrix_1 = np.loadtxt(args.files[0]) if check_matrix(T_matrix_1): T_matrix_1 = unflatten_matrix(T_matrix_1) os.chdir(cwd) os.chdir("%s/%s"%(cwd,subdir[1])) T_matrix_2 = np.loadtxt(args.files[1]) if check_matrix(T_matrix_2): T_matrix_2 = unflatten_matrix(T_matrix_2) os.chdir(cwd) c_direc = "%s/tmatrix_compare"%(cwd) if not os.path.isdir(c_direc): os.mkdir(c_direc) os.chdir(c_direc) diff_matrix = T_matrix_1 - T_matrix_2 if args.iter != None: iter = args.iter title = "Transition Differences Iter %d and %d"%(iter[0], iter[1]) else: title = "Transition Differences" ptm.plot_matrix(diff_matrix, title, -0.5, 0.5, diff=True)
def plot_compare(args): cwd = os.getcwd() subdir = args.subdir os.chdir(subdir) FRETfile = args.trace FRETr = np.loadtxt(FRETfile) # Load full experimental transition matrix TMfile = args.TMfile T_matrix = np.loadtxt(TMfile) # Calculate and unflatten transition matrix tmatrix = tmcalc.get_T_matrix(FRETr, spacing=args.spacing, framestep=args.fstep) if tmcalc.check_matrix(tmatrix): tmatrix = tmcalc.unflatten_matrix(tmatrix) # Calculate experimental matrix bin_size = np.size(tmatrix)**0.5 spacing = 0.1 lower_ran = spacing * (np.floor(10 * np.min(FRETr))) upper_ran = spacing * (np.ceil(10 * np.max(FRETr))) ran_size = (lower_ran, upper_ran) tmatrix_exp = xtm.tmatrix_exp_calc(T_matrix, bin_size, ran_size, spacing) if tmcalc.check_matrix(tmatrix_exp): tmatrix_exp = tmcalc.unflatten_matrix(tmatrix_exp) # Difference matrix diff_matrix = tmatrix - tmatrix_exp diff_squared = np.mean(np.abs(diff_matrix)) print "Average absolute difference is: " print diff_squared # Generate plots if "color" in args.plot_type: ptm.plot_matrix(tmatrix, "Simulated Transition Matrix", 0, 0.5) ptm.plot_matrix(tmatrix_exp, "Experimental Transition Matrix", 0, 0.5) ptm.plot_matrix(diff_matrix, "Transition Probability Differences", -0.5, 0.5, diff=True) if "spy" in args.plot_type: ptm.spy_matrix(tmatrix, "Non-zero entries, simulated") ptm.spy_matrix(tmatrix_exp, "Non-zero entries, experimental") ptm.spy_matrix(diff_matrix, "Non-zero entries, difference")
def plot_compare(args): cwd = os.getcwd() subdir = args.subdir os.chdir(subdir) FRETfile = args.trace FRETr = np.loadtxt(FRETfile) # Load full experimental transition matrix TMfile = args.TMfile T_matrix = np.loadtxt(TMfile) # Calculate and unflatten transition matrix tmatrix = tmcalc.get_T_matrix(FRETr, spacing=args.spacing, framestep=args.fstep) if tmcalc.check_matrix(tmatrix): tmatrix = tmcalc.unflatten_matrix(tmatrix) # Calculate experimental matrix bin_size = np.size(tmatrix)**0.5 spacing=0.1 lower_ran = spacing*(np.floor(10*np.min(FRETr))) upper_ran = spacing*(np.ceil(10*np.max(FRETr))) ran_size = (lower_ran, upper_ran) tmatrix_exp = xtm.tmatrix_exp_calc(T_matrix, bin_size, ran_size, spacing) if tmcalc.check_matrix(tmatrix_exp): tmatrix_exp = tmcalc.unflatten_matrix(tmatrix_exp) # Difference matrix diff_matrix = tmatrix - tmatrix_exp diff_squared = np.mean(np.abs(diff_matrix)) print "Average absolute difference is: " print diff_squared # Generate plots if "color" in args.plot_type: ptm.plot_matrix(tmatrix, "Simulated Transition Matrix", 0, 0.5) ptm.plot_matrix(tmatrix_exp, "Experimental Transition Matrix", 0, 0.5) ptm.plot_matrix(diff_matrix, "Transition Probability Differences", -0.5, 0.5, diff=True) if "spy" in args.plot_type: ptm.spy_matrix(tmatrix, "Non-zero entries, simulated") ptm.spy_matrix(tmatrix_exp, "Non-zero entries, experimental") ptm.spy_matrix(diff_matrix, "Non-zero entries, difference")