Function bodies 54 total
plot_difference function · python · L589-L604 (16 LOC)utils/spatial-shiny/vectra_lib_v4.py
def plot_difference(data, ax = False):
pcf_dm = np.median(np.vstack(data['normPCF']),axis=0)
pcf_dsem = error_median(data['normPCF'])
if ax == False:
fig, ax = plt.subplots()
fig.set_size_inches(8,5)
ax.plot(x_data, pcf_dm)
ax.fill_between(x_data, pcf_dsem[0], pcf_dsem[1], alpha = .4, lw=0)
ax.set_title(data['Cell_one'].iloc[0] + ' vs. ' + data['Cell_two'].iloc[0], fontsize = 18);
ax.plot(x_data, np.ones(len(x_data)), 'k--');
ax.set_xlabel('Radius ($\mu$m)', fontsize = 16);
ax.set_ylabel('PCF', fontsize = 16);
ax.tick_params(axis='both', which='major', labelsize=14);interaction_subset function · python · L606-L609 (4 LOC)utils/spatial-shiny/vectra_lib_v4.py
def interaction_subset(df, cell1, cell2, min_count=0):
pcf_table = df[(((df['Cell_one']==cell1) & (df['Cell_two']==cell2)) | ((df['Cell_one']==cell2) & (df['Cell_two']==cell1)) ) & (df['min_count'] > min_count)]
#pcf_table = pcf_table[pcf_table['PCF'] != 'NA']
return pcf_tableplot_pcf_curves function · python · L613-L727 (115 LOC)utils/spatial-shiny/vectra_lib_v4.py
def plot_pcf_curves(pcf_df,cell_types_,resolution,label,out_path,radius):
CELL_TYPES_ALIAS =['All']
CELL_TYPES_ALIAS.extend(cell_types_)
CELL_TYPES = CELL_TYPES_ALIAS
COLOR_LIST = sns.color_palette(None, len(CELL_TYPES))
print(COLOR_LIST)
#x_data = np.arange(0, 125, .25)
rmax=radius/resolution
stepsize=rmax/500
x_data = np.arange(0,rmax,stepsize)
# fig = plt.figure(figsize=(10, 10))
# #outer = mpl.gridspec.GridSpec(3, 3, wspace=0.2, hspace=0.2)
# outer = mpl.gridspec.GridSpec(int(np.ceil(np.sqrt(len(CELL_TYPES))))+1, int(np.ceil(np.sqrt(len(CELL_TYPES)))), wspace=0.4, hspace=0.4)
# print(str(outer.ncols))
# print(str(outer.nrows))
# print(len(CELL_TYPES))
# print(CELL_TYPES)
pcfs_global=[]
for i in range(len(CELL_TYPES)):
print('i: '+str(i))
print(CELL_TYPES[i])
# inner = mpl.gridspec.GridSpecFromSubplotSpec(2, 1,
# subplot_spec=outer[i], wspace=0.2, hspace=0.2, height_ratios=[1,2])
#
#
# pcf_AUC function · python · L730-L830 (101 LOC)utils/spatial-shiny/vectra_lib_v4.py
def pcf_AUC(pcf_df,cell_types_,cell1,label,out_path,resolution):
CELL_TYPES = ['All']
CELL_TYPES.extend(cell_types_)
print(CELL_TYPES)
CELL_TYPES_ALIAS = CELL_TYPES
CELL2_LIST = CELL_TYPES
print(CELL_TYPES)
CELL2_LIST.pop(CELL_TYPES.index(cell1))
print(CELL_TYPES)
LABELS = CELL_TYPES
print(cell1)
print(LABELS)
print('Cell 2 list:')
print(CELL2_LIST)
COLORS = sns.color_palette(None, len(CELL_TYPES))
STEP_TO_UM = resolution
def interaction_subset(df, cell1, cell2, min_count=0):
pcf_table = df[(((df['Cell_one']==cell1) & (df['Cell_two']==cell2)) | ((df['Cell_one']==cell2) & (df['Cell_two']==cell1)) ) & (df['min_count'] > min_count)]
#pcf_table = pcf_table[pcf_table['PCF'] != 'NA']
return pcf_table
def pvalue_text(data1, data2, verbose = False):
pvalue = stats.mannwhitneyu(data1, data2, alternative='two-sided')[1]
if verbose:
print(pvalue)
if pvalue < 0.001:
return '***'
elif pvalue < 0.01:
‹ prevpage 2 / 2