gzsbwfj03 commited on
Commit
a28b686
·
verified ·
1 Parent(s): f6a58a1

Update cytof/utils.py

Browse files
Files changed (1) hide show
  1. cytof/utils.py +14 -9
cytof/utils.py CHANGED
@@ -358,7 +358,7 @@ def check_feature_distribution(feature_summary_df, features):
358
  # return None
359
  # return fig
360
 
361
- def visualize_scatter(data, communities, n_community, title, figsize=(5,5), savename=None, show=False, ax=None):
362
  """
363
  data = data to visualize (N, 2)
364
  communities = group indices correspond to each sample in data (N, 1) or (N, )
@@ -372,10 +372,15 @@ def visualize_scatter(data, communities, n_community, title, figsize=(5,5), save
372
  else:
373
  fig = None
374
  ax.set_title(title)
375
- sns.scatterplot(x=data[:,0], y=data[:,1], hue=communities, palette='tab20',
376
- hue_order=np.arange(n_community), ax=ax)
377
- # legend=legend,
378
- # hue_order=np.arange(n_community))
 
 
 
 
 
379
 
380
  ax.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0.)
381
  # plt.axis('tight')
@@ -387,7 +392,7 @@ def visualize_scatter(data, communities, n_community, title, figsize=(5,5), save
387
  plt.show()
388
  if clos:
389
  plt.close('all')
390
- return fig
391
 
392
  def visualize_expression(data, markers, group_ids, title, figsize=(5,5), savename=None, show=False, ax=None):
393
  clos = not show and ax is None
@@ -403,8 +408,8 @@ def visualize_expression(data, markers, group_ids, title, figsize=(5,5), savenam
403
  yticklabels=group_ids,
404
  ax=ax
405
  )
406
- ax.set_xlabel("Markers")
407
- ax.set_ylabel("Phenograph clusters")
408
  ax.set_title("normalized expression - {}".format(title))
409
  ax.xaxis.set_tick_params(labelsize=8)
410
  if savename is not None:
@@ -414,7 +419,7 @@ def visualize_expression(data, markers, group_ids, title, figsize=(5,5), savenam
414
  plt.show()
415
  if clos:
416
  plt.close('all')
417
- return fig
418
 
419
  def _get_thresholds(df_feature: pd.DataFrame,
420
  features: List[str],
 
358
  # return None
359
  # return fig
360
 
361
+ def visualize_scatter(data, communities, n_community, title, scatter_dot_size, figsize=(5,5), savename=None, show=False, ax=None):
362
  """
363
  data = data to visualize (N, 2)
364
  communities = group indices correspond to each sample in data (N, 1) or (N, )
 
372
  else:
373
  fig = None
374
  ax.set_title(title)
375
+ sns.scatterplot(x=data[:,0],
376
+ y=data[:,1],
377
+ hue=communities,
378
+ palette='tab20',
379
+ s=scatter_dot_size,
380
+ alpha=0.9,
381
+ linewidth=0,
382
+ hue_order=np.arange(n_community), ax=ax
383
+ )
384
 
385
  ax.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0.)
386
  # plt.axis('tight')
 
392
  plt.show()
393
  if clos:
394
  plt.close('all')
395
+ return fig, ax
396
 
397
  def visualize_expression(data, markers, group_ids, title, figsize=(5,5), savename=None, show=False, ax=None):
398
  clos = not show and ax is None
 
408
  yticklabels=group_ids,
409
  ax=ax
410
  )
411
+ # ax.set_xlabel("Markers")
412
+ ax.set_ylabel("PhenoGraph clusters")
413
  ax.set_title("normalized expression - {}".format(title))
414
  ax.xaxis.set_tick_params(labelsize=8)
415
  if savename is not None:
 
419
  plt.show()
420
  if clos:
421
  plt.close('all')
422
+ return fig, ax
423
 
424
  def _get_thresholds(df_feature: pd.DataFrame,
425
  features: List[str],