-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_gold_standard.py
More file actions
52 lines (44 loc) · 1.74 KB
/
test_gold_standard.py
File metadata and controls
52 lines (44 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#load required libraries
import pandas as pd
import scanpy as sc
import matplotlib.pyplot as plt
import seaborn as sns
import os
import liana as li
from liana.method import cellphonedb, cellchat
from tqdm import tqdm
#liana dotplot returns a ggsave object...
from plotnine import ggsave, ggplot
# # verbosity: errors (0), warnings (1), info (2), hints (3)
# sc.settings.verbosity = 3
# sc.settings.set_figure_params(dpi=80, facecolor='white')
#load data
print("Reading data...")
data = sc.read_h5ad("ProcessedData/"+"GF_HF"+"_CellChat.h5ad")
dot_plot = li.pl.dotplot(adata = data,
colour='lr_probs',
size='cellchat_pvals',
inverse_size=True, # we inverse sign since we want small p-values to have large sizes
source_labels=['Kupffer cells'],
target_labels=['Monocytes & Monocyte-derived cells'],
figure_size=(8, 7),
# ligand_complex=['Dll4'],
# finally, since cpdbv2 suggests using a filter to FPs
# we filter the pvals column to <= 0.05
# filter_fun=lambda x: x['cellphone_pvals'] <= 0.05,
uns_key='cpdb_res' # uns_key to use, default is 'liana_res'
)
# fig = dot_plot.get_figure()
# # Save the Figure to a file
#img_name = "figures/"+"GF_HF"+"_dotplot_goldstandard.png"
#fig.savefig(img_name)
# plt.close(fig)
# print(dot_plot)
# print(type(dot_plot))
print(dot_plot)
dot_plot.save(filename="GF_HF_dotplot_goldstandard.png", dpi=300)
# ggsave(plot=dot_plot, filename="GF_HF_dotplot_goldstandard.png", dpi=300)
#fig = draw(dot_plot)
# Save the figure using matplotlib
#fig.savefig("figures/GF_HF_dotplot_goldstandard.png", dpi=300)
#plt.close(fig) # Close the figure if you don't want to display it