area = peak_sum_area(real_im, peak) peak.set_area(area) # real_peak_list is PyMS' best guess at the true peak list ################## Run Simulator ###################### # Simulator takes a peak list, time_list and mass_list # and returns an IntensityMatrix object. # The mass_list and time_list are the same for the real # data and the simulated data. time_list = real_im.get_time_list() mass_list = real_im.get_mass_list() sim_im = gcms_sim(time_list, mass_list, real_peak_list) # sim_im is an IntensityMatrix object # Now add noise to the simulated intensity matrix object scale = 1000 add_gaussc_noise(sim_im, scale) ### Now display the ics from the simulated data ics = [] for i in range(n_mz): ics.append(sim_im.get_ic_at_index(i)) display = Display() display.plot_ics(ics) display.do_plotting( 'ICs of Simulated Data with gaussian noise (constant scale)')
n_scan, n_mz = im.get_size() for ii in range(n_mz): ic = im.get_ic_at_index(ii) ic_smooth = savitzky_golay(ic) ic_base = tophat(ic_smooth, struct="1.5m") im.set_ic_at_index(ii, ic_base) # Load the experiment exper = load_expr(expr_file) # Load the peak list peak_list = exper.get_peak_list() # Pass Ion Chromatograms into a list of ICs n_mz = len(im.get_mass_list()) ic = [] for m in range(n_mz): ic.append(im.get_ic_at_index(m)) # Create a new display object, this time plot four ICs # and the TIC, as well as the peak list display = Display() display.plot_ics(ic) display.plot_peaks(peak_list, 'Peaks') display.do_plotting('ICs, and PyMS Detected Peaks')
peak.set_area(area) # real_peak_list is PyMS' best guess at the true peak list ################## Run Simulator ###################### # Simulator takes a peak list, time_list and mass_list # and returns an IntensityMatrix object. # The mass_list and time_list are the same for the real # data and the simulated data. time_list = real_im.get_time_list() mass_list = real_im.get_mass_list() sim_im = gcms_sim(time_list, mass_list, real_peak_list) # sim_im is an IntensityMatrix object # select one ic to add noise to from this simulated intensity matrix ic = sim_im.get_ic_at_mass(73) ic_add_noise = copy.deepcopy(ic) # Now add noise to the simulated intensity matrix object scale = 1000 add_gaussc_noise_ic(ic_add_noise, scale) display = Display() display.plot_ics([ic, ic_add_noise], ['Without noise', 'With noise added']) display.do_plotting('Simulated IC for m/z = 73, with and without noise')
# real_peak_list is PyMS' best guess at the true peak list ################## Run Simulator ###################### # Simulator takes a peak list, time_list and mass_list # and returns an IntensityMatrix object. # The mass_list and time_list are the same for the real # data and the simulated data. time_list = real_im.get_time_list() mass_list = real_im.get_mass_list() sim_im = gcms_sim(time_list, mass_list, real_peak_list) # sim_im is an IntensityMatrix object # Now add noise to the simulated intensity matrix object scale = 1000 cutoff = 10000 prop = 0.0003 add_gaussv_noise(sim_im, scale, cutoff, prop) ### Now display the ics from the simulated data ics = [] for i in range(n_mz): ics.append(sim_im.get_ic_at_index(i)) display = Display() display.plot_ics(ics) display.do_plotting("ICs, and PyMS Detected Peaks of Simulated Data")
peak.set_area(area) # real_peak_list is PyMS' best guess at the true peak list ################## Run Simulator ###################### # Simulator takes a peak list, time_list and mass_list # and returns an IntensityMatrix object. # The mass_list and time_list are the same for the real # data and the simulated data. time_list = real_im.get_time_list() mass_list = real_im.get_mass_list() sim_im = gcms_sim(time_list, mass_list, real_peak_list) # sim_im is an IntensityMatrix object # Now add noise to the simulated intensity matrix object scale = 1000 cutoff = 10000 prop = 0.0003 add_gaussv_noise(sim_im, scale, cutoff, prop) ### Now display the ics from the simulated data ics = [] for i in range(n_mz): ics.append(sim_im.get_ic_at_index(i)) display = Display() display.plot_ics(ics) display.do_plotting('ICs, and PyMS Detected Peaks of Simulated Data')
real_peak_list = num_ions_threshold(pl, n, t) print "Number of filtered peaks in real data: ", len(real_peak_list) # Set the peak areas for peak in real_peak_list: area = peak_sum_area(real_im, peak) peak.set_area(area) # real_peak_list is PyMS' best guess at the true peak list ################## Run Simulator ###################### # Simulator takes a peak list, time_list and mass_list # and returns an IntensityMatrix object. # The mass_list and time_list are the same for the real # data and the simulated data. time_list = real_im.get_time_list() mass_list = real_im.get_mass_list() sim_im = gcms_sim(time_list, mass_list, real_peak_list) # sim_im is an IntensityMatrix object ### Now display the ics from the simulated data ics = [] for i in range(n_mz): ics.append(sim_im.get_ic_at_index(i)) display = Display() display.plot_ics(ics) display.do_plotting('ICs of Simulated Data')
# trim by threshold new_peak_list = num_ions_threshold(pl, n, t) print "Number of filtered peaks: ", len(new_peak_list) # TIC from raw data tic = data.get_tic() # save TIC to a file # Get Ion Chromatograms for all m/z channels n_mz = len(im.get_mass_list()) ic = [] for m in range(n_mz): ic.append(im.get_ic_at_index(m)) # Create a new display object, this time plot the ICs # and the TIC, as well as the peak list display = Display() display.plot_tic(tic, 'TIC') display.plot_ics(ic) display.plot_peaks(new_peak_list, 'Peaks') display.do_plotting('TIC, and PyMS Detected Peaks')
area = peak_sum_area(real_im, peak) peak.set_area(area) # real_peak_list is PyMS' best guess at the true peak list ################## Run Simulator ###################### # Simulator takes a peak list, time_list and mass_list # and returns an IntensityMatrix object. # The mass_list and time_list are the same for the real # data and the simulated data. time_list = real_im.get_time_list() mass_list = real_im.get_mass_list() sim_im = gcms_sim(time_list, mass_list, real_peak_list) # sim_im is an IntensityMatrix object # select one ic to add noise to from this simulated intensity matrix ic = sim_im.get_ic_at_mass(73) ic_add_noise = copy.deepcopy(ic) # Now add noise to the simulated intensity matrix object scale = 1000 add_gaussc_noise_ic(ic_add_noise, scale) display = Display() display.plot_ics([ic, ic_add_noise], ['Without noise', 'With noise added']) display.do_plotting('Simulated IC for m/z = 73, with and without noise')
# trim by relative intensity pl = rel_threshold(peak_list, r) # trim by threshold new_peak_list = num_ions_threshold(pl, n, t) print "Number of filtered peaks: ", len(new_peak_list) # TIC from raw data tic = data.get_tic() # save TIC to a file # Get Ion Chromatograms for all m/z channels n_mz = len(im.get_mass_list()) ic = [] # All plotting from here on for m in range(n_mz): ic.append(im.get_ic_at_index(m)) # Create a new display object, this time plot the ICs # and the TIC, as well as the peak list display = Display() display.plot_tic(tic, 'TIC') display.plot_ics(ic) display.plot_peaks(new_peak_list, 'PyMS peaks') display.do_plotting()
for peak in real_peak_list: area = peak_sum_area(real_im, peak) peak.set_area(area) # real_peak_list is PyMS' best guess at the true peak list ################## Run Simulator ###################### # Simulator takes a peak list, time_list and mass_list # and returns an IntensityMatrix object. # The mass_list and time_list are the same for the real # data and the simulated data. time_list = real_im.get_time_list() mass_list = real_im.get_mass_list() sim_im = gcms_sim(time_list, mass_list, real_peak_list) # sim_im is an IntensityMatrix object # Now add noise to the simulated intensity matrix object scale = 1000 add_gaussc_noise(sim_im, scale) ### Now display the ics from the simulated data ics = [] for i in range(n_mz): ics.append(sim_im.get_ic_at_index(i)) display = Display() display.plot_ics(ics) display.do_plotting('ICs of Simulated Data with gaussian noise (constant scale)')
# Set the peak areas for peak in real_peak_list: area = peak_sum_area(real_im, peak) peak.set_area(area) # real_peak_list is PyMS' best guess at the true peak list ################## Run Simulator ###################### # Simulator takes a peak list, time_list and mass_list # and returns an IntensityMatrix object. # The mass_list and time_list are the same for the real # data and the simulated data. time_list = real_im.get_time_list() mass_list = real_im.get_mass_list() sim_im = gcms_sim(time_list, mass_list, real_peak_list) # sim_im is an IntensityMatrix object ### Now display the ics from the simulated data ics = [] for i in range(n_mz): ics.append(sim_im.get_ic_at_index(i)) display = Display() display.plot_ics(ics) display.do_plotting("ICs of Simulated Data")