CENT AMPLIFICATION: SMAD VS VORO AREA¶
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())
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]:
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()
Out[27]:
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 [ ]: