Trial by hx

need to make completely new dataframe of peak values with:

  • No averages
  • Trial numbers Then, sort by trial and look at peaks based on previous trial

In [1]:
drive_path = 'c:/'
import numpy as np
import pandas as pd
import os
import sys
import matplotlib.pyplot as plt
from scipy.stats import ks_2samp
from scipy.stats import anderson_ksamp
from scipy.stats import kruskal
from scipy.stats import variation
%matplotlib
import seaborn as sns
from scipy.stats import zscore
from scipy.stats import nanmean
from scipy.stats import nanstd


Using matplotlib backend: Qt4Agg

In [47]:
filename='C:\Users\Annie\Documents\Data\Ca_Imaging\GoodFiles\\fullpeak.csv'
comp=pd.read_csv(filename)
comp_sorted=comp.reindex_axis(comp.mean().sort_values().index, axis=1)
comp_labels=pd.DataFrame(comp.Mouse)
comp_group=pd.DataFrame(comp.Group)
tmp=[comp_group,comp_labels,comp_sorted]
composite_full=pd.concat(tmp,axis=1)
cfull=pd.melt(composite_full,['Group','Mouse'],var_name="Odor")

In [10]:
test=pd.read_csv('C:\Users\Annie\Documents\Data\Ca_Imaging\GoodFiles\\160325_1\\9dt.txt')

In [11]:
trials=pd.read_csv('C:\\Users\\Annie\\Documents\\Data\\Ca_Imaging\\Analysis\\Odor_Panel\\Odor_Trials.csv')

In [46]:
composite_full.head()


Out[46]:
Group Mouse MS01 THA Blank MS10 AP MS05 IAA05 PA IAA01 IAA10 Hexanal10 Hexanone Hexanal01 Hexanal05 EB
0 Control 160321_1 0.015671 0.067358 NaN 0.150474 0.036738 0.169456 0.034294 0.037389 0.188597 0.099708 0.069948 0.093353 0.062999 0.124211 -0.061840
1 Control 160321_1 -0.034636 0.095266 NaN 0.074001 0.073576 0.139423 0.001814 -0.002271 0.188666 0.041676 0.036447 -0.026087 0.014205 0.101018 0.056893
2 Control 160321_1 -0.044179 0.146676 NaN 0.260675 0.058214 0.095906 0.127803 0.221412 0.477065 0.287615 0.263380 0.022945 0.129928 0.293199 0.153817
3 Control 160321_1 0.146939 0.094015 NaN 0.071141 0.110235 0.157300 0.104363 0.051386 0.248613 0.034975 0.037260 -0.057530 0.104142 0.198974 0.082859
4 Control 160321_1 0.268299 0.069755 NaN 0.220858 0.116399 0.233311 0.240154 0.203381 0.393188 0.309290 0.145721 -0.147715 0.315627 0.538062 0.694684

In [39]:


In [98]:


In [35]:
#Order all the trials
df=pd.DataFrame([])
for a in trials.File.unique():
    temp=trials[trials.File==a]
    tone=temp[['Odor','T1']]
    tone.columns=['Odor','Trial']
    ttwo=temp[['Odor','T2']]
    ttwo.columns=['Odor','Trial']
    tthree=temp[['Odor','T3']]
    tthree.columns=['Odor','Trial']
    tfour=temp[['Odor','T4']]
    tfour.columns=['Odor','Trial']
    trialsdf=pd.concat([tone,ttwo,tthree,tfour],axis=0,ignore_index=True)
    sortedtrials=trialsdf.sort_values('Trial')
    sortedtrials=sortedtrials[sortedtrials.Trial!=0]
    sortedtrials=sortedtrials.reset_index(drop=True)
    sortedtrials['Mouse']=a
    df=df.append(sortedtrials,ignore_index=True)
#Get Odor1 and Odor2
# TH=pd.DataFrame([])
# full=pd.DataFrame([])
# for x in df.Mouse.unique():
#     if <len(sortedtrials.Trial.unique()):
#         Odor1=sortedtrials[sortedtrials.Trial==x]['Odor'].values
#         Odor2=sortedtrials[sortedtrials.Trial==x+1]['Odor'].values
#         tmp=({'Mouse':a,'Odor1':Odor1,'Odor2':Odor2,'Trial1':x,'Trial2':x+1})
#         TH=TH.append(tmp,ignore_index=True)

In [42]:
df[df.Mouse==x]


Out[42]:
Odor Trial Mouse
2350 Spontaneous 1 160623
2351 Spontaneous 2 160623
2352 Spontaneous 3 160623
2353 Spontaneous 4 160623
2354 Blank 5 160623
2355 Blank 6 160623
2356 Blank 7 160623
2357 Blank 8 160623
2358 Pre 9 160623
2359 Pre 10 160623
2360 Pre 11 160623
2361 Pre 12 160623
2362 Post5 13 160623
2363 Post5 14 160623
2364 Post5 15 160623
2365 Post5 16 160623
2366 Post30 17 160623
2367 Post30 18 160623
2368 Post30 19 160623
2369 Post30 20 160623

In [44]:
for x in df.Mouse.unique():
    for y in df[df.Mouse==x]['Trial'].unique():
        if y<len(df[df.Mouse==x]['Trial']):
            Odor1=df[df.Mouse==x]

In [168]:
#WHY IS X NOT CHANGING BACK TO INT& WHY CAN I NOT GET ODOR 1 valuess


Out[168]:
array(['MS10'], dtype=object)

In [ ]:


In [ ]:


In [ ]:


In [ ]: