In [17]:
%pylab inline
import sys
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import os
import numpy as np
def filterFiles(path, extension):
    return [file for root, dirs, files in os.walk(path) for file in files if file.endswith(extension)]


Populating the interactive namespace from numpy and matplotlib

In [128]:
csv_folder = './csv_data/Merged/'

files = filterFiles(csv_folder, '.csv')

In [129]:
for i in files:
    print (i)


mergedData.csv

In [130]:
df = pd.read_csv(csv_folder + i)

In [131]:
dfA = df.query("name == 'A01' or name == 'A02' or name == 'A03' or name == 'A04' or name == 'A05' or name == 'A06' \
                or name == 'A07' or name == 'A08' or name == 'A09' or name == 'A10' or name == 'A11'")

In [118]:
#dfA = dfA[dfA['FL3-A'] < 10000 ]
dfA = dfA[dfA['FL3-A'] < 2000 ]
dfA['cvFL3-A'] = np.std(dfA['FL3-A'].tolist())/np.mean(dfA['FL3-A'].tolist())
dfA['mFL3-A'] = np.mean(dfA['FL3-A'].tolist())


C:\Users\BD Accuri\Anaconda3\lib\site-packages\ipykernel\__main__.py:3: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  app.launch_new_instance()
C:\Users\BD Accuri\Anaconda3\lib\site-packages\ipykernel\__main__.py:4: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy

In [132]:
dfA


Out[132]:
FSC-A SSC-A FL1-A FL2-A FL3-A FL4-A FSC-H SSC-H FL1-H FL2-H FL3-H FL4-H Width Time name cvFSC-H mFSC-H cvFL3-A mFL3-A
0 8849 282 229 158 939 101 28430 846 218 50 997 0 19 154 A01 3.897020 62392.501674 2.336084 1031.253035
1 12204 1023 427 302 901 371 46651 2184 375 220 938 508 25 154 A01 3.897020 62392.501674 2.336084 1031.253035
2 5381 3736 280 196 888 128 17834 11449 322 121 802 321 17 154 A01 3.897020 62392.501674 2.336084 1031.253035
3 90211 19389 1385 574 1161 52 206898 34230 1511 496 1039 174 47 154 A01 3.897020 62392.501674 2.336084 1031.253035
4 38953 9936 155 303 850 447 110334 18639 191 178 1007 367 34 154 A01 3.897020 62392.501674 2.336084 1031.253035
5 14251 14831 0 46 1284 132 22519 20911 0 0 1007 144 50 154 A01 3.897020 62392.501674 2.336084 1031.253035
6 14795 1034 196 136 957 213 46588 2880 93 138 1141 181 25 154 A01 3.897020 62392.501674 2.336084 1031.253035
7 18994 9826 443 140 940 367 50237 19053 389 78 864 440 40 154 A01 3.897020 62392.501674 2.336084 1031.253035
8 9947 7184 192 116 870 414 26528 17166 107 71 1306 384 23 154 A01 3.897020 62392.501674 2.336084 1031.253035
9 13360 991 377 244 1226 156 37159 2959 236 159 1082 356 24 154 A01 3.897020 62392.501674 2.336084 1031.253035
10 10496 2925 159 272 943 311 27039 6953 214 156 967 190 27 154 A01 3.897020 62392.501674 2.336084 1031.253035
11 8135 487 99 24 849 294 27471 1734 132 0 1007 321 22 154 A01 3.897020 62392.501674 2.336084 1031.253035
12 17967 546 403 208 901 167 62952 1438 379 128 979 226 25 154 A01 3.897020 62392.501674 2.336084 1031.253035
13 7108 5085 121 194 1041 286 22665 13566 20 92 1146 241 20 154 A01 3.897020 62392.501674 2.336084 1031.253035
14 40787 11652 177 129 888 155 86981 20026 230 112 914 222 44 155 A01 3.897020 62392.501674 2.336084 1031.253035
15 11906 5433 345 120 811 334 25805 10794 182 48 974 362 35 155 A01 3.897020 62392.501674 2.336084 1031.253035
16 15212 1080 254 151 948 301 48791 3071 252 64 958 231 27 155 A01 3.897020 62392.501674 2.336084 1031.253035
17 5109 663 127 119 937 119 12040 1279 151 66 1126 72 24 155 A01 3.897020 62392.501674 2.336084 1031.253035
18 3882 186 94 226 801 0 11414 1840 0 136 826 0 18 155 A01 3.897020 62392.501674 2.336084 1031.253035
19 16120 3586 0 95 868 23 48615 9095 0 119 917 182 31 155 A01 3.897020 62392.501674 2.336084 1031.253035
20 2117394 1075106 22792 8523 13956 1179 2271883 1178397 13480 4928 8645 1202 98 155 A01 3.897020 62392.501674 2.336084 1031.253035
21 5146 1100 205 140 859 158 18555 4209 168 72 925 50 18 155 A01 3.897020 62392.501674 2.336084 1031.253035
22 12089 6439 273 71 813 107 41181 17478 147 0 836 168 21 155 A01 3.897020 62392.501674 2.336084 1031.253035
23 33945 7460 251 133 1037 79 78351 12865 209 97 801 136 36 155 A01 3.897020 62392.501674 2.336084 1031.253035
24 3777 152 159 166 1032 153 14461 977 324 92 1538 84 16 156 A01 3.897020 62392.501674 2.336084 1031.253035
25 72000 15184 181 116 909 426 144642 23571 195 167 854 469 50 156 A01 3.897020 62392.501674 2.336084 1031.253035
26 2746 24 257 110 862 89 11017 865 227 0 1225 106 14 156 A01 3.897020 62392.501674 2.336084 1031.253035
27 9244 5294 230 46 820 398 21202 11946 91 2 830 320 26 156 A01 3.897020 62392.501674 2.336084 1031.253035
28 13371 1258 450 176 816 188 46635 3274 439 54 929 138 22 156 A01 3.897020 62392.501674 2.336084 1031.253035
29 7085 2883 146 143 832 0 17951 7853 135 80 983 84 25 156 A01 3.897020 62392.501674 2.336084 1031.253035
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
53632 20805 963 0 21 1278 614 37690 1412 48 67 860 348 52 249 A11 3.082133 53557.262245 0.642373 971.284569
53633 4827 594 156 87 835 180 25594 2864 273 53 1086 104 13 249 A11 3.082133 53557.262245 0.642373 971.284569
53634 7040 564 25 217 906 319 23514 1818 0 156 892 324 20 249 A11 3.082133 53557.262245 0.642373 971.284569
53635 6303 460 103 231 871 120 19976 1626 0 171 1146 39 18 249 A11 3.082133 53557.262245 0.642373 971.284569
53636 7679 149 144 234 921 377 25934 1784 42 143 947 408 20 249 A11 3.082133 53557.262245 0.642373 971.284569
53637 7604 771 143 196 1034 65 26717 2670 32 74 1101 0 20 249 A11 3.082133 53557.262245 0.642373 971.284569
53638 5797 168 178 145 864 156 18884 1792 92 86 929 130 18 249 A11 3.082133 53557.262245 0.642373 971.284569
53639 128247 23405 0 247 831 91 241453 32825 0 159 826 190 85 249 A11 3.082133 53557.262245 0.642373 971.284569
53640 16117 1598 279 181 916 0 56350 2978 294 90 924 90 29 249 A11 3.082133 53557.262245 0.642373 971.284569
53641 10696 910 57 356 985 138 23607 2966 43 229 860 106 30 250 A11 3.082133 53557.262245 0.642373 971.284569
53642 11555 870 240 45 900 135 20280 2959 197 66 1078 166 37 250 A11 3.082133 53557.262245 0.642373 971.284569
53643 16573 1473 156 334 858 85 23122 2654 110 200 832 253 50 250 A11 3.082133 53557.262245 0.642373 971.284569
53644 8897 1456 66 201 804 173 28109 3860 148 98 933 216 19 250 A11 3.082133 53557.262245 0.642373 971.284569
53645 18384 1653 304 317 864 114 53411 4107 314 199 819 111 22 250 A11 3.082133 53557.262245 0.642373 971.284569
53646 4297 527 181 232 916 92 16348 1914 203 201 1022 0 16 250 A11 3.082133 53557.262245 0.642373 971.284569
53647 10714 2906 269 0 1052 235 25081 4009 182 0 915 342 34 250 A11 3.082133 53557.262245 0.642373 971.284569
53648 17600 5338 115 57 835 34 26876 10617 103 52 1102 125 42 250 A11 3.082133 53557.262245 0.642373 971.284569
53649 15304 2004 226 139 823 338 34351 4405 194 76 947 388 37 250 A11 3.082133 53557.262245 0.642373 971.284569
53650 13656 4229 177 185 937 28 19839 4962 183 114 817 218 43 250 A11 3.082133 53557.262245 0.642373 971.284569
53651 9524 431 56 105 960 122 32099 1215 96 17 882 128 21 250 A11 3.082133 53557.262245 0.642373 971.284569
53652 19728 8326 0 93 927 210 54924 18362 65 22 1153 183 31 250 A11 3.082133 53557.262245 0.642373 971.284569
53653 10103 601 446 167 804 276 35528 1942 456 104 813 362 18 250 A11 3.082133 53557.262245 0.642373 971.284569
53654 29264 8463 156 259 853 183 50157 12943 363 128 900 270 37 250 A11 3.082133 53557.262245 0.642373 971.284569
53655 13472 2471 294 252 949 31 42273 6199 386 263 836 0 22 250 A11 3.082133 53557.262245 0.642373 971.284569
53656 15103 1699 110 148 1146 152 27074 3221 31 31 863 181 37 250 A11 3.082133 53557.262245 0.642373 971.284569
53657 4651 190 198 187 885 0 25180 2076 129 102 1116 0 13 250 A11 3.082133 53557.262245 0.642373 971.284569
53658 8725 742 221 193 898 59 33848 2226 150 81 1119 41 18 250 A11 3.082133 53557.262245 0.642373 971.284569
53659 6515 503 116 145 843 82 21188 2183 40 18 917 0 17 250 A11 3.082133 53557.262245 0.642373 971.284569
53660 13639 18990 362 196 813 250 39353 41132 259 124 818 270 25 250 A11 3.082133 53557.262245 0.642373 971.284569
53661 12686 1845 75 87 916 214 36239 5068 40 4 919 396 23 250 A11 3.082133 53557.262245 0.642373 971.284569

53662 rows × 19 columns


In [133]:
dfA.head(n=5)


Out[133]:
FSC-A SSC-A FL1-A FL2-A FL3-A FL4-A FSC-H SSC-H FL1-H FL2-H FL3-H FL4-H Width Time name cvFSC-H mFSC-H cvFL3-A mFL3-A
0 8849 282 229 158 939 101 28430 846 218 50 997 0 19 154 A01 3.89702 62392.501674 2.336084 1031.253035
1 12204 1023 427 302 901 371 46651 2184 375 220 938 508 25 154 A01 3.89702 62392.501674 2.336084 1031.253035
2 5381 3736 280 196 888 128 17834 11449 322 121 802 321 17 154 A01 3.89702 62392.501674 2.336084 1031.253035
3 90211 19389 1385 574 1161 52 206898 34230 1511 496 1039 174 47 154 A01 3.89702 62392.501674 2.336084 1031.253035
4 38953 9936 155 303 850 447 110334 18639 191 178 1007 367 34 154 A01 3.89702 62392.501674 2.336084 1031.253035

In [141]:
g = sns.factorplot(x="name", y="FSC-H", data=dfA, size=10, aspect=2, )



In [117]:
g = sns.factorplot(x="name", y="cvFL3-A", data=dfA, size=10, aspect=2, )



In [54]:
g = sns.pairplot(dfA01)



In [56]:
g = sns.pairplot(dfA08)



In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [21]:
png_folder = './Images/plot/'
if not os.path.exists(png_folder):
    os.makedirs(png_folder)

for i in files:
    df = pd.read_csv(csv_folder + i)
    df['logFSCa'] = np.log10(df['FSC-A'])
    df['logSSCa'] = np.log10(df['SSC-A'])
    g = sns.jointplot('logFSCa', 'logSSCa', data=df ,kind='scatter', color='g',xlim=(2,6), ylim=(1,6))
    g.savefig(png_folder+ i+"pair.png")
    plt.clf()
    x = sns.distplot(df['FL3-A'])
    fig = x.get_figure()
    fig.savefig(png_folder+ i+"hist.png")


C:\Users\BD Accuri\Anaconda3\lib\site-packages\statsmodels\nonparametric\kdetools.py:20: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  y = X[:m/2+1] + np.r_[0,X[m/2+1:],0]*1j
C:\Users\BD Accuri\Anaconda3\lib\site-packages\matplotlib\pyplot.py:516: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`).
  max_open_warning, RuntimeWarning)

In [93]:
[x for x in files if 'pJAC1' in files[]]


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-93-28ebe25ab4b1> in <module>()
----> 1 [x for x in files if 'pJAC1' in files[x]]

<ipython-input-93-28ebe25ab4b1> in <listcomp>(.0)
----> 1 [x for x in files if 'pJAC1' in files[x]]

TypeError: list indices must be integers or slices, not str

In [5]:
filesfilt= []
plasmids=['pJAC1','pJAC2','pJAC4','pJAC6','pJAC8']
for i in plasmids:
    M = [] 
    for j in files:
        if i in j:
            M.append(j)
    filesfilt.append(M)

In [6]:
filesfilt


Out[6]:
[['correctedA03 LB+JCA1+pJAC1.csv',
  'correctedB03 M9+JAC1+pJAC1.csv',
  'correctedC03 M9-N+JAC1+pJAC1.csv',
  'correctedD03 M9-12-N+JAC1+pJAC1.csv',
  'correctedE03 M9-29-N+JAC1+pJAC1.csv',
  'correctedF03 M9-70-N+JAC1+pJAC1.csv',
  'correctedG03 M9-112-N+JAC1+pJAC1.csv',
  'correctedH03 M9-196-N+JAC1+pJAC1.csv'],
 ['correctedA04 LB+JCA1+pJAC2.csv',
  'correctedB04 M9+JAC1+pJAC2.csv',
  'correctedC04 M9-N+JAC1+pJAC2.csv',
  'correctedC09 M9-N+JAC1+pJAC2.csv',
  'correctedD04 M9-12-N+JAC1+pJAC2.csv',
  'correctedD09 M9-12-N+JAC1+pJAC2.csv',
  'correctedE04 M9-29-N+JAC1+pJAC2.csv',
  'correctedF04 M9-70-N+JAC1+pJAC2.csv',
  'correctedG04 M9-112-N+JAC1+pJAC2.csv',
  'correctedH04 M9-196-N+JAC1+pJAC2.csv',
  'correctedH09 M9-196-N+JAC1+pJAC2.csv'],
 ['correctedA05 LB+JCA1+pJAC4.csv',
  'correctedB05 M9+JAC1+pJAC4.csv',
  'correctedC05 M9-N+JAC1+pJAC4.csv',
  'correctedD05 M9-12-N+JAC1+pJAC4.csv',
  'correctedE05 M9-29-N+JAC1+pJAC4.csv',
  'correctedF05 M9-70-N+JAC1+pJAC4.csv',
  'correctedG05 M9-112-N+JAC1+pJAC4.csv',
  'correctedH05 M9-196-N+JAC1+pJAC4.csv'],
 ['correctedA06 LB+JCA1+pJAC6.csv',
  'correctedA10 M9-12-N+JAC1+pJAC6.csv',
  'correctedB06 M9+JAC1+pJAC6.csv',
  'correctedB10 M9-29-N+JAC1+pJAC6.csv',
  'correctedC06 M9-N+JAC1+pJAC6.csv',
  'correctedD06 M9-12-N+JAC1+pJAC6.csv',
  'correctedD10 M9-112-N+JAC1+pJAC6.csv',
  'correctedE06 M9-29-N+JAC1+pJAC6.csv',
  'correctedE10 M9-196-N+JAC1+pJAC6.csv',
  'correctedF06 M9-70-N+JAC1+pJAC6.csv',
  'correctedG06 M9-112-N+JAC1+pJAC6.csv',
  'correctedH06 M9-196-N+JAC1+pJAC6.csv'],
 ['correctedA07 LB+JCA1+pJAC8.csv',
  'correctedB07 M9+JAC1+pJAC8.csv',
  'correctedC07 M9-N+JAC1+pJAC8.csv',
  'correctedD07 M9-12-N+JAC1+pJAC8.csv',
  'correctedE07 M9-29-N+JAC1+pJAC8.csv',
  'correctedF07 M9-70-N+JAC1+pJAC8.csv',
  'correctedG07 M9-112-N+JAC1+pJAC8.csv',
  'correctedH07 M9-196-N+JAC1+pJAC8.csv']]

In [8]:
df= pd.read_csv(csv_folder + filesfilt[0][1])

In [10]:
df.head(n=5)


Out[10]:
FSC-A SSC-A FL1-A FL2-A FL3-A FL4-A FSC-H SSC-H FL1-H FL2-H FL3-H FL4-H Width Time
0 18466 1313 887 362 1005 303 27155 2659 479 155 432 249 50 153
1 10605 1603 597 145 864 0 28377 4382 768 37 731 43 24 153
2 22340 2022 724 204 1638 146 69826 4475 903 208 1895 209 37 153
3 10851 1438 591 352 867 98 39303 3935 584 355 948 196 22 153
4 10480 1666 903 201 984 304 21918 3668 961 141 588 649 35 153

In [11]:
names = ['LB', 'M9', 'M9-N', 'M9-N(12)', 'M9-N(29)', 'M9-N(70)', 'M9-N(112)', 'M9-N(196)']

In [34]:
png_folder = "./newphotos"
if not os.path.exists(png_folder):#making the folder to corrected rfp tif
    os.makedirs(png_folder)

NOISE = []
STD = []
for j in filesfilt:
    noise = []
    std = []
    for i in j:
        if '09' not in i and '10' not in i:
            df = pd.read_csv(csv_folder + i)
            noise.append(np.mean(df['FL1-A']))
            std.append(np.std(df['FSC-H']))
    NOISE.append(noise)

In [31]:
NOISE


Out[31]:
[[954.4760914760915,
  1140.082216264522,
  1362.909090909091,
  1038.1432225063938,
  1005.9397260273972,
  1030.67311827957,
  1022.1470588235294,
  1026.3918699186993],
 [996.4758244483015,
  1527.3795900939367,
  1239.1892430278886,
  1160.7729729729729,
  1136.372980910426,
  1126.2557427258805,
  1142.2900703674745,
  1062.4359415305246],
 [1021.216352436065,
  1251.3056528264133,
  1279.455630126771,
  1039.509009009009,
  1080.6244897959184,
  1041.2173913043478,
  968.6309677419355,
  1017.4299802761341],
 [935.9198966408269,
  1048.8325358851675,
  985.0,
  1008.0,
  968.2878787878788,
  1085.409090909091,
  1002.830463576159,
  976.4258373205741],
 [992.8188050930461,
  1358.344980587909,
  1296.0530201342283,
  1017.7193347193347,
  994.9926829268293,
  1059.5032258064516,
  1047.414953271028,
  1037.797]]

In [35]:
for i in range(len(NOISE)):
    plt.figure(figsize=(10,10))
    ax = sns.stripplot(x=names, y=NOISE[i])
    #ax.errorbar(x=names, y=NOISE[i], yerr=STD[i], fmt='-o')
    fig = ax.get_figure()
    fig.savefig(png_folder+'/'+plasmids[i]+"hist.png")



In [22]:
png_folder


Out[22]:
'./newphotos'

In [56]:
df
df['logFSCa'] = np.log10(df['FSC-A'])
df['logSSCa'] = np.log10(df['SSC-A'])
g = sns.jointplot('logFSCa', 'logSSCa', data=df ,kind='scatter', color='g',xlim=(2,6), ylim=(1,6))
g.savefig( i+"pair.png")
plt.clf()
x = sns.distplot(df['FL3-A'])
fig = x.get_figure()
fig.savefig( i+"hist.png")


/Users/biofisica/anaconda/lib/python3.5/site-packages/statsmodels/nonparametric/kdetools.py:20: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  y = X[:m/2+1] + np.r_[0,X[m/2+1:],0]*1j

In [53]:
x = sns.distplot(df['FL3-A'])
x.savefig(output.png)


/Users/biofisica/anaconda/lib/python3.5/site-packages/statsmodels/nonparametric/kdetools.py:20: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  y = X[:m/2+1] + np.r_[0,X[m/2+1:],0]*1j
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-53-f7a5e66d41e3> in <module>()
      1 x = sns.distplot(df['FL3-A'])
----> 2 x.savefig(output.png)

AttributeError: 'AxesSubplot' object has no attribute 'savefig'

In [17]:
if 'FSC-A' in list(df):
    df['logFSCa'] = np.log10(df['FSC-A'])
    df['logSSCa'] = np.log10(df['SSC-A'])
    #g = sns.jointplot('logFSCa', 'logSSCa', data=df ,kind='scatter', color='g') 
   
    for i in range(len(df)):
        if 3*(np.log10(df['FSC-A'][i])-4.25)**2 + 0.5*(np.log10(df['SSC-A'][i])-3.7)**2 > 0.3:
            df = df.drop(i)
    if dflen == len(df):
        print('No hay valores por fuera la elipse')
        exit(0)
    else:
        pass
    #g = sns.jointplot('logFSCa', 'logSSCa', data=df ,kind='scatter', color='g',xlim=(2,6), ylim=(1,6))
    
    df.to_csv('filteredData.csv')

elif 'FSC-A' not in list(df):
    print('El archivo no posee datos de Forward-Scattering')
    exit(0)
elif 'SSC-A' not in list(df):
    print('El archivo no posee datos de Side-Scattering')
    exit(0)

else: 
    print('error desconocido')
    exit(0)


---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-17-4cb1a28834b1> in <module>()
      5 
      6     for i in range(len(df)):
----> 7         if 3*(np.log10(df['FSC-A'][i])-4.25)**2 + 0.5*(np.log10(df['SSC-A'][i])-3.7)**2 > 0.3:
      8             df = df.drop(i)
      9     if dflen == len(df):

/Users/biofisica/anaconda/lib/python3.5/site-packages/pandas/core/series.py in __getitem__(self, key)
    581         key = com._apply_if_callable(key, self)
    582         try:
--> 583             result = self.index.get_value(self, key)
    584 
    585             if not lib.isscalar(result):

/Users/biofisica/anaconda/lib/python3.5/site-packages/pandas/indexes/base.py in get_value(self, series, key)
   1978         try:
   1979             return self._engine.get_value(s, k,
-> 1980                                           tz=getattr(series.dtype, 'tz', None))
   1981         except KeyError as e1:
   1982             if len(self) > 0 and self.inferred_type in ['integer', 'boolean']:

KeyboardInterrupt: 

In [43]:
df = df.reset_index(drop=True)
for i in range(len(df)):
    if df['FL3-A'][i] < 800:
        df = df.drop(i)

In [47]:
ax = sns.distplot(df['FL3-A'])


/Users/biofisica/anaconda/lib/python3.5/site-packages/statsmodels/nonparametric/kdetools.py:20: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  y = X[:m/2+1] + np.r_[0,X[m/2+1:],0]*1j

In [52]:
df['FL3-A-Norm'] = df['FL3-A']/df['FSC-H']
df['FL3-A-log'] = np.log10(df['FL3-A'])

In [56]:
df['logFSCh'] = np.log10(df['FSC-H'])

In [57]:
ax = sns.distplot(df['logFSCh'])


/Users/biofisica/anaconda/lib/python3.5/site-packages/statsmodels/nonparametric/kdetools.py:20: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  y = X[:m/2+1] + np.r_[0,X[m/2+1:],0]*1j

In [30]:
import fcsparser

In [31]:
path = '/Users/biofisica/Documents/Carlos Sanchez/JACCitometry/FCSExports/20160907_183741/A01 LB.fcs'

In [32]:
meta, data = fcsparser.parse(path, meta_data_only=False, reformat_meta=True)

In [33]:
data.to_csv('hola.csv')

In [34]:
df = data

In [35]:
df.head(n=6)


Out[35]:
FSC-A SSC-A GFP-A FL2-A mcherry-A FL4-A FSC-H SSC-H GFP-H FL2-H mcherry-H FL4-H Width Time
0 2366 364 354 108 651 146 10534 1393 583 14 743 436 13 154
1 2587 291 0 178 264 100 10083 1244 0 108 231 311 14 154
2 2551 561 326 204 319 85 10437 2967 718 194 55 360 14 154
3 2864 182 102 205 57 50 13649 1012 267 181 0 0 13 154
4 2151 218 0 293 496 194 10064 1266 0 265 1107 232 12 154
5 2376 0 912 151 286 0 10444 0 1526 92 790 0 13 154

In [36]:
np.where(df['SSC-A'] == 0)


Out[36]:
(array([     5,      9,     18, ..., 104693, 104694, 104732]),)

In [37]:
for i in range(len(df)):
    if df['SSC-A'][i] == 0:
        df = df.drop(i)

In [38]:
df = df.reset_index(drop=True)

In [44]:
if 'FSC-A' in list(df):
    df['logFSCa'] = np.log10(df['FSC-A'])
    df['logSSCa'] = np.log10(df['SSC-A'])
    g = sns.jointplot('logFSCa', 'logSSCa', data=df ,kind='scatter', color='g') 
   
    for i in range(len(df)):
        if 3*(np.log10(df['FSC-A'][i])-4.25)**2 + 0.5*(np.log10(df['SSC-A'][i])-3.7)**2 > 0.3:
            df = df.drop(i)
    if dflen == len(df):
        print('No hay valores por fuera la elipse')
        exit(0)
    else:
        pass
    g = sns.jointplot('logFSCa', 'logSSCa', data=df ,kind='scatter', color='g',xlim=(2,6), ylim=(1,6))
    
    df.to_csv('filteredData.csv')

elif 'FSC-A' not in list(df):
    print('El archivo no posee datos de Forward-Scattering')
    exit(0)
elif 'SSC-A' not in list(df):
    print('El archivo no posee datos de Side-Scattering')
    exit(0)

else: 
    print('error desconocido')
    exit(0)


---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-44-f3490536e87e> in <module>()
      5 
      6     for i in range(len(df)):
----> 7         if 3*(np.log10(df['FSC-A'][i])-4.25)**2 + 0.5*(np.log10(df['SSC-A'][i])-3.7)**2 > 0.3:
      8             df = df.drop(i)
      9     if dflen == len(df):

/Users/biofisica/anaconda/lib/python3.5/site-packages/pandas/core/series.py in __getitem__(self, key)
    581         key = com._apply_if_callable(key, self)
    582         try:
--> 583             result = self.index.get_value(self, key)
    584 
    585             if not lib.isscalar(result):

/Users/biofisica/anaconda/lib/python3.5/site-packages/pandas/indexes/base.py in get_value(self, series, key)
   1978         try:
   1979             return self._engine.get_value(s, k,
-> 1980                                           tz=getattr(series.dtype, 'tz', None))
   1981         except KeyError as e1:
   1982             if len(self) > 0 and self.inferred_type in ['integer', 'boolean']:

pandas/index.pyx in pandas.index.IndexEngine.get_value (pandas/index.c:3332)()

pandas/index.pyx in pandas.index.IndexEngine.get_value (pandas/index.c:3035)()

pandas/index.pyx in pandas.index.IndexEngine.get_loc (pandas/index.c:4018)()

pandas/hashtable.pyx in pandas.hashtable.Int64HashTable.get_item (pandas/hashtable.c:6610)()

pandas/hashtable.pyx in pandas.hashtable.Int64HashTable.get_item (pandas/hashtable.c:6554)()

KeyError: 0

In [39]:
df2 = read_csv('Fourth_Apr5_2016.csv')


Out[39]:
FSC-A SSC-A GFP-A FL2-A mcherry-A FL4-A FSC-H SSC-H GFP-H FL2-H mcherry-H FL4-H Width Time
0 2366 364 354 108 651 146 10534 1393 583 14 743 436 13 154
1 2587 291 0 178 264 100 10083 1244 0 108 231 311 14 154
2 2551 561 326 204 319 85 10437 2967 718 194 55 360 14 154
3 2864 182 102 205 57 50 13649 1012 267 181 0 0 13 154
4 2151 218 0 293 496 194 10064 1266 0 265 1107 232 12 154
5 7067 2163 523 107 495 44 16291 5884 858 56 921 402 25 154
6 2168 176 32 204 276 267 10109 1554 0 182 257 589 12 154
7 2691 437 199 297 808 164 12177 2074 410 311 971 457 13 154
8 14335 1278 439 337 202 0 37022 3500 525 246 467 122 28 154
9 2750 336 0 34 196 517 10101 1886 712 0 0 760 15 154
10 3153 380 0 199 375 592 10114 1533 55 193 299 1323 17 154
11 2625 126 88 0 0 0 12110 2597 660 0 0 0 13 154
12 5289 1461 400 92 967 62 10876 3615 720 108 1019 449 32 154
13 3156 307 337 93 46 141 10217 1933 495 0 744 577 16 154
14 3003 538 657 269 643 226 11588 2465 938 267 528 117 15 154
15 3069 64 323 191 64 292 12579 1659 509 103 379 328 14 154
16 2642 359 0 297 409 444 10622 2282 292 351 380 688 14 154
17 9360 654 0 288 258 25 32852 1407 440 222 981 536 21 154
18 14514 5938 0 299 270 750 36412 12598 0 248 677 785 30 154
19 3713 1153 56 170 0 0 13354 3230 160 234 0 0 17 154
20 16083 10801 51 179 0 191 30395 20289 750 311 38 233 36 154
21 6575 1868 307 182 0 359 23860 5042 410 259 140 704 19 154
22 3081 147 165 163 226 177 10345 1943 281 57 130 255 16 154
23 3315 474 63 123 489 107 12003 1695 582 37 359 164 17 154
24 2589 136 205 158 628 288 10674 498 258 114 692 609 14 154
25 3544 285 486 276 237 79 12176 1515 723 222 392 26 16 155
26 295571 338489 2114 686 1547 1443 457852 555174 1580 708 1208 894 65 155
27 6736 444 459 0 858 0 13730 1644 767 0 1406 350 28 155
28 3651 627 87 231 213 0 12512 1907 491 230 616 0 18 155
29 3766 3515 205 110 807 389 11138 8662 578 100 1046 283 22 155
... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
87853 3064 54 0 172 874 101 10545 856 446 67 1216 303 16 1353
87854 3429 362 0 143 75 207 10527 1892 535 18 280 513 17 1353
87855 3131 238 607 119 723 0 10270 1790 629 42 834 0 17 1353
87856 2312 327 143 87 139 191 11206 1802 139 15 76 671 12 1353
87857 8262 2152 0 199 1061 0 21366 4590 352 216 945 0 24 1353
87858 2262 83 507 285 510 0 10956 583 857 262 854 145 12 1353
87859 85448 56324 2865 971 1995 0 174161 96269 2729 754 1744 776 46 1353
87860 3586 344 391 244 432 304 12446 1390 726 144 247 492 18 1353
87861 9697 1906 0 64 633 0 34499 5111 291 0 886 88 22 1353
87862 5106 633 0 34 421 0 11027 1695 56 80 993 0 28 1353
87863 3541 197 0 148 459 450 11313 1803 169 115 1426 421 18 1353
87864 2561 307 100 241 280 153 10359 1133 557 168 1199 226 14 1353
87865 11994 1844 0 136 0 17 38172 4246 219 38 0 37 23 1353
87866 3406 372 0 179 706 0 11636 1027 740 97 626 0 17 1353
87867 2554 155 260 117 418 80 13565 2561 419 0 465 0 12 1353
87868 24971 1465 36 184 540 4 73576 3547 316 95 637 140 29 1354
87869 2737 793 563 278 831 213 10145 2593 870 391 1004 444 15 1354
87870 2871 112 520 42 636 256 10271 1443 591 0 711 546 15 1354
87871 4385 213 388 335 594 289 10654 2142 339 383 1000 885 22 1354
87872 2602 380 314 299 121 138 13215 1808 440 346 0 217 12 1354
87873 2740 131 0 317 453 243 10326 1245 325 319 682 280 15 1354
87874 2822 373 659 190 303 326 12683 1738 1126 134 221 437 13 1354
87875 4972 1302 388 240 612 0 14908 4185 691 217 814 0 19 1354
87876 4077 1226 0 166 588 285 10611 3364 270 73 413 651 21 1354
87877 3045 362 258 175 475 292 10286 1411 347 50 462 313 17 1354
87878 2402 161 131 37 193 0 10462 1298 197 0 118 0 13 1354
87879 57965 5784 558 90 690 279 129495 9567 469 271 972 428 45 1354
87880 3150 91 70 244 295 164 11623 982 341 144 133 275 16 1354
87881 19505 5452 378 9 688 568 37451 11858 289 186 648 911 37 1354
87882 2397 375 113 241 193 0 11191 2009 89 220 74 0 12 1354

87883 rows × 14 columns


In [ ]: