예제 #1
0
    def test_batch_analysis(self):
        '''
        test the batch analysis.
        '''
        cluster_list = []
        for patch in self._name_list:
            test_patch = Patch(os.path.join(self._dir, patch))
            test_patch.scan()
            for cluster in test_patch:
                cluster.compute_mode()
                cluster.compute_mode_detail()
                cluster_list.append(cluster)

        # Test BatchAnalysis class
        batch_analysis = BatchAnalysis(list(cluster_list))
        test_dict = batch_analysis.compute_cluster_summary()



        for patchname in self._name_list:
            for cluster_no in range(1, self.cluster_num+1):
                test_dict = batch_analysis.compute_cluster_summary(
                patchname = patchname, cluster_no = cluster_no)

                temp_amp = np.mean(self._patch_list[patchname][cluster_no-1]['open_amp']
                                   -
                                   self._patch_list[patchname][cluster_no-1]['shut_amp'])
                if abs(test_dict['mean_amp'] - temp_amp) > 0.0001:
                    print('Amplitude error')

                temp_duration = (sum(self._patch_list[patchname][cluster_no-1]['open_period'])
                                 +
                                 sum(self._patch_list[patchname][cluster_no-1]['shut_period']))

                if abs(test_dict['duration'] - temp_duration) > 0.0001:
                    print('Duration error')

                temp_popen = sum(self._patch_list[patchname][cluster_no-1]['open_period']) / temp_duration
                if abs(test_dict['popen'] - temp_popen) > 0.0001:
                    print('Popen error')

        # Test StretchSummary class

        batch_analysis.compute_stretch_summary()
예제 #2
0
"""



import os
import codecs

import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
import pandas as pd


from batch_query import Batch
from batch_analysis import BatchAnalysis, PatchExamination


sns.set(color_codes=True)

batch = Batch('./data/')
batch.scan_orded_folder()
concentation_list = ['0.3', '1', '3', '10', '100']

for concentration in concentation_list:
    cluster_list = batch.query(mutation = 'S270T', concentration = concentration)
    cluster_summary = BatchAnalysis(cluster_list)  
    summary = cluster_summary.compute_cluster_summary()
    np.savetxt(concentration+'.csv', summary, 
               fmt= ['%s', '%i', '%.2f', '%.2f','%.2f','%i','%.2f','%.2f'],
               delimiter = ',')
    
예제 #3
0
import numpy as np

from batch_query import Batch
from batch_analysis import BatchAnalysis

batch = Batch('/Users/zhiyiwu/GitHub/sc_py/data')
batch.scan_orded_folder()
list_100 = batch.query(mutation = 'wt', agonist = 'taurine', concentration = '100')
list_30 = batch.query(mutation = 'wt', agonist = 'taurine', concentration = '30')

combined_list = list_100 + list_30
for cluster in combined_list:
    cluster.compute_mode()
    cluster.compute_mode_detail(output = True)

batch_100 = BatchAnalysis(list_100)
cluster_100 = batch_100.compute_cluster_summary()
stretch_100 = batch_100.compute_stretch_summary()

popen_100 = plt.figure()
ax = popen_100.add_subplot(111)
ax.hist(stretch_100['popen'], bins = np.arange(0,1.05,0.05), color = 'blue')
ax.hist(cluster_100['popen'], bins = np.arange(0,1.05,0.05), color = 'red')
ax.set_title('Popen distribution for 100mM taurine')
popen_100.savefig(os.path.join('/Users/zhiyiwu/GitHub/sc_py/data','taurine_100_Popen.png'),dpi=300)
plt.close(popen_100)

open_shut_100 = plt.figure()
ax = open_shut_100.add_subplot(111)
ax.scatter(stretch_100['mean_open'], stretch_100['mean_shut'], s=1, color = 'blue')
ax.scatter(cluster_100['mean_open'], cluster_100['mean_shut'], s=1, color = 'red')
예제 #4
0
concentrations = [1,3,10,100]
for concentration in concentrations:
    for patch in data:
        if float(patch['concentration']) == concentration:
            filename = "./ekdist_traces/{}.scn".format(patch['filename'].decode('utf8'))
#
#            filename = "./raw trace/{}/{}.scn".format(patch['concentration'].decode('utf8'), 
#    patch['filename'].decode('utf8'))
            patch = Patch(filename)
            patch.read_scn(tres=patch['res']*1e-6, tcrit=patch['tcrit']*1e-6)
            cluster_list.extend(patch.get_cluster_list())
            
    
    
    batch_analysis = BatchAnalysis(cluster_list)
    summary = batch_analysis.compute_cluster_summary()
    summary['start'] /= 1000
    summary['end'] /= 1000
    
    np.savetxt('temp.csv', summary, delimiter=',', fmt = '%s,%.18e,%.18e,%.18e,%.18e,%.18e,%.18e,%.18e,%.18e,%.18e,%.18e,%.18e')
    col_name = str(summary.dtype.names)
    col_name = col_name[1:-1] + '\n'
    f = open('temp.csv','r')
    string = f.read()
    string = col_name + string
    f.close()
    f = open('scan_summary_{}.csv'.format(concentration),'w')
    f.write(string)
    f.close()
예제 #5
0
파일: S270T.py 프로젝트: xiki-tempula/sc_py
total_summary = pd.DataFrame()
for concentration in concentation_list:
    cluster_list = batch.query(mutation = 'S270T', concentration = concentration)

    patch_list = batch.query(mutation = 'S270T', concentration = concentration,
                             output = 'patch')
    patch_summary = PatchExamination(patch_list)
    summary = patch_summary.compute_summary_table()
    summary = pd.DataFrame(summary)

    length = len(summary)
#    summary.loc[:,'concentration'] = float(concentration)
    total_summary = total_summary.append(summary, ignore_index=True)

    if cluster_list:
        cluster_summary = BatchAnalysis(cluster_list)
        result = cluster_summary.compute_cluster_summary()

#        plot = sns.jointplot(result['popen'],result['mean_amp'], stat_func= None)
#        plot.set_axis_labels('Popen', 'Amp (pA)')
#        plot.savefig(os.path.join('/Volumes/c-floor/William/data','{}_scatter.png'.format(concentration)),dpi=300)
#        plt.close()
#
#        plot = sns.distplot(result['popen'], bins = np.arange(0,1.05,0.05), kde=False, rug=True);
#        plt.title('Popen distribution ({}mM glycine)'.format(concentration))
#        plt.savefig(os.path.join('/Volumes/c-floor/William/data','{}_Popen_original.png'.format(concentration)),dpi=300)
#        plt.close()
#
        amp.append(result['mean_amp'])
        result = cluster_summary.compute_cluster_summary(patchname = '2015_07_24_0011.csv')