In [1]:
%matplotlib inline
import sys
import pandas as pd
import os
import tables
import pickle

# os.environ['R_LIBS_USER'] = '/project/projectdirs/metatlas/r_pkgs/'
curr_ld_lib_path = ''

# os.environ['LD_LIBRARY_PATH'] = curr_ld_lib_path + ':/project/projectdirs/openmsi/jupyterhub_libs/boost_1_55_0/lib' + ':/project/projectdirs/openmsi/jupyterhub_libs/lib'

#sys.path.insert(0, '/project/projectdirs/metatlas/python_pkgs/')
#sys.path.insert(0,'/global/project/projectdirs/metatlas/anaconda/lib/python2.7/site-packages' )
#sys.path.append('/global/project/projectdirs/openmsi/jupyterhub_libs/anaconda/lib/python2.7/site-packages')

from metatlas import metatlas_objects as metob
from metatlas import h5_query as h5q

import qgrid

from matplotlib import pyplot as plt

import dill

import numpy as np

from rdkit import Chem
from rdkit.Chem import AllChem
from rdkit.Chem import Draw
# from rdkit.Chem.rdMolDescriptors import ExactMolWt
from rdkit.Chem import Descriptors
from rdkit.Chem import rdMolDescriptors
from rdkit.Chem import AllChem
from rdkit.Chem import Draw
from rdkit.Chem import rdDepictor
from rdkit.Chem.Draw import rdMolDraw2D
from rdkit.Chem.Draw import IPythonConsole
from IPython.display import SVG,display


/home/jimmy/anaconda2/lib/python2.7/site-packages/IPython/html.py:14: ShimWarning: The `IPython.html` package has been deprecated. You should import from `notebook` instead. `IPython.html.widgets` has moved to `ipywidgets`.
  "`IPython.html.widgets` has moved to `ipywidgets`.", ShimWarning)

In [16]:
# my_file = 'save_data_pos_exudates_only.pkl'
# my_file = 'save_data_neg_exudates_only.pkl'
# my_file = 'save_data_pos_cassettes.pkl'
my_file = '20160106_save_data_pos_r2a_replicates_hilic.pkl'
# my_file = 'save_data_neg_archetypes_hilic.pkl'
# my_file = 'save_data_pos_archetypes_hilic_istds.pkl'
# project_label = 'kate_exudates_metatlas_exudates_neg_only'
project_label = '20160106_save_data_pos_r2a_replicates_hilic'

with open(my_file,'r') as f:
    data = dill.load(f)

In [3]:
print data[1][1].keys()
print data[1][1]['data'].keys()


['group', 'identification', 'lcmsrun', 'data']
['eic', 'ms1_summary', 'msms']

In [4]:
data[1][15]['data']


Out[4]:
{'eic': {'intensity': array([  3.34468408e+03,   7.56296045e+03,   2.46600781e+03,
           3.43390039e+03,   3.15061523e+03,   6.42145508e+03,
           2.98844141e+03,   6.15165039e+03,   3.76552734e+03,
           3.17461328e+03,   3.46189844e+03,   3.54673828e+03,
           1.97250781e+03,   3.09075000e+03,   3.45294531e+03,
           2.83103125e+03,   2.82762109e+03,   3.12122266e+03,
           3.63455469e+03,   2.83837500e+03,   3.49504688e+03,
           2.00257812e+03,   8.09164062e+03,   6.32307812e+03,
           2.46091406e+03,   3.11416406e+03,   6.10220312e+03,
           5.87065625e+03,   3.41347656e+03,   2.29717969e+03,
           3.40531250e+03,   2.88708594e+03,   6.22285938e+03,
           3.48564844e+03,   7.09829688e+03,   6.16707812e+03,
           8.06615625e+03,   3.61534375e+03,   7.63370312e+03,
           8.44620312e+03,   8.82268750e+03,   7.13665625e+03,
           7.67465625e+03,   8.79921875e+03,   1.09832188e+04,
           5.92689062e+03,   8.37332812e+03,   8.08581250e+03,
           9.63750000e+03,   8.71675000e+03,   8.83012500e+03,
           1.31080938e+04,   1.72070000e+04,   1.84554375e+04,
           3.20790625e+04,   4.47371250e+04,   7.74475000e+04,
           9.89211875e+04,   1.51796438e+05,   2.52811875e+05,
           3.81010438e+05,   4.68976875e+05,   6.82685000e+05,
           9.83400000e+05,   1.32700800e+06,   1.50298500e+06,
           2.08075100e+06,   2.23052600e+06,   2.94264600e+06,
           3.37761500e+06,   3.66194800e+06,   4.66007000e+06,
           4.34240400e+06,   4.96443600e+06,   5.67096000e+06,
           6.01307200e+06,   7.01794400e+06,   8.14269200e+06,
           7.89372400e+06,   7.25768800e+06,   7.79206400e+06,
           8.17224800e+06,   7.26413600e+06,   7.33439200e+06,
           6.57461600e+06,   5.79449600e+06,   5.51360000e+06,
           5.06692000e+06,   4.32510400e+06,   3.93380800e+06,
           3.26392000e+06,   2.67577600e+06,   2.24931200e+06,
           1.89424000e+06,   1.61406400e+06,   1.43830400e+06,
           1.08288000e+06,   1.03064000e+06,   9.62848000e+05,
           7.89616000e+05,   7.72032000e+05,   7.09968000e+05,
           5.81840000e+05,   6.19264000e+05,   5.25760000e+05,
           4.53392000e+05,   4.26608000e+05,   3.50352000e+05,
           3.28080000e+05,   2.74592000e+05,   2.77936000e+05,
           1.90176000e+05,   2.09600000e+05,   1.61056000e+05,
           1.49696000e+05,   1.02480000e+05,   1.02112000e+05,
           8.53600000e+04,   7.76800000e+04,   6.88480000e+04,
           7.65280000e+04,   4.56320000e+04,   4.63840000e+04,
           4.60480000e+04,   4.20000000e+04,   3.32320000e+04,
           3.60960000e+04,   2.50880000e+04,   3.22560000e+04,
           3.60320000e+04,   3.14400000e+04,   2.56640000e+04,
           2.84320000e+04,   3.15040000e+04,   2.86560000e+04,
           3.61120000e+04,   3.53600000e+04,   3.79040000e+04,
           5.03360000e+04,   4.84960000e+04,   5.74560000e+04,
           5.31200000e+04,   7.49280000e+04,   7.39200000e+04,
           9.65600000e+04,   1.23904000e+05,   1.25120000e+05,
           1.13040000e+05,   1.21696000e+05,   1.22240000e+05,
           1.25712000e+05,   1.14864000e+05,   1.25888000e+05,
           8.37920000e+04,   8.29920000e+04,   9.55360000e+04,
           1.02144000e+05,   8.15200000e+04,   7.89280000e+04,
           8.88480000e+04,   8.64800000e+04,   9.36160000e+04,
           8.47200000e+04,   8.42400000e+04], dtype=float32),
  'polarity': 1,
  'rt': array([  8.92443085,   8.94357681,   8.95317078,   8.96275806,
           8.98207092,   8.99186611,   9.00158119,   9.01137257,
           9.0210104 ,   9.03081417,   9.04061604,   9.05038261,
           9.06018543,   9.06998348,   9.07974148,   9.08955002,
           9.09936237,   9.10916424,   9.11897278,   9.12877274,
           9.13856888,   9.14837456,   9.15778732,   9.16758919,
           9.17738914,   9.18719101,   9.19699574,   9.20679951,
           9.21658993,   9.22639179,   9.23618507,   9.24597454,
           9.25578308,   9.26558113,   9.2753849 ,   9.28520393,
           9.29499817,   9.30480194,   9.31459999,   9.32441235,
           9.33422089,   9.34402084,   9.35383511,   9.36364174,
           9.3734436 ,   9.38324547,   9.39305401,   9.40283775,
           9.41264153,   9.42244339,   9.43225002,   9.44204617,
           9.45184326,   9.46164989,   9.47145176,   9.4812727 ,
           9.49108124,   9.50087643,   9.51066875,   9.5204668 ,
           9.53025818,   9.54008102,   9.54981422,   9.55964756,
           9.56945419,   9.57924366,   9.58905029,   9.59885216,
           9.60864162,   9.61844158,   9.62824345,   9.63804626,
           9.64783764,   9.6576519 ,   9.66745853,   9.67726898,
           9.68706417,   9.6968565 ,   9.70665455,   9.71646023,
           9.72629833,   9.73609543,   9.74592113,   9.75575161,
           9.76555634,   9.77536011,   9.78514576,   9.79493141,
           9.80473518,   9.81448555,   9.82427692,   9.83400631,
           9.84374809,   9.85336685,   9.86284637,   9.87231064,
           9.8817358 ,   9.89090157,   9.90018368,   9.90941048,
           9.91864586,   9.92780876,   9.93700218,   9.94602489,
           9.95481873,   9.96410179,   9.9729147 ,   9.98228359,
           9.99170399,  10.00119781,  10.01077938,  10.01976871,
          10.02938747,  10.03892899,  10.0485754 ,  10.05830574,
          10.06792736,  10.07760429,  10.08721733,  10.09687328,
          10.10646725,  10.11590576,  10.12532139,  10.13468838,
          10.14416504,  10.15376282,  10.16333771,  10.17272663,
          10.18225193,  10.19174957,  10.20117664,  10.21091747,
          10.22072697,  10.230546  ,  10.24034214,  10.25013065,
          10.25994968,  10.26974583,  10.27955246,  10.28936481,
          10.29917717,  10.30893803,  10.31855774,  10.32812691,
          10.33734798,  10.34615612,  10.35495186,  10.36381721,
          10.37265205,  10.38154793,  10.39042282,  10.39886475,
          10.40773582,  10.41673183,  10.42567062,  10.43464184,
          10.44362926,  10.45267105,  10.46157742,  10.4706316 ,
          10.47957993,  10.48856735,  10.49759197,  10.50685024], dtype=float32)},
 'ms1_summary': {'mz_centroid': 139.05061,
  'mz_peak': 139.05064,
  'peak_area': 5020174.0,
  'peak_height': 2255562.8,
  'polarity': 1,
  'rt_centroid': 9.7323236,
  'rt_peak': 9.7308064},
 'msms': {'data': array([ (53.07600021362305, 1569.101318359375, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (54.986900329589844, 1945.19140625, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (56.96588897705078, 101820.8359375, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (57.97361755371094, 2493.440185546875, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (60.28266143798828, 1828.879150390625, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (62.3231086730957, 1898.606689453125, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (70.066162109375, 4750.68701171875, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (71.78445434570312, 1956.5794677734375, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (71.95288848876953, 54462.87109375, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (72.08160400390625, 1833.3079833984375, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (74.09734344482422, 9941.6845703125, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (84.8247299194336, 2034.026123046875, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (85.07688903808594, 10795.244140625, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (87.50013732910156, 3329.26123046875, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (93.04557037353516, 9281.2216796875, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (95.06105041503906, 26525.69921875, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (97.07674407958984, 4294.51806640625, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (98.07242584228516, 3793.576171875, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (98.09693145751953, 3476.314697265625, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (98.97612762451172, 908494.4375, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (99.97937774658203, 13984.7109375, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (107.38224029541016, 2012.16455078125, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (111.0927505493164, 2817.5888671875, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (112.08767700195312, 17997.30859375, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (112.56375885009766, 1886.869140625, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (112.86474609375, 3458.617919921875, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (113.04622650146484, 2290.297607421875, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (114.79478454589844, 1888.5517578125, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (115.45660400390625, 1849.5672607421875, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (116.98653411865234, 963535.125, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (117.98988342285156, 16885.59765625, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (121.0402603149414, 116365.8984375, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (122.04377746582031, 6975.17333984375, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (122.09701538085938, 2046.290283203125, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (123.05561065673828, 21062.423828125, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (128.9866180419922, 3549.794677734375, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (134.9969482421875, 681782.75, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (136.00038146972656, 11462.462890625, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (138.0554656982422, 3403.21533203125, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (138.0915069580078, 3228.791748046875, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (139.05059814453125, 201652.203125, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (139.1234130859375, 74322.8671875, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (140.0022735595703, 11542.572265625, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (140.0557403564453, 13331.4716796875, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (140.06814575195312, 21061.14453125, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (140.12657165527344, 7585.0927734375, 9.546207427978516, 139.0500030517578, 3527810.5, 20.0),
         (55.54423904418945, 4075.352294921875, 9.730806350708008, 139.05027770996094, 7792066.5, 20.0),
         (56.96589279174805, 86247.1484375, 9.730806350708008, 139.05027770996094, 7792066.5, 20.0),
         (60.249637603759766, 4831.6171875, 9.730806350708008, 139.05027770996094, 7792066.5, 20.0),
         (64.23908233642578, 4776.29736328125, 9.730806350708008, 139.05027770996094, 7792066.5, 20.0),
         (68.05044555664062, 6191.82421875, 9.730806350708008, 139.05027770996094, 7792066.5, 20.0),
         (69.97936248779297, 6504.6455078125, 9.730806350708008, 139.05027770996094, 7792066.5, 20.0),
         (71.95296478271484, 45160.11328125, 9.730806350708008, 139.05027770996094, 7792066.5, 20.0),
         (74.09727478027344, 6564.14404296875, 9.730806350708008, 139.05027770996094, 7792066.5, 20.0),
         (85.0769271850586, 6255.99658203125, 9.730806350708008, 139.05027770996094, 7792066.5, 20.0),
         (85.4671630859375, 6533.830078125, 9.730806350708008, 139.05027770996094, 7792066.5, 20.0),
         (87.98941802978516, 6185.1962890625, 9.730806350708008, 139.05027770996094, 7792066.5, 20.0),
         (93.04550170898438, 121093.671875, 9.730806350708008, 139.05027770996094, 7792066.5, 20.0),
         (95.06118774414062, 262138.171875, 9.730806350708008, 139.05027770996094, 7792066.5, 20.0),
         (96.06460571289062, 10511.916015625, 9.730806350708008, 139.05027770996094, 7792066.5, 20.0),
         (97.04043579101562, 37434.4609375, 9.730806350708008, 139.05027770996094, 7792066.5, 20.0),
         (98.09724426269531, 5386.2958984375, 9.730806350708008, 139.05027770996094, 7792066.5, 20.0),
         (98.97612762451172, 1112600.625, 9.730806350708008, 139.05027770996094, 7792066.5, 20.0),
         (99.97932434082031, 6864.67529296875, 9.730806350708008, 139.05027770996094, 7792066.5, 20.0),
         (103.43488311767578, 5395.6591796875, 9.730806350708008, 139.05027770996094, 7792066.5, 20.0),
         (112.08744049072266, 10416.47265625, 9.730806350708008, 139.05027770996094, 7792066.5, 20.0),
         (112.15483093261719, 7094.388671875, 9.730806350708008, 139.05027770996094, 7792066.5, 20.0),
         (116.98655700683594, 856504.1875, 9.730806350708008, 139.05027770996094, 7792066.5, 20.0),
         (121.04024505615234, 1286621.0, 9.730806350708008, 139.05027770996094, 7792066.5, 20.0),
         (122.03623962402344, 8376.50390625, 9.730806350708008, 139.05027770996094, 7792066.5, 20.0),
         (122.04364776611328, 102142.90625, 9.730806350708008, 139.05027770996094, 7792066.5, 20.0),
         (134.5682373046875, 5590.9892578125, 9.730806350708008, 139.05027770996094, 7792066.5, 20.0),
         (134.9863739013672, 11520.1396484375, 9.730806350708008, 139.05027770996094, 7792066.5, 20.0),
         (134.99693298339844, 377696.625, 9.730806350708008, 139.05027770996094, 7792066.5, 20.0),
         (139.05064392089844, 2255562.75, 9.730806350708008, 139.05027770996094, 7792066.5, 20.0),
         (139.12342834472656, 59489.4609375, 9.730806350708008, 139.05027770996094, 7792066.5, 20.0),
         (140.00267028808594, 7459.6484375, 9.730806350708008, 139.05027770996094, 7792066.5, 20.0),
         (140.05459594726562, 129185.1640625, 9.730806350708008, 139.05027770996094, 7792066.5, 20.0),
         (140.06874084472656, 10280.2138671875, 9.730806350708008, 139.05027770996094, 7792066.5, 20.0),
         (54.12312698364258, 1690.549560546875, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (54.98678970336914, 4068.5712890625, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (56.96589279174805, 76652.296875, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (57.9736213684082, 2116.113037109375, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (69.22649383544922, 1908.9400634765625, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (70.0661392211914, 2960.924560546875, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (71.95286560058594, 33010.5234375, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (72.08165740966797, 2413.52392578125, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (74.0973892211914, 15657.841796875, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (75.66036224365234, 1823.9996337890625, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (77.76134490966797, 1878.9400634765625, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (82.06584167480469, 2904.520263671875, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (85.07689666748047, 9228.94921875, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (85.19752502441406, 2533.94921875, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (87.49995422363281, 4491.8837890625, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (91.05525970458984, 3352.796875, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (92.05846405029297, 18698.3125, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (93.04546356201172, 12209.08984375, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (95.06118774414062, 30029.177734375, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (97.07665252685547, 3057.402587890625, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (98.07225036621094, 3161.834716796875, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (98.09709930419922, 3561.584228515625, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (98.97611999511719, 708632.4375, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (99.09242248535156, 22168.634765625, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (99.97970581054688, 10202.7451171875, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (102.35235595703125, 2313.960693359375, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (111.09237670898438, 1979.6954345703125, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (112.08765411376953, 17920.11328125, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (112.8648910522461, 4760.0244140625, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (116.98652648925781, 723291.1875, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (117.9895248413086, 14486.455078125, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (120.05359649658203, 15267.6767578125, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (121.04019927978516, 152462.734375, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (122.04354095458984, 8483.8310546875, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (134.9969482421875, 510657.8125, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (136.00042724609375, 7965.68896484375, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (137.06150817871094, 2074.626220703125, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (137.08018493652344, 16043.986328125, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (138.0919952392578, 2160.206787109375, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (139.05062866210938, 266821.625, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (139.1233367919922, 58733.6171875, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (140.00213623046875, 11295.4267578125, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (140.05465698242188, 21907.9921875, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (140.06871032714844, 37729.2421875, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0),
         (140.12693786621094, 2640.744873046875, 9.904694557189941, 139.0500030517578, 2999932.5, 20.0)], 
        dtype=[('mz', '<f4'), ('i', '<f4'), ('rt', '<f4'), ('precursor_MZ', '<f4'), ('precursor_intensity', '<f4'), ('collision_energy', '<f4')]),
  'most_intense_precursor': {'precursor_intensity': array([ 7792066.5,  3527810.5,  2999932.5], dtype=float32),
   'precursor_mz': array([ 139.05027771,  139.05000305,  139.05000305], dtype=float32),
   'spectra': array([[  5.55442390e+01,   4.07535229e+03],
          [  5.69658928e+01,   8.62471484e+04],
          [  6.02496376e+01,   4.83161719e+03],
          [  6.42390823e+01,   4.77629736e+03],
          [  6.80504456e+01,   6.19182422e+03],
          [  6.99793625e+01,   6.50464551e+03],
          [  7.19529648e+01,   4.51601133e+04],
          [  7.40972748e+01,   6.56414404e+03],
          [  8.50769272e+01,   6.25599658e+03],
          [  8.54671631e+01,   6.53383008e+03],
          [  8.79894180e+01,   6.18519629e+03],
          [  9.30455017e+01,   1.21093672e+05],
          [  9.50611877e+01,   2.62138172e+05],
          [  9.60646057e+01,   1.05119160e+04],
          [  9.70404358e+01,   3.74344609e+04],
          [  9.80972443e+01,   5.38629590e+03],
          [  9.89761276e+01,   1.11260062e+06],
          [  9.99793243e+01,   6.86467529e+03],
          [  1.03434883e+02,   5.39565918e+03],
          [  1.12087440e+02,   1.04164727e+04],
          [  1.12154831e+02,   7.09438867e+03],
          [  1.16986557e+02,   8.56504188e+05],
          [  1.21040245e+02,   1.28662100e+06],
          [  1.22036240e+02,   8.37650391e+03],
          [  1.22043648e+02,   1.02142906e+05],
          [  1.34568237e+02,   5.59098926e+03],
          [  1.34986374e+02,   1.15201396e+04],
          [  1.34996933e+02,   3.77696625e+05],
          [  1.39050644e+02,   2.25556275e+06],
          [  1.39123428e+02,   5.94894609e+04],
          [  1.40002670e+02,   7.45964844e+03],
          [  1.40054596e+02,   1.29185164e+05],
          [  1.40068741e+02,   1.02802139e+04]], dtype=float32)},
  'polarity': 1}}

In [17]:
import re
export_group_names = []
for i,d in enumerate(data):
    newstr = d[0]['group'].name
    export_group_names.append(newstr)
# print export_group_names

In [18]:
import re
export_file_names = []
for i,d in enumerate(data):
    newstr = os.path.basename(d[0]['lcmsrun'].hdf5_file)
    export_file_names.append(newstr)
# print export_file_names

In [19]:
import re
from collections import defaultdict

export_compound_names = []
export_compound_objects = []
for i,d in enumerate(data[0]):
    export_compound_objects.append(d['identification'])
    if len(d['identification'].compound) > 0:
        str = d['identification'].compound[0].name
    else:
        str = d.name
    newstr = '%s_%s_%s'%(str,d['identification'].mz_references[0].detected_polarity,d['identification'].mz_references[0].adduct)
    newstr = re.sub('[\[\]]','',newstr)
    newstr = re.sub('[^A-Za-z0-9+-]+', '_', newstr)
    newstr = re.sub('i_[A-Za-z]+_i_', '', newstr)
    if newstr[0] == '_':
        newstr = newstr[1:]
    if newstr[0] == '-':
        newstr = newstr[1:]
    if newstr[-1] == '_':
        newstr = newstr[:-1]

    newstr = re.sub('[^A-Za-z0-9]{2,}', '', newstr) #2 or more in regexp
    export_compound_names.append(newstr)

#If duplicate compound names exist, then append them with a number
D = defaultdict(list)
for i,item in enumerate(export_compound_names):
    D[item].append(i)
D = {k:v for k,v in D.items() if len(v)>1}
for k in D.keys():
    for i,f in enumerate(D[k]):
        export_compound_names[f] = '%s%d'%(export_compound_names[f],i)

# for i, e in enumerate (export_compound_names):
#     print i,e

In [20]:
def plot_chromatogram(d,file_name, ax=None):
    import numpy as np
    from textwrap import wrap
    if ax is None:
        ax = plt.gca()

    plt.rcParams['pdf.fonttype']=42
    plt.rcParams['pdf.use14corefonts'] = True
    plt.rcParams['text.usetex'] = False
    plt.rcParams.update({'font.size': 12})
    plt.rcParams.update({'font.weight': 'bold'})
    plt.rcParams['axes.linewidth'] = 2 # set the value globally

    rt_min = d['identification'].rt_references[0].rt_min
    rt_max = d['identification'].rt_references[0].rt_max
    rt_peak = d['identification'].rt_references[0].rt_peak
        
    if len(d['data']['eic']['rt']) > 0:
        x = d['data']['eic']['rt']
        y = d['data']['eic']['intensity']
        ax.plot(x,y,'k-',linewidth=2.0,alpha=1.0)  
        myWhere = np.logical_and(x>=rt_min, x<=rt_max )
        ax.fill_between(x,0,y,myWhere, facecolor='c', alpha=0.3)

    ax.axvline(rt_min, color='k',linewidth=2.0)
    ax.axvline(rt_max, color='k',linewidth=2.0)
    ax.axvline(rt_peak, color='r',linewidth=2.0)
#     ax.set_xlabel('Time (min)',weight='bold')
#     ax.set_ylabel('Intensity (au)',weight='bold')

    ax.set_title("\n".join(wrap(file_name,54)),fontsize=12,weight='bold')

def plot_all_chromatograms_all_files(data,nCols,export_file_names,export_compound_names,share_y,project_label):
    import time
    d = 'data/%s/chromatograms/'%project_label
    if not os.path.exists(d):
        os.makedirs(d)
    nRows = int(np.ceil(len(export_file_names)/float(nCols)))
    for compound_idx,compound in enumerate(export_compound_names):
        starttime = time.time()
        f, ax = plt.subplots(nRows, nCols, sharey=share_y,figsize=(8*nCols,nRows * 6)) #original 8 x 6
#         plt.tight_layout()
        print "figure created in ", time.time() - starttime, " seconds"
        ax = ax.flatten()
        parttime = time.time()
        for i,fname in enumerate(export_file_names):
            p = plot_chromatogram(data[i][compound_idx], fname, ax=ax[i])
        print i, "subplots created in ", time.time() - parttime, " seconds"
#         parttime = time.time()
#         print "tight layout is ", time.time() - parttime, " seconds"
        parttime = time.time()
        f.savefig('%s%s.pdf'%(d,export_compound_names[compound_idx]))
        print "time to save figure is ", time.time() - parttime, " seconds"
        parttime = time.time()
#         f.clear()
        plt.close('all')#f.clear()
        print "time to clear and close figure is ", time.time() - parttime, " seconds"
        print " "

In [21]:
""" contribution from Hans de Winter """
def _InitialiseNeutralisationReactions():
    patts= (
        # Imidazoles
        ('[n+;H]','n'),
        # Amines
        ('[N+;!H0]','N'),
        # Carboxylic acids and alcohols
        ('[$([O-]);!$([O-][#7])]','O'),
        # Thiols
        ('[S-;X1]','S'),
        # Sulfonamides
        ('[$([N-;X2]S(=O)=O)]','N'),
        # Enamines
        ('[$([N-;X2][C,N]=C)]','N'),
        # Tetrazoles
        ('[n-]','[nH]'),
        # Sulfoxides
        ('[$([S-]=O)]','S'),
        # Amides
        ('[$([N-]C=O)]','N'),
        )
    return [(Chem.MolFromSmarts(x),Chem.MolFromSmiles(y,False)) for x,y in patts]

_reactions=None
def NeutraliseCharges(mol, reactions=None):
    global _reactions
    if reactions is None:
        if _reactions is None:
            _reactions=_InitialiseNeutralisationReactions()
        reactions=_reactions
#     mol = Chem.MolFromSmiles(smiles)
    replaced = False
    for i,(reactant, product) in enumerate(reactions):
        while mol.HasSubstructMatch(reactant):
            replaced = True
            rms = AllChem.ReplaceSubstructs(mol, reactant, product)
            rms_smiles = Chem.MolToSmiles(rms[0])
            mol = Chem.MolFromSmiles(rms_smiles)
    if replaced:
        return (mol, True) #Chem.MolToSmiles(mol,True)
    else:
        return (mol, False)
def drawStructure_ShowingFragment(pactolus_tree,fragment_idx,myMol,myMol_w_Hs):

    drawer = rdMolDraw2D.MolDraw2DSVG(600,300)

    fragment_atoms = np.where(pactolus_tree[fragment_idx]['atom_bool_arr'])[0]
    mark_atoms_no_H = []
    for a_index in fragment_atoms:
        if myMol_w_Hs.GetAtomWithIdx(a_index).GetSymbol() != 'H':
            mark_atoms_no_H.append(a_index)

    rdDepictor.Compute2DCoords(myMol)

    drawer.DrawMolecule(myMol,highlightAtoms=mark_atoms_no_H)
    drawer.FinishDrawing()
    svg = drawer.GetDrawingText().replace('svg:','')
    return svg

def drawStructure_Fragment(pactolus_tree,fragment_idx,myMol,myMol_w_Hs):
    fragment_atoms = np.where(pactolus_tree[fragment_idx]['atom_bool_arr'])[0]
    depth_of_hit = np.sum(pactolus_tree[fragment_idx]['bond_bool_arr'])
    mol2 = deepcopy(myMol_w_Hs)
    # Now set the atoms you'd like to remove to dummy atoms with atomic number 0
    fragment_atoms = np.where(pactolus_tree[fragment_idx]['atom_bool_arr']==False)[0]
    for f in fragment_atoms:
        mol2.GetAtomWithIdx(f).SetAtomicNum(0)

    # Now remove dummy atoms using a query
    mol3 = Chem.DeleteSubstructs(mol2, Chem.MolFromSmarts('[#0]'))
    mol3 = Chem.RemoveHs(mol3)
    # You get what you are looking for
    return moltosvg(mol3),depth_of_hit


def moltosvg(mol,molSize=(450,150),kekulize=True):
    mc = Chem.Mol(mol.ToBinary())
    if kekulize:
        try:
            Chem.Kekulize(mc)
        except:
            mc = Chem.Mol(mol.ToBinary())
    if not mc.GetNumConformers():
        rdDepictor.Compute2DCoords(mc)
    drawer = rdMolDraw2D.MolDraw2DSVG(molSize[0],molSize[1])
    drawer.DrawMolecule(mc)
    drawer.FinishDrawing()
    svg = drawer.GetDrawingText()
    # It seems that the svg renderer used doesn't quite hit the spec.
    # Here are some fixes to make it work in the notebook, although I think
    # the underlying issue needs to be resolved at the generation step
    return svg.replace('svg:','')

def get_ion_from_fragment(frag_info,spectrum):
    hit_indices = np.where(np.sum(frag_info,axis=1))
    hit = spectrum[hit_indices,:][0]
    return hit,hit_indices

In [22]:
#plot msms and annotate
#compound name
#formula
#adduct
#theoretical m/z
#histogram of retention times
#scatter plot of retention time with peak area
#retention time
#print all chromatograms
#structure

def file_with_max_precursor_intensity(data,compound_idx):
    idx = []
    my_max = 0
    for i,d in enumerate(data):
        temp = d[compound_idx]['data']['msms']['data']
        if d[compound_idx]['data']['msms']['polarity'] or d[compound_idx]['data']['msms']['polarity'] ==0 :
            m = np.max(temp['precursor_intensity'])
            if m > my_max:
                my_max = m
                idx = i
    return idx,my_max


def make_identification_figure(data,file_idx,compound_idx,export_name,project_label):
    d = 'data/%s/identification/'%project_label
    if not os.path.exists(d):
        os.makedirs(d)
    fig = plt.figure(figsize=(20,20))
#     fig = plt.figure()
    ax = fig.add_subplot(211)
    ax.set_title(data[file_idx][compound_idx]['identification'].compound[0].name,fontsize=12,weight='bold')
    ax.set_xlabel('m/z',fontsize=12,weight='bold')
    ax.set_ylabel('intensity',fontsize=12,weight='bold')

    mz = data[file_idx][compound_idx]['data']['msms']['data']['mz']
    zeros = np.zeros(data[file_idx][compound_idx]['data']['msms']['data']['mz'].shape)
    intensity = data[idx][compound_idx]['data']['msms']['data']['i']
    ax.vlines(mz,zeros,intensity,colors='r',linewidth = 2)
    sx = np.argsort(intensity)[::-1]
    labels = [1.001e9]
    for i in sx:
        if np.min(np.abs(mz[i] - labels)) > 0.1 and intensity[i] > 0.02 * np.max(intensity):
            ax.annotate('%5.4f'%mz[i], xy=(mz[i], 1.01*intensity[i]),rotation = 90, horizontalalignment = 'center', verticalalignment = 'left')
            labels.append(mz[i])

    plt.tight_layout()
    L = plt.ylim()
    plt.ylim(L[0],L[1]*1.12)
   
    inchi =  data[file_idx][compound_idx]['identification'].compound[0].inchi
    myMol = Chem.MolFromInchi(inchi.encode('utf-8'))
    myMol,neutralised = NeutraliseCharges(myMol)
    image = Draw.MolToImage(myMol, size = (300,300) )
    ax2 = fig.add_subplot(223)
    ax2.imshow(image)
    ax2.axis('off')
    #     SVG(moltosvg(myMol))

    ax3 = fig.add_subplot(224)
    ax3.set_xlim(0,1)
    mz_theoretical = data[file_idx][compound_idx]['identification'].mz_references[0].mz
    mz_measured = data[file_idx][compound_idx]['data']['ms1_summary']['mz_centroid']
    if not mz_measured:
        mz_measured = 0

    delta_mz = abs(mz_theoretical - mz_measured)
    delta_ppm = delta_mz / mz_theoretical * 1e6
    
    rt_theoretical = data[file_idx][compound_idx]['identification'].rt_references[0].rt_peak
    rt_measured = data[file_idx][compound_idx]['data']['ms1_summary']['rt_centroid']
    if not rt_measured:
        rt_measured = 0
    ax3.text(0,1,'%s'%os.path.basename(data[file_idx][compound_idx]['lcmsrun'].hdf5_file),fontsize=12)
    ax3.text(0,0.95,'%s %s'%(data[file_idx][compound_idx]['identification'].compound[0].name, data[file_idx][compound_idx]['identification'].mz_references[0].adduct),fontsize=12)
    ax3.text(0,0.9,'m/z theoretical = %5.4f, measured = %5.4f, %5.4f ppm difference'%(mz_theoretical, mz_measured, delta_ppm),fontsize=12)
    ax3.text(0,0.85,'Expected Elution of %5.2f minutes, %5.2f min actual'%(rt_theoretical,rt_measured),fontsize=12)
    ax3.set_ylim(0.2,1.01)
    ax3.axis('off')
#     plt.show()
    fig.savefig('%sIdentifications_%s.pdf'%(d,export_name))
    fig.clear()
    plt.close('all')#f.clear()

In [23]:
inchi =  '%s'%data[idx][9]['identification'].compound[0].InChI
myMol = Chem.MolFromInchi(inchi.encode('utf-8'))
SVG(moltosvg(myMol))


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-23-b2296acbf8e2> in <module>()
----> 1 inchi =  '%s'%data[idx][9]['identification'].compound[0].InChI
      2 myMol = Chem.MolFromInchi(inchi.encode('utf-8'))
      3 SVG(moltosvg(myMol))

/global/project/projectdirs/metatlas/anaconda/lib/python2.7/site-packages/metatlas/metatlas_objects.pyc in __getattribute__(self, name)
    233         """Automatically resolve stubs on demand.
    234         """
--> 235         value = super(MetatlasObject, self).__getattribute__(name)
    236         if isinstance(value, Stub) and FETCH_STUBS:
    237             value = value.retrieve()

AttributeError: 'Compound' object has no attribute 'InChI'

In [24]:
# column name list
# row name list
import pandas as pd
import os
peak_height = pd.DataFrame( index=export_compound_names, columns=export_file_names, dtype=float)
peak_area = pd.DataFrame( index=export_compound_names, columns=export_file_names, dtype=float)

# peak_height['compound'] = compound_list
# peak_height.set_index('compound',drop=True)
for i,dd in enumerate(data):
    for j,d in enumerate(dd):
        if not d['data']['ms1_summary']['peak_height']:
            peak_height.ix[export_compound_names[j],export_file_names[i]] = 0
            peak_area.ix[export_compound_names[j],export_file_names[i]] = 0
        else:
            peak_height.ix[export_compound_names[j],export_file_names[i]] = d['data']['ms1_summary']['peak_height']  
            peak_area.ix[export_compound_names[j],export_file_names[i]] = d['data']['ms1_summary']['peak_area']
columns = []
for i,f in enumerate(export_file_names):
    columns.append((export_group_names[i],f))
peak_height.columns = pd.MultiIndex.from_tuples(columns,names=['group', 'file'])
peak_area.columns = pd.MultiIndex.from_tuples(columns,names=['group', 'file'])

In [25]:
d = 'data/%s/sheets/'%project_label
if not os.path.exists(d):
    os.makedirs(d)
peak_height.to_csv('data/%s/sheets/compounds peak height.tab'%project_label,sep='\t')
peak_area.to_csv('data/%s/sheets/compounds peak area.tab'%project_label,sep='\t')

In [26]:
from matplotlib import pyplot as plt

def plot_errorbar_plots(df,compound_list,project_label):
    d = 'data/%s/error_bar/'%project_label
    if not os.path.exists(d):
        os.makedirs(d)
    for compound in compound_list:
        m = df.ix[compound].groupby(level='group').mean()
        e = df.ix[compound].groupby(level='group').std()
        c = df.ix[compound].groupby(level='group').count()

        for i in range(len(e)):
            if c[i]>0:
                e[i] = e[i] / c[i]**0.5

        f, ax = plt.subplots(1, 1,figsize=(20,12))
        m.plot(yerr=e, kind='bar',ax=ax)
        ax.set_title(compound,fontsize=12,weight='bold')
        plt.tight_layout()
        f.savefig('%sErrorBar_%s.pdf'%(d,compound))
        f.clear()
        plt.close('all')#f.clear()

In [28]:
for compound_idx in range(len(export_compound_names)):
    idx, m = file_with_max_precursor_intensity(data,compound_idx)
    if idx:
        make_identification_figure(data,idx,compound_idx,export_compound_names[compound_idx],project_label)

plot_errorbar_plots(peak_height,export_compound_names,project_label)

nCols = 2
compound_idx = 9
share_y=True
t = plot_all_chromatograms_all_files(data,nCols,export_file_names,export_compound_names,share_y,project_label)


figure created in  0.17017698288  seconds
3 subplots created in  0.0280148983002  seconds
time to save figure is  0.269181013107  seconds
time to clear and close figure is  0.000948190689087  seconds
 
figure created in  0.169955015182  seconds
3 subplots created in  0.027734041214  seconds
time to save figure is  0.357175111771  seconds
time to clear and close figure is  0.000591993331909  seconds
 
figure created in  0.170099020004  seconds
3 subplots created in  0.0279650688171  seconds
time to save figure is  0.239701986313  seconds
time to clear and close figure is  0.000757932662964  seconds
 
figure created in  0.170048952103  seconds
3 subplots created in  0.0276961326599  seconds
time to save figure is  0.383126974106  seconds
time to clear and close figure is  8.01086425781e-05  seconds
 
figure created in  0.170010089874  seconds
3 subplots created in  0.0281929969788  seconds
time to save figure is  0.302487850189  seconds
time to clear and close figure is  0.00106716156006  seconds
 
figure created in  0.346698045731  seconds
3 subplots created in  0.0275130271912  seconds
time to save figure is  0.257642030716  seconds
time to clear and close figure is  0.000761985778809  seconds
 
figure created in  0.170406103134  seconds
3 subplots created in  0.0276708602905  seconds
time to save figure is  0.214015960693  seconds
time to clear and close figure is  0.000658988952637  seconds
 
figure created in  0.170073032379  seconds
3 subplots created in  0.0280728340149  seconds
time to save figure is  0.212095975876  seconds
time to clear and close figure is  0.000648021697998  seconds
 
figure created in  0.1694688797  seconds
3 subplots created in  0.0276310443878  seconds
time to save figure is  0.582645893097  seconds
time to clear and close figure is  0.000112056732178  seconds
 
figure created in  0.170941114426  seconds
3 subplots created in  0.0285279750824  seconds
time to save figure is  0.277858972549  seconds
time to clear and close figure is  0.000924110412598  seconds
 
figure created in  0.170030832291  seconds
3 subplots created in  0.0276758670807  seconds
time to save figure is  0.265229940414  seconds
time to clear and close figure is  0.000940084457397  seconds
 
figure created in  0.170095920563  seconds
3 subplots created in  0.0278601646423  seconds
time to save figure is  0.34455704689  seconds
time to clear and close figure is  0.00111794471741  seconds
 
figure created in  0.170171976089  seconds
3 subplots created in  0.0277750492096  seconds
time to save figure is  0.532804965973  seconds
time to clear and close figure is  0.000741004943848  seconds
 
figure created in  0.170480012894  seconds
3 subplots created in  0.0277500152588  seconds
time to save figure is  0.245393037796  seconds
time to clear and close figure is  0.000900030136108  seconds
 
figure created in  0.169831037521  seconds
3 subplots created in  0.0280179977417  seconds
time to save figure is  0.345781803131  seconds
time to clear and close figure is  0.00115203857422  seconds
 
figure created in  0.169954061508  seconds
3 subplots created in  0.0281660556793  seconds
time to save figure is  0.233595848083  seconds
time to clear and close figure is  0.000698804855347  seconds
 
figure created in  0.171314001083  seconds
3 subplots created in  0.0280828475952  seconds
time to save figure is  0.305249929428  seconds
time to clear and close figure is  0.00115489959717  seconds
 
figure created in  0.180459976196  seconds
3 subplots created in  0.0289940834045  seconds
time to save figure is  0.588900089264  seconds
time to clear and close figure is  0.000654935836792  seconds
 
figure created in  0.171127080917  seconds
3 subplots created in  0.0282881259918  seconds
time to save figure is  0.243990182877  seconds
time to clear and close figure is  0.000707864761353  seconds
 
figure created in  0.171121120453  seconds
3 subplots created in  0.0279519557953  seconds
time to save figure is  0.272780895233  seconds
time to clear and close figure is  0.000940084457397  seconds
 
figure created in  0.170945167542  seconds
3 subplots created in  0.0281448364258  seconds
time to save figure is  0.273020029068  seconds
time to clear and close figure is  0.000927925109863  seconds
 
figure created in  0.170277118683  seconds
3 subplots created in  0.0280909538269  seconds
time to save figure is  0.379534006119  seconds
time to clear and close figure is  7.9870223999e-05  seconds
 
figure created in  0.171717882156  seconds
3 subplots created in  0.0279710292816  seconds
time to save figure is  0.263081073761  seconds
time to clear and close figure is  0.000851154327393  seconds
 
figure created in  0.171903848648  seconds
3 subplots created in  0.0258071422577  seconds
time to save figure is  0.237021923065  seconds
time to clear and close figure is  0.000900030136108  seconds
 
figure created in  0.631187200546  seconds
3 subplots created in  0.0273687839508  seconds
time to save figure is  0.315416097641  seconds
time to clear and close figure is  8.39233398438e-05  seconds
 
figure created in  0.170077085495  seconds
3 subplots created in  0.0279288291931  seconds
time to save figure is  0.374966144562  seconds
time to clear and close figure is  7.41481781006e-05  seconds
 
figure created in  0.170257091522  seconds
3 subplots created in  0.0291860103607  seconds
time to save figure is  0.315837860107  seconds
time to clear and close figure is  0.00113487243652  seconds
 
figure created in  0.178672075272  seconds
3 subplots created in  0.0256350040436  seconds
time to save figure is  0.290966033936  seconds
time to clear and close figure is  0.00116395950317  seconds
 
figure created in  0.17227602005  seconds
3 subplots created in  0.0283639431  seconds
time to save figure is  0.413812875748  seconds
time to clear and close figure is  7.79628753662e-05  seconds
 
figure created in  0.17093205452  seconds
3 subplots created in  0.0282258987427  seconds
time to save figure is  0.231906890869  seconds
time to clear and close figure is  0.000665187835693  seconds
 
figure created in  0.170843839645  seconds
3 subplots created in  0.0281059741974  seconds
time to save figure is  0.300496101379  seconds
time to clear and close figure is  0.00103807449341  seconds
 
figure created in  0.757644176483  seconds
3 subplots created in  0.0285379886627  seconds
time to save figure is  0.268600940704  seconds
time to clear and close figure is  0.000895977020264  seconds
 
figure created in  0.171260118484  seconds
3 subplots created in  0.0282621383667  seconds
time to save figure is  0.281248092651  seconds
time to clear and close figure is  0.000999927520752  seconds
 
figure created in  0.17097902298  seconds
3 subplots created in  0.0285739898682  seconds
time to save figure is  0.31188416481  seconds
time to clear and close figure is  0.00112080574036  seconds
 
figure created in  0.170924186707  seconds
3 subplots created in  0.0283000469208  seconds
time to save figure is  0.389843940735  seconds
time to clear and close figure is  8.60691070557e-05  seconds
 
figure created in  0.170675039291  seconds
3 subplots created in  0.0284030437469  seconds
time to save figure is  0.273775815964  seconds
time to clear and close figure is  0.00100803375244  seconds
 
figure created in  0.170619010925  seconds
3 subplots created in  0.0292859077454  seconds
time to save figure is  0.332671880722  seconds
time to clear and close figure is  0.0010941028595  seconds
 
figure created in  0.171272039413  seconds
3 subplots created in  0.0282979011536  seconds
time to save figure is  0.335597991943  seconds
time to clear and close figure is  0.00113487243652  seconds
 
figure created in  0.174831151962  seconds
3 subplots created in  0.0287919044495  seconds
time to save figure is  0.321920871735  seconds
time to clear and close figure is  0.00124502182007  seconds
 
figure created in  0.173702955246  seconds
3 subplots created in  0.0293889045715  seconds
time to save figure is  0.273561000824  seconds
time to clear and close figure is  0.000895023345947  seconds
 
figure created in  0.870157003403  seconds
3 subplots created in  0.0279331207275  seconds
time to save figure is  0.238882064819  seconds
time to clear and close figure is  0.000716924667358  seconds
 
figure created in  0.171173810959  seconds
3 subplots created in  0.028580904007  seconds
time to save figure is  0.221954107285  seconds
time to clear and close figure is  0.000663995742798  seconds
 
figure created in  0.171281814575  seconds
3 subplots created in  0.0282528400421  seconds
time to save figure is  0.24126291275  seconds
time to clear and close figure is  0.00076699256897  seconds
 
figure created in  0.171705007553  seconds
3 subplots created in  0.0282828807831  seconds
time to save figure is  0.340257883072  seconds
time to clear and close figure is  0.00113415718079  seconds
 
figure created in  0.171240091324  seconds
3 subplots created in  0.031289100647  seconds
time to save figure is  0.293282032013  seconds
time to clear and close figure is  0.00108695030212  seconds
 
figure created in  0.171732187271  seconds
3 subplots created in  0.02894115448  seconds
time to save figure is  0.261229038239  seconds
time to clear and close figure is  0.000868082046509  seconds
 
figure created in  0.171301841736  seconds
3 subplots created in  0.0283198356628  seconds
time to save figure is  0.351747989655  seconds
time to clear and close figure is  0.000102043151855  seconds
 
figure created in  0.171472072601  seconds
3 subplots created in  0.028382062912  seconds
time to save figure is  0.374862909317  seconds
time to clear and close figure is  7.82012939453e-05  seconds
 
figure created in  0.170958995819  seconds
3 subplots created in  0.0285458564758  seconds
time to save figure is  0.304219961166  seconds
time to clear and close figure is  0.000969886779785  seconds
 
figure created in  0.171707868576  seconds
3 subplots created in  0.0284900665283  seconds
time to save figure is  0.254265785217  seconds
time to clear and close figure is  0.000885009765625  seconds
 
figure created in  0.176867961884  seconds
3 subplots created in  0.0292019844055  seconds
time to save figure is  0.282003879547  seconds
time to clear and close figure is  0.000962018966675  seconds
 
figure created in  0.169956922531  seconds
3 subplots created in  0.0302131175995  seconds
time to save figure is  1.11160087585  seconds
time to clear and close figure is  0.00108194351196  seconds
 
figure created in  0.171633958817  seconds
3 subplots created in  0.0302481651306  seconds
time to save figure is  0.287548065186  seconds
time to clear and close figure is  0.00101494789124  seconds
 
figure created in  0.170972108841  seconds
3 subplots created in  0.0251610279083  seconds
time to save figure is  0.250838041306  seconds
time to clear and close figure is  0.000789165496826  seconds
 
figure created in  0.171017885208  seconds
3 subplots created in  0.0267910957336  seconds
time to save figure is  0.250028133392  seconds
time to clear and close figure is  0.000876188278198  seconds
 
figure created in  0.172796964645  seconds
3 subplots created in  0.0313918590546  seconds
time to save figure is  0.365520954132  seconds
time to clear and close figure is  8.20159912109e-05  seconds
 
figure created in  0.188405990601  seconds
3 subplots created in  0.0311639308929  seconds
time to save figure is  0.338943004608  seconds
time to clear and close figure is  0.00111198425293  seconds
 
figure created in  0.170815944672  seconds
3 subplots created in  0.0284149646759  seconds
time to save figure is  0.35258102417  seconds
time to clear and close figure is  7.20024108887e-05  seconds
 
figure created in  0.169903039932  seconds
3 subplots created in  0.0281999111176  seconds
time to save figure is  0.352943897247  seconds
time to clear and close figure is  0.0011990070343  seconds
 
figure created in  0.180864095688  seconds
3 subplots created in  0.0285260677338  seconds
time to save figure is  0.247740030289  seconds
time to clear and close figure is  0.000747203826904  seconds
 
figure created in  0.170570850372  seconds
3 subplots created in  0.0286719799042  seconds
time to save figure is  0.279456138611  seconds
time to clear and close figure is  0.00102090835571  seconds
 
figure created in  0.170204877853  seconds
3 subplots created in  0.0284600257874  seconds
time to save figure is  0.259630918503  seconds
time to clear and close figure is  0.000876903533936  seconds
 
figure created in  0.170449972153  seconds
3 subplots created in  0.0283670425415  seconds
time to save figure is  0.274461984634  seconds
time to clear and close figure is  0.000921010971069  seconds
 
figure created in  0.170269012451  seconds
3 subplots created in  0.0282459259033  seconds
time to save figure is  0.257195949554  seconds
time to clear and close figure is  0.000790119171143  seconds
 
figure created in  0.170516014099  seconds
3 subplots created in  0.0282900333405  seconds
time to save figure is  0.309612989426  seconds
time to clear and close figure is  0.000985860824585  seconds
 
figure created in  1.1665661335  seconds
3 subplots created in  0.0279619693756  seconds
time to save figure is  0.36584186554  seconds
time to clear and close figure is  8.70227813721e-05  seconds
 
figure created in  0.170855045319  seconds
3 subplots created in  0.0311529636383  seconds
time to save figure is  0.222761154175  seconds
time to clear and close figure is  0.000823020935059  seconds
 
figure created in  0.170928001404  seconds
3 subplots created in  0.0285890102386  seconds
time to save figure is  0.351675033569  seconds
time to clear and close figure is  7.5101852417e-05  seconds
 
figure created in  0.170650959015  seconds
3 subplots created in  0.0284059047699  seconds
time to save figure is  0.351832151413  seconds
time to clear and close figure is  0.00122404098511  seconds
 
figure created in  0.193287849426  seconds
3 subplots created in  0.0293889045715  seconds
time to save figure is  0.381527900696  seconds
time to clear and close figure is  7.20024108887e-05  seconds
 
figure created in  0.170123815536  seconds
3 subplots created in  0.0284450054169  seconds
time to save figure is  0.240092992783  seconds
time to clear and close figure is  0.000730991363525  seconds
 
figure created in  0.169350147247  seconds
3 subplots created in  0.027575969696  seconds
time to save figure is  0.274759054184  seconds
time to clear and close figure is  0.000992059707642  seconds
 
figure created in  0.169501066208  seconds
3 subplots created in  0.0283100605011  seconds
time to save figure is  0.281125068665  seconds
time to clear and close figure is  0.000881910324097  seconds
 
figure created in  0.169516086578  seconds
3 subplots created in  0.028156042099  seconds
time to save figure is  0.381664037704  seconds
time to clear and close figure is  0.00010085105896  seconds
 
figure created in  0.172342061996  seconds
3 subplots created in  0.0313420295715  seconds
time to save figure is  0.306797027588  seconds
time to clear and close figure is  0.00117182731628  seconds
 
figure created in  0.169764041901  seconds
3 subplots created in  0.0285720825195  seconds
time to save figure is  0.260215044022  seconds
time to clear and close figure is  0.000897169113159  seconds
 
figure created in  0.16970205307  seconds
3 subplots created in  0.028373003006  seconds
time to save figure is  0.278639793396  seconds
time to clear and close figure is  0.000992059707642  seconds
 
figure created in  0.170077085495  seconds
3 subplots created in  0.0282790660858  seconds
time to save figure is  0.356992006302  seconds
time to clear and close figure is  7.41481781006e-05  seconds
 
figure created in  0.169624090195  seconds
3 subplots created in  0.0284547805786  seconds
time to save figure is  0.260221004486  seconds
time to clear and close figure is  0.000906944274902  seconds
 

In [ ]: