This file tests out the hts-db installation


In [ ]:
import sys

%load_ext autoreload
%autoreload 2
%load_ext sql 
%pylab inline
%matplotlib inline

import pandas as pd
import pickle,time
import pymongo 

import pylab as pl

FT1=['p53Act','DNADamage','StressKinase','OxidativeStress','MicrotubuleCSK','LysosomalMass',
     'MitoMass','MitoMembPot','MitoFxnI','Steatosis',
     'MitoticArrest','CellCycleArrest','NuclearSize','DNATexture','Apoptosis','CellLoss']

In [11]:
# This package contains the object (i.e. schema) definition for the database

from bio.data.htsdb import *

# This pacakge contains the functions for retrieving and displaying the data 
import bio.comp.hts as hts

In [12]:
# Count the number of Plates 
HtsPlate.objects.count()


Out[12]:
416

In [65]:
# Find Troglitazone
print hts.getChem('troglitazone')
# Now get the chemical object with the eid 
TGTZ = HtsChem.objects(eid='TX006205').first()


[(u'Troglitazone', u'TX006205')]

In [67]:
# Get the plates containing troglitazone
Plates0 = HtsPlate.objects(chems=TGTZ)
Plates0


Out[67]:
[<HtsPlate: HtsPlate object>, <HtsPlate: HtsPlate object>, <HtsPlate: HtsPlate object>, <HtsPlate: HtsPlate object>]

In [68]:
# Which assays are on the first plate ? 
[A.name for A in Plates0[0].assays]


Out[68]:
[u'Apredica OxidativeStress',
 u'Apredica p53Act',
 u'Apredica CellCycleArrest',
 u'Apredica CellLoss',
 u'Apredica StressKinase',
 u'Apredica NuclearSize']

In [69]:
# Find all assays for Troglitazone
[(A.eid,A.name) for A in HtsPlate.objects(chems=TGTZ).distinct('assays')]


Out[69]:
[(u'CellCycleArrest', u'Apredica CellCycleArrest'),
 (u'CellLoss', u'Apredica CellLoss'),
 (u'NuclearSize', u'Apredica NuclearSize'),
 (u'OxidativeStress', u'Apredica OxidativeStress'),
 (u'StressKinase', u'Apredica StressKinase'),
 (u'p53Act', u'Apredica p53Act'),
 (u'MicrotubuleCSK', u'Apredica MicrotubuleCSK'),
 (u'MitoMass', u'Apredica MitoMass'),
 (u'MitoMembPot', u'Apredica MitoMembPot'),
 (u'MitoticArrest', u'Apredica MitoticArrest')]

In [54]:
# Get the p53Activation assay object
P53 = HtsAssay.objects(eid='p53Act').first()

In [70]:
# Find the normalized concentration response data for TGTZ for the p53 endpoint
for CRCi in HtsConcRespCurveNrm.objects(chem=TGTZ,assay=P53):
    print CRCi.timeh


24.0
72.0

In [77]:
# Get the concentration response data as a pandas dataframe
X=hts.getChemConcResp(u'TX006205',ret='df')

In [78]:
# Get the percentage change data 
X[('ppct')]


Out[78]:
timeh 24.0 72.0
assay_id CellCycleArrest CellLoss MicrotubuleCSK MitoMass MitoMembPot MitoticArrest NuclearSize OxidativeStress StressKinase p53Act CellCycleArrest CellLoss MicrotubuleCSK MitoMass MitoMembPot MitoticArrest NuclearSize OxidativeStress StressKinase p53Act
chem_id hchem_id chem_name chem_casrn lconc
3328 TX006205 Troglitazone 97322-87-7 -6.407823 0.239099 0.927296 0.541501 0.214457 0.389415 0.004196 0.663280 0.007612 0.296132 0.058852 0.725426 0.893859 0.579744 0.156148 0.771371 0.009592 0.493860 0.002004 0.009305 0.034304
-6.107349 0.237880 0.922468 0.527029 0.227181 0.524093 0.012049 0.650171 0.015939 0.442190 0.098895 0.721635 0.882536 0.588961 0.153552 0.790353 0.010092 0.484045 0.001049 0.005863 0.028591
-5.806875 0.241273 0.920025 0.499066 0.246462 0.700091 0.020032 0.631976 0.020144 0.524640 0.117269 0.699468 0.860696 0.584371 0.147985 0.747416 0.011804 0.482692 0.000085 0.002924 0.025590
-5.504456 0.249372 0.918011 0.474675 0.261533 0.829099 0.027554 0.619587 0.016181 0.469369 0.096539 0.659763 0.836553 0.568448 0.138116 0.635194 0.014634 0.491745 -0.000190 0.002450 0.031021
-5.204120 0.257248 0.907064 0.474336 0.261203 0.871587 0.036002 0.622879 0.007667 0.330875 0.060343 0.613142 0.810197 0.585762 0.127984 0.580077 0.019690 0.494403 0.000740 0.004956 0.046731
-4.903090 0.262698 0.879071 0.494631 0.245708 0.852133 0.039740 0.638324 0.002194 0.227795 0.042969 0.567535 0.758254 0.660829 0.117038 0.662770 0.031720 0.483115 0.002753 0.005923 0.070871
-4.602060 0.265682 0.835465 0.507373 0.221675 0.776275 0.028452 0.657132 -0.000070 0.172692 0.037405 0.522284 0.654281 0.766715 0.102379 0.822983 0.058677 0.471401 0.006806 0.006737 0.105685
-4.301030 0.249786 0.774680 0.498432 0.203010 0.628495 0.009173 0.681782 -0.000643 0.143686 0.032476 0.455201 0.515961 0.868527 0.082691 0.912466 0.099895 0.470799 0.014598 0.026811 0.162291
-4.000000 0.200230 0.672528 0.448662 0.222137 0.428821 0.031543 0.656222 0.010260 0.134046 0.061234 0.369607 0.373405 0.875778 0.053572 0.834558 0.176668 0.420427 0.048020 0.088935 0.275348
-3.698970 0.133480 0.524804 0.331878 0.298151 0.213782 0.126580 0.511810 0.038723 0.081322 0.140317 0.316971 0.242023 0.703857 0.012824 0.584970 0.312552 0.252731 0.126294 0.183523 0.456390

In [79]:
# Get the assay results 
AR=hts.getChemAssayResults('TX006205')

In [82]:
AR[('hit_call')]


Out[82]:
timeh 24.0 72.0
assay_id CellCycleArrest CellLoss MicrotubuleCSK MitoMass MitoMembPot MitoticArrest NuclearSize OxidativeStress StressKinase p53Act CellCycleArrest CellLoss MicrotubuleCSK MitoMass MitoMembPot MitoticArrest NuclearSize OxidativeStress StressKinase p53Act
chem_id hchem_id chem_name chem_casrn
3328 TX006205 Troglitazone 97322-87-7 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 1 0 1 0 1

In [85]:
# Plot the conc response for Octanoic acid
hts.plotHtsConcRespHM('TX002151',exp_id='APR-HepG2-PhII',add_t0=True,loc=None)


No LEC data

In [22]:
FTLB3 = dict(zip(FT1,['p53','SK','OS','Mt','MM','MMP','MA','CCA','NS','CN']))
hts.plotHtsTrajHM('TX002151',exp_id='APR-HepG2-PhII',add_t0=True,cb=True,use_resp='slfc',
                  draw_chem=False,FTLB=FTLB3,
                  fs=1.1,xyoff=[2,-4],fgsz=[15,3],loc=None)