-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_pcs_dens.py
46 lines (33 loc) · 1.39 KB
/
plot_pcs_dens.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
43
44
45
# imports the pcreode package
import pcreode
# matplotlib is a commonly used package for plotting
import matplotlib.pyplot as plt
# pandas is a package used for making the handling of large data sets easier
import pandas as pd
# numpy is very common package for handling arrays and matrices
import numpy as np
file_nm = "./Myeloid_with_IDs.csv"
data_raw = pd.read_csv( file_nm)
data_raw.head()
data_pca = pcreode.PCA( data_raw)
data_pca.get_pca()
pca_test_data = data_pca.pca_set_components( 5)
fig = plt.figure( figsize=(12,12))
ax1 = fig.add_subplot(221)
ax2 = fig.add_subplot(222)
ax3 = fig.add_subplot(223)
ax4 = fig.add_subplot(224)
cc = 'r'
ax1.scatter( pca_test_data[:,0], pca_test_data[:,1], alpha=0.5, s=25, c=cc)
ax2.scatter( pca_test_data[:,2], pca_test_data[:,1], alpha=0.5, s=25, c=cc)
ax3.scatter( pca_test_data[:,2], pca_test_data[:,3], alpha=0.5, s=25, c=cc)
ax4.scatter( pca_test_data[:,4], pca_test_data[:,3], alpha=0.5, s=25, c=cc)
ax1.set_xlabel("PC1", fontsize=15), ax1.set_ylabel("PC2", fontsize=15)
ax2.set_xlabel("PC3", fontsize=15), ax2.set_ylabel("PC2", fontsize=15)
ax3.set_xlabel("PC3", fontsize=15), ax3.set_ylabel("PC4", fontsize=15)
ax4.set_xlabel("PC5", fontsize=15), ax4.set_ylabel("PC4", fontsize=15)
fig_name = './PCA_fig'
fig.savefig()
pca_test_data = data_pca.pca_set_components( 5)
pca_reduced_data = data_pca.pca_set_components( 3)
dens = pcreode.Density( pca_reduced_data)