Update geneformer/emb_extractor.py

#350
Files changed (1) hide show
  1. geneformer/emb_extractor.py +4 -2
geneformer/emb_extractor.py CHANGED
@@ -270,7 +270,9 @@ def plot_umap(embs_df, emb_dims, label, output_file, kwargs_dict):
270
  if kwargs_dict is not None:
271
  default_kwargs_dict.update(kwargs_dict)
272
 
273
- sc.pl.umap(adata, color=label, save=output_file, **default_kwargs_dict)
 
 
274
 
275
 
276
  def gen_heatmap_class_colors(labels, df):
@@ -783,7 +785,7 @@ class EmbExtractor:
783
  output_file = (
784
  Path(output_directory) / output_prefix_label
785
  ).with_suffix(".pdf")
786
- plot_umap(embs, emb_dims, label, output_prefix_label, kwargs_dict)
787
 
788
  if plot_style == "heatmap":
789
  for label in self.labels_to_plot:
 
270
  if kwargs_dict is not None:
271
  default_kwargs_dict.update(kwargs_dict)
272
 
273
+ with plt.rc_context():
274
+ sc.pl.umap(adata, color=label, **default_kwargs_dict)
275
+ plt.savefig(output_file, bbox_inches="tight")
276
 
277
 
278
  def gen_heatmap_class_colors(labels, df):
 
785
  output_file = (
786
  Path(output_directory) / output_prefix_label
787
  ).with_suffix(".pdf")
788
+ plot_umap(embs, emb_dims, label, output_file, kwargs_dict)
789
 
790
  if plot_style == "heatmap":
791
  for label in self.labels_to_plot: