def test_rel_abundance(mzs): data = read_mzXML(get_mzXML_sample_path()) mz, intensities, times = data["mz"], data["intensities"], data["times"] abun = get_relative_abundance(mz, intensities, mzs) npt.assert_equal(abun.shape[0], len(mzs)) npt.assert_equal(abun.shape[1], intensities.shape[0])
def test_contourf_keep(): # Test different keep_ith_scan settings # If we keep twice as many scans we don't exactly double the number of points # in the contour plot b/c each scan doesn't have the same number of points. # That being said it should be roughly double and we see that it is. # Test default settings data = read_mzXML(get_mzXML_sample_path()) mz, intensities, times = data["mz"], data["intensities"], data["times"] X, Y, Z = contourf(mz, intensities, 50, 70, keep_ith_scan=2)
def test_contourf_def(): # Test default settings data = read_mzXML(get_mzXML_sample_path()) mz, intensities, times = data["mz"], data["intensities"], data["times"] n_scans = intensities.shape[0] X, Y, Z = contourf(mz, intensities, 50, 70, keep_ith_scan=1) npt.assert_equal(X.shape, Y.shape) npt.assert_equal(Y.shape, Z.shape) # print(intensities.shape, times.shape, X.shape) npt.assert_equal(X.shape[1], times.size)
def test_read_mzXML(): data = read_mzXML(get_mzXML_sample_path()) mz, intensities, times = data["mz"], data["intensities"], data["times"] npt.assert_equal(len(intensities.shape), 2) npt.assert_equal(times.size, intensities.shape[0]) npt.assert_equal(mz.size, intensities.shape[1])
import numpy as np import pandas as pd import matplotlib.colors as colors # For log color scale from pyopenms import MSExperiment, MzXMLFile from msanalysis.data_extraction import read_mzXML from msanalysis.plotting import add_custom_ticks from msanalysis.plotting.contour import contourf from msanalysis.sample_data import get_mzXML_sample_path, get_csv_sample_path # # User specified variables # labview_file = get_csv_sample_path() mzXML_file = get_mzXML_sample_path() # Users can specify their own path like the lines below # labview_file = "/home/james/Downloads/20200228_TP.csv" # mzXML_file = "/home/james/Downloads/20200228_1175.mzXML" # labview_file = "20200612_TP.csv" # mzXML_file = "20200612_2735.mzXML" # # Read CSV Data from LabView # cols = ["time", "b", "temp", "d", "e", "f", "g", "h"] df = pd.read_csv(labview_file, names=cols) df["time"] -= df["time"][0] last_lv_time = np.array(df["time"])[-1] #
""" This example shows how to read a mzXML file and plot the first spectra using matplotlib. Author: James E. T. Smith <*****@*****.**> Date: 12/12/19 """ import matplotlib.pyplot as plt import seaborn as sns from msanalysis.data_extraction import read_mzXML from msanalysis.sample_data import get_mzXML_sample_path # # Read in CDF # data = read_mzXML(get_mzXML_sample_path()) mz, intensities, times = data["mz"], data["intensities"], data["times"] # # Plot # plt.figure() sns.set_style("darkgrid") plt.plot(mz, intensities[0], c="k") plt.xlim((30, 125)) plt.xlabel("M/Z") plt.ylabel("Intensity") plt.tight_layout() plt.savefig("figures/ex1.png", dpi=600)