-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathprobabilistic_embedding.py
42 lines (33 loc) · 1.27 KB
/
probabilistic_embedding.py
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
from __future__ import print_function, division, absolute_import
from odin.stats import describe
from sisua.data import get_dataset
from sisua.label_threshold import ProbabilisticEmbedding
# ===========================================================================
# Load dataset
# ===========================================================================
FIGURE_PATH = '/tmp/tmp.pdf'
ds, _, _ = get_dataset('pbmc_citeseq')
protein = ds['y']
protein_name = ds['y_col']
print(protein.shape)
print(protein_name)
# ===========================================================================
# Probabilistic Embedding
# ===========================================================================
pb = ProbabilisticEmbedding(
n_components_per_class=2, positive_component=1,
log_norm=True, clip_quartile=0., remove_zeros=True,
ci_threshold=-0.68, random_state=5218,
verbose=True)
pb.fit(protein)
# binarize the protein matrix
y_bin = pb.predict(protein)
print(describe(y_bin))
# probabilize the protein matrix
y_prob = pb.predict_proba(protein)
print(describe(y_prob))
# ====== save the analysis and diagnosis ====== #
pb.boxplot(protein, protein_name
).plot_diagnosis(protein, protein_name
).plot_distribution(protein, protein_name
).save_figures(FIGURE_PATH, verbose=True)