Second Post

Posted by Remi on Sat 23 September 2017

CENT AMPLIFICATION: SMAD VS VORO AREA

Extract and save cellular features

run twice to extract CENT>2 and CTRL features: first add 'CT' and after 'CA' to EXP_COND

In [26]:
% matplotlib inline
import matplotlib.pyplot as plt

import image_features_extraction.Images as fe
import numpy as np
import pandas as pd

EXP_COND = 'CT'

IMGS_BIN = fe.Images('./{}/bin'.format(EXP_COND))
IMGS_SMAD = fe.Images('./{}/smad'.format(EXP_COND))
IMGS_YAP = fe.Images('./{}/yap'.format(EXP_COND))
IMGS_DNA = fe.Images('./{}/dna'.format(EXP_COND))

print(IMGS_BIN.file_names())
print(IMGS_SMAD.file_names())
print(IMGS_YAP.file_names())
print(IMGS_DNA.file_names())
['CT_24_DNA_bin.tif']
['CT_24_SMAD.tif']
['CT_24_YAP.tif']
['CT_24_DNA.tif']
In [27]:
A1 = IMGS_BIN.item(0)

fig, ax = plt.subplots(figsize=(20, 20))
ax.imshow(A1.get_image_segmentation())
Out[27]:
In [28]:
vor = A1.Voronoi()

V1 = vor.get_voronoi_map()

IMG_MIX = V1 + A1.get_image()/17

fig = plt.figure(figsize=(20,20))
plt.imshow(IMG_MIX, cmap=plt.get_cmap('pink'))
Out[28]:

features for nuclear and voronoi

In [29]:
IMG_BIN = IMGS_BIN.item(0)
#A1.set_image_intensity(IMGS_SMAD.item(0))
VORO = IMG_BIN.Voronoi()

FEATURES_NUCL = IMG_BIN.features(['area','perimeter','centroid','minor_axis_length','major_axis_length', \
                        'eccentricity','extent', 'equivalent_diameter',\
                        'solidity'], prefix='nucl_')


FEATURES_VORO = VORO.features(['area','perimeter','centroid','minor_axis_length','major_axis_length', \
                        'eccentricity','extent', 'equivalent_diameter',\
                        'solidity'], prefix='voro_')

FEATURES_MAIN = FEATURES_NUCL.merge(FEATURES_VORO)

nucl voro centroid distance

In [30]:
# ADD SMAD ACTIVATION 
df = FEATURES_MAIN.get_dataframe()

xn = np.array([c[0] for c in df.nucl_centroid])
yn = np.array([c[1] for c in df.nucl_centroid])
xv = np.array([c[0] for c in df.voro_centroid])
yv = np.array([c[1] for c in df.voro_centroid])

centr_dist = np.sqrt((xn-xv)**2+(yn-yv)**2)

FEATURES_MAIN.add_feature('nucl_voro_centroid_distance', centr_dist)
In [31]:
fig = plt.figure(figsize=(10,10))
plt.plot(xn,yn,'.b')
plt.plot(xv,yv,'.r')
Out[31]:
[]

proteins intensity

In [32]:
def NUCL_PROT_INTENSITY(IMG_BIN, IMG_8BIT, prefix='protein'):
    # NUCLER INTENSITY OF DIFFERENT PROTEINS
    IMG_BIN.set_image_intensity(IMG_8BIT)
    VORO = IMG_BIN.Voronoi()
    
    pref_nucl = 'nucl_'+ prefix +'_'
    pref_voro = 'voro_'+ prefix +'_'
    
    FEATURES_NUCL = IMG_BIN.features(['intensity_image','mean_intensity', 'max_intensity', 'min_intensity'], prefix=pref_nucl)
    FEATURES_VORO = VORO.features(['intensity_image','mean_intensity', 'max_intensity', 'min_intensity'], prefix=pref_voro)

    return FEATURES_NUCL.merge(FEATURES_VORO)
In [33]:
FEATURES_SMAD = NUCL_PROT_INTENSITY(IMG_BIN, IMGS_SMAD.item(0), prefix='smad')

FEATURES_YAP = NUCL_PROT_INTENSITY(IMG_BIN, IMGS_YAP.item(0), prefix='yap')

FEATURES_DNA = NUCL_PROT_INTENSITY(IMG_BIN, IMGS_DNA.item(0), prefix='dna')

add ratio cyto/nucl intensity (protein activity)

In [34]:
# ADD SMAD ACTIVATION 
df = FEATURES_SMAD.get_dataframe()
df_main = FEATURES_MAIN.get_dataframe()

In = np.array([np.sum(I) for I in df.nucl_smad_intensity_image])
Iv = np.array([np.sum(I) for I in df.voro_smad_intensity_image])

voro_mean_intensity_nonucl = (Iv-In)/(df_main.voro_area-df_main.nucl_area)

activity = df.nucl_smad_mean_intensity / voro_mean_intensity_nonucl

FEATURES_SMAD.add_feature('nucl_smad_activity', activity)


# ADD YAP ACTIVATION 
df = FEATURES_YAP.get_dataframe()
df_main = FEATURES_MAIN.get_dataframe()

In = np.array([np.sum(I) for I in df.nucl_yap_intensity_image])
Iv = np.array([np.sum(I) for I in df.voro_yap_intensity_image])

voro_mean_intensity_nonucl = (Iv-In)/(df_main.voro_area-df_main.nucl_area)

activity = df.nucl_yap_mean_intensity / voro_mean_intensity_nonucl

FEATURES_YAP.add_feature('nucl_yap_activity', activity)

Joins features and save

In [35]:
FEATURES_FINAL = FEATURES_MAIN.merge(FEATURES_SMAD)
FEATURES_FINAL = FEATURES_FINAL.merge(FEATURES_YAP)
FEATURES_FINAL = FEATURES_FINAL.merge(FEATURES_DNA)

# ADD FEATURE: FILE_NAME
FEATURES_FINAL.add_feature('key_filename', IMG_BIN.file_name())

# ADD FEATURE: EXP_COND
FEATURES_FINAL.add_feature('key_experiment', EXP_COND)
In [36]:
# SAVE
FEATURES_FINAL.save('./DATA_EXP2.csv')
Out[36]:
1

SAVED!! (repeat for CT or CA by changing the values in the first cell above)

In [27]:
df1 = FEATURES_FINAL.get_dataframe()
print(df1.columns.values)
df1.head()
['id' 'nucl_area' 'nucl_perimeter' 'nucl_centroid' 'nucl_minor_axis_length'
 'nucl_major_axis_length' 'nucl_eccentricity' 'nucl_extent'
 'nucl_equivalent_diameter' 'nucl_solidity' 'voro_area' 'voro_perimeter'
 'voro_centroid' 'voro_minor_axis_length' 'voro_major_axis_length'
 'voro_eccentricity' 'voro_extent' 'voro_equivalent_diameter'
 'voro_solidity' 'nucl_smad_intensity_image' 'nucl_smad_mean_intensity'
 'nucl_smad_max_intensity' 'nucl_smad_min_intensity'
 'voro_smad_intensity_image' 'voro_smad_mean_intensity'
 'voro_smad_max_intensity' 'voro_smad_min_intensity' 'nucl_smad_activity'
 'nucl_yap_intensity_image' 'nucl_yap_mean_intensity'
 'nucl_yap_max_intensity' 'nucl_yap_min_intensity'
 'voro_yap_intensity_image' 'voro_yap_mean_intensity'
 'voro_yap_max_intensity' 'voro_yap_min_intensity' 'nucl_yap_activity'
 'nucl_dna_intensity_image' 'nucl_dna_mean_intensity'
 'nucl_dna_max_intensity' 'nucl_dna_min_intensity'
 'voro_dna_intensity_image' 'voro_dna_mean_intensity'
 'voro_dna_max_intensity' 'voro_dna_min_intensity' 'key_filename'
 'key_experiment']
Out[27]:
id nucl_area nucl_perimeter nucl_centroid nucl_minor_axis_length nucl_major_axis_length nucl_eccentricity nucl_extent nucl_equivalent_diameter nucl_solidity ... nucl_dna_intensity_image nucl_dna_mean_intensity nucl_dna_max_intensity nucl_dna_min_intensity voro_dna_intensity_image voro_dna_mean_intensity voro_dna_max_intensity voro_dna_min_intensity key_filename key_experiment
0 34 137 42.041631 (26.8175182482, 235.839416058) 12.663302 14.073133 0.436259 0.698980 13.207340 0.964789 ... [[0, 0, 0, 149, 149, 0, 0, 0, 0, 0, 0, 0, 0, 0... 148.481752 211 114 [[0, 0, 14, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0,... 48.934879 211 13 ./images/exp2/CA/bin/CA_24H_NUCL_bin.tif CA
1 41 333 67.597980 (34.033033033, 1629.8048048) 18.633728 22.942173 0.583373 0.689441 20.590988 0.979412 ... [[0, 0, 0, 0, 0, 0, 165, 166, 160, 142, 127, 1... 146.132132 206 101 [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,... 44.293905 206 10 ./images/exp2/CA/bin/CA_24H_NUCL_bin.tif CA
2 43 295 64.769553 (37.6338983051, 1870.69152542) 15.644891 24.111132 0.760903 0.670455 19.380549 0.964052 ... [[0, 0, 0, 0, 0, 0, 0, 0, 53, 0, 0, 0, 0, 0, 0... 67.816949 88 49 [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 11, 0, ... 20.657997 88 9 ./images/exp2/CA/bin/CA_24H_NUCL_bin.tif CA
3 44 383 73.012193 (41.2036553525, 91.4856396867) 18.425584 26.591939 0.721033 0.696364 22.082816 0.979540 ... [[0, 0, 0, 0, 0, 86, 77, 73, 0, 0, 0, 0, 0, 0,... 62.151436 93 43 [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,... 32.942001 93 13 ./images/exp2/CA/bin/CA_24H_NUCL_bin.tif CA
4 45 297 64.870058 (36.67003367, 1562.82491582) 16.897147 22.850960 0.673211 0.750000 19.446134 0.973770 ... [[85, 128, 156, 168, 170, 165, 163, 149, 127, ... 175.336700 223 85 [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,... 64.474673 223 11 ./images/exp2/CA/bin/CA_24H_NUCL_bin.tif CA

5 rows × 47 columns

CENT-AMP: correlation voro area smad activity (mean)

In [11]:
b = plt.hist(df1.nucl_smad_activity, 100)
In [31]:
from scipy.stats import binned_statistic

# BINNIG
x = df1.voro_area
y = df1.nucl_smad_activity

s = binned_statistic(x, y, bins=500, range=(0, 15000))
yy = s[0]
xx = s[1]


# PLOR
fig, ax = plt.subplots(figsize=(10, 10))
plt.xlim([100,15000])
plt.ylim([-0.1,6])
plt.plot(xx[0:-1],yy, '.b')
plt.xlabel('voro area (px*px)')
plt.ylabel('nuclear SMAD mean intensity/voro-area mean intensity (a.u)')
Out[31]:
In [ ]: