-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcolocalisation.cpp
More file actions
98 lines (70 loc) · 3.58 KB
/
colocalisation.cpp
File metadata and controls
98 lines (70 loc) · 3.58 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// this object will wrap all functionalities needed to compute the colocalisation matrix
#include "colocalisation.h"
#include "colocalization_matrix.h"
colocalisation::~colocalisation(){
delete expression;
}
// run steps to compute colocalisation matrix
void colocalisation::compute(){
// compute colocalisation matrix
step1();
std::cout << "[Progress] Step 1 finished successfully ..." << std::endl;
step2();
std::cout << "[Progress] Step 2 finished successfully ..." << std::endl;
step3();
std::cout << "[Progress] Step 3 finished successfully ..." << std::endl;
step4();
std::cout << "[Progress] Step 4 finished successfully ..." << std::endl;
step5();
std::cout << "[Progress] Step 5 finished successfully ..." << std::endl;
}
// save colocalisation matrix to file
void colocalisation::saveToFile(std::string filename){
std::cout << "[Progress] Saving File ..." << std::endl;
expression_raw.writeToFile(filename,*A_colocalisation,expression_raw.getcurrentGenes());
delete A_colocalisation;
}
// Individual steps to compute the colocalisation matrix
void colocalisation::step1(){
// step 1 - create distance matrix
std::cout << "[Progress] Running step 1 ..." << std::endl;
A_distance = new Eigen::MatrixXd;
*A_distance = matrix_distance(A_spatial);
std::cout<<(*A_distance).block(0,0,std::min((int)A_distance->rows(),10),std::min((int)A_distance->cols(),10))<<std::endl;
std::cout<<"\nDistance matrix shape: (" << (*A_distance).rows() << ", " << (*A_distance).cols() << ")"<<std::endl;
}
void colocalisation::step2(){
// step 2 - linkage matrix with parameters m and p
std::cout << "[Progress] Running step 2 ..." << std::endl;
A_linkage = new Eigen::MatrixXd;
*A_linkage = matrix_linkage(*A_distance, m, p);
delete A_distance;
std::cout<<(*A_linkage).block(0,0,std::min((int)A_linkage->rows(),10),std::min((int)A_linkage->cols(),10))<<std::endl;
std::cout<<"\nLinkage matrix shape: (" << (*A_linkage).rows() << ", " << (*A_linkage).cols() << ")"<<std::endl;
}
void colocalisation::step3(){
// step 3 - apply linkage to expression matrix -> neighbouring matrix
std::cout << "[Progress] Running step 3 ..." << std::endl;
A_combine = new Eigen::MatrixXd;
*A_combine = combine_linkage(*A_linkage,*expression);
delete A_linkage;
std::cout<<A_combine->block(0,0,std::min((int)A_combine->rows(),10),std::min((int)A_combine->cols(),10))<<std::endl;
std::cout<<"\n Comparison matrix shape: (" << A_combine->rows() << ", " << A_combine->cols() << ")"<<std::endl;
}
void colocalisation::step4(){
// step 4 - compare expression and neighbouring matrices (with default parameters
std::cout << "[Progress] Running step 4 ..." << std::endl;
A_compare = new Eigen::MatrixXd;
*A_compare = comparison_old(*expression, *A_combine);
std::cout<<A_compare->block(0,0,std::min((int)A_compare->rows(),10),std::min((int)A_compare->cols(),10))<<std::endl;
std::cout<<"\n Comparison matrix shape: (" << A_compare->rows() << ", " << A_compare->cols() << ")"<<std::endl;
delete A_combine;
}
void colocalisation::step5(){
// step 5 - compute enrichement score
std::cout << "[Progress] Running step 5 ..." << std::endl;
A_colocalisation = new Eigen::MatrixXd;
*A_colocalisation = enrichment(*A_compare);
std::cout<<A_colocalisation->block(0,0,std::min((int)A_colocalisation->rows(),10),std::min((int)A_colocalisation->cols(),10))<<std::endl;
std::cout<<"\n Colocalisation matrix shape: (" << A_colocalisation->rows() << ", " << A_colocalisation->cols() << ")"<<std::endl;
}