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')
Ejemplo n.º 2
0
# 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")
Ejemplo n.º 3
0
    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)')
Ejemplo n.º 4
0
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')
Ejemplo n.º 5
0
    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')
Ejemplo n.º 6
0
# 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')
Ejemplo n.º 7
0
    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')
Ejemplo n.º 8
0
#
# IonChromatogram
#

# TIC from raw data
tic = data.get_tic()
# save TIC to a file

# Get Ion Chromatograms for 4 separate m/z channels
ic = im.get_ic_at_mass(191)
ic1 = im.get_ic_at_mass(73)
ic2 = im.get_ic_at_mass(57)
ic3 = im.get_ic_at_mass(55)
# create a list of ICs for passing to plot_ics()
ics = [ic, ic1, ic2, ic3]

# load list of peaks
# NB NB NB NB You must first run proc_save_peaks.py from
# this directory to generate the peak list
peak_list = load_peaks("output/peaks.bin")

# Create a new display object, this time plot four ICs
# and the TIC, as well as the peak list
display = Display()

display.plot_tic(tic, 'TIC')
display.plot_ics(ics, ['191', '73', '57', '55'])
display.plot_peaks(peak_list, 'Peaks')
display.do_plotting('TIC, ICs, and PyMS Detected Peaks')
Ejemplo n.º 9
0
    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')
Ejemplo n.º 10
0
    ic_smooth2 = savitzky_golay(ic_smooth1)
    ic_bc = tophat(ic_smooth1, struct="1.5m")
    sim_im.set_ic_at_index(ii, ic_bc)

### Now detect peaks in the noisy simulated IntensityMatrix

pre_peak_list = BillerBiemann(sim_im, points=3, scans=2)
print "Number of peaks found in simulated data", len(pre_peak_list)

### Filter this peak list as for real_im
r = 1
# minimum number of ions, n
n = 3
# greater than or equal to threshold, t
t = 10000
# trim by relative intensity
spl = rel_threshold(pre_peak_list, r)
# trim by threshold
sim_peak_list = num_ions_threshold(spl, n, t)
print "Number of filtered peaks in simulated data", len(sim_peak_list)

### Now display the ics and the filtered peak list 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.plot_peaks(sim_peak_list, 'Peaks')
display.do_plotting('ICs, and PyMS Detected Peaks of Simulated Data')
# 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()
Ejemplo n.º 12
0
    ic_bc = tophat(ic_smooth1, struct="1.5m")
    sim_im.set_ic_at_index(ii, ic_bc)


### Now detect peaks in the noisy simulated IntensityMatrix

pre_peak_list = BillerBiemann(sim_im, points=3, scans=2)
print "Number of peaks found in simulated data", len(pre_peak_list)

### Filter this peak list as for real_im
r = 1
# minimum number of ions, n
n = 3
# greater than or equal to threshold, t
t = 10000
# trim by relative intensity
spl = rel_threshold(pre_peak_list, r)
# trim by threshold
sim_peak_list = num_ions_threshold(spl, n, t)
print "Number of filtered peaks in simulated data", len(sim_peak_list)

### Now display the ics and the filtered peak list 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.plot_peaks(sim_peak_list, 'Peaks')
display.do_plotting('ICs, and PyMS Detected Peaks of Simulated Data')
Ejemplo n.º 13
0
# IonChromatogram
#

# TIC from raw data
tic = data.get_tic()
# save TIC to a file

# Get Ion Chromatograms for 4 separate m/z channels
ic = im.get_ic_at_mass(191)
ic1 = im.get_ic_at_mass(73)
ic2 = im.get_ic_at_mass(57)
ic3 = im.get_ic_at_mass(55)
# create a list of ICs for passing to plot_ics()
ics = [ic, ic1, ic2, ic3]

# load list of peaks
# NB NB NB NB You must first run proc_save_peaks.py from
# this directory to generate the peak list
peak_list = load_peaks("output/peaks.bin") 



# Create a new display object, this time plot four ICs 
# and the TIC, as well as the peak list
display = Display()

display.plot_tic(tic, 'TIC')
display.plot_ics(ics, ['191','73','57','55'])
display.plot_peaks(peak_list, 'Peaks')
display.do_plotting('TIC, ICs, and PyMS Detected Peaks')
Ejemplo n.º 14
0
    
    # determine and set area
    area = peak_sum_area(im, peak)
    peak.set_area(area)

    # print some details
    UID = peak.get_UID()
    # height as sum of the intensities of the apexing ions
    height = sum(peak.get_mass_spectrum().mass_spec)
    print UID + ", %.2f, %.2f, %.2f" % (rt, height, peak.get_area())

# TIC from raw data
tic = data.get_tic()
# baseline correction for TIC
tic_bc = tophat(tic, struct="1.5m")

# 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_bc, 'TIC BC')
display.plot_ics(ic)
display.plot_peaks(new_peak_list, 'Peaks')
display.do_plotting('TIC, and PyMS Detected Peaks')
Ejemplo n.º 15
0
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)')
Ejemplo n.º 16
0
# 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")