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)]
In [128]:
csv_folder = './csv_data/Merged/'
files = filterFiles(csv_folder, '.csv')
In [129]:
for i in files:
print (i)
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())
In [132]:
dfA
Out[132]:
In [133]:
dfA.head(n=5)
Out[133]:
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")
In [93]:
[x for x in files if 'pJAC1' in files[]]
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]:
In [8]:
df= pd.read_csv(csv_folder + filesfilt[0][1])
In [10]:
df.head(n=5)
Out[10]:
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]:
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]:
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")
In [53]:
x = sns.distplot(df['FL3-A'])
x.savefig(output.png)
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)
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'])
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'])
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]:
In [36]:
np.where(df['SSC-A'] == 0)
Out[36]:
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)
In [39]:
df2 = read_csv('Fourth_Apr5_2016.csv')
Out[39]:
In [ ]: