-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignanalysis.hpp
250 lines (236 loc) · 8.12 KB
/
signanalysis.hpp
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
//
// apobec.hpp
// APOBECXP
//
// Created by Marat Kazanov on 28/11/2018.
// Copyright © 2018 Marat Kazanov. All rights reserved.
//
#ifndef signanalysis_hpp
#define signanalysis_hpp
#include <stdio.h>
#include <string>
#include <vector>
#include "mutation.hpp"
#include "genehuman.hpp"
#include "expression.hpp"
#include "replicationtime.hpp"
using namespace std;
class CResultsKey {
public:
string motif;
string cancer;
string sample;
int rtbin;
int expbin;
CResultsKey(string motif_, string cancer_, string sample_, int rtbin_, int expbin_);
CResultsKey(string cancer_, string sample_, int rtbin_, int expbin_);
bool operator< (const CResultsKey &right) const
{
if (motif < right.motif)
return true;
else if (motif > right.motif)
return false;
else
{
if (cancer < right.cancer)
return true;
else if (cancer > right.cancer)
return false;
else
{
if (sample < right.sample)
return true;
else if (sample > right.sample)
return false;
else
{
if(rtbin < right.rtbin)
return true;
else if (rtbin > right.rtbin)
return false;
else
{
if (expbin < right.expbin)
return true;
else if (expbin > right.expbin)
return false;
else
return false;
}
}
}
}
}
};
class CResultsValue{
public:
unsigned long mutCnt;
unsigned long leadingCnt;
unsigned long laggingCnt;
unsigned long plusStrandConsistent;
unsigned long minusStrandConsistent;
unsigned long plusStrandAll;
unsigned long minusStrandAll;
CResultsValue(unsigned long mutCnt_, unsigned long leadingCnt_, unsigned long laggingCnt_);
CResultsValue(unsigned long mutCnt_, unsigned long plusStrandConsistent_, unsigned long minusStrandConsistent_, unsigned long plusStrandAll_, unsigned long minusStrandAll_);
CResultsValue(unsigned long mutCnt_, unsigned long leadingCnt_, unsigned long laggingCnt_,unsigned long plusStrandConsistent_, unsigned long minusStrandConsistent_, unsigned long plusStrandAll_, unsigned long minusStrandAll_);
CResultsValue(){};
};
class CRTexpMapKey {
public:
string motif;
int RTbin;
int expbin;
int RTstrand;
int senseStrand;
char mutbase;
CRTexpMapKey(string motif_, int RTbin_, int expbin_, int RTstrand_, int senseStrand_, char mutbase_);
bool operator< (const CRTexpMapKey &right) const
{
if(motif < right.motif)
return true;
else if (motif > right.motif)
return false;
else
{
if(RTbin < right.RTbin)
return true;
else if (RTbin > right.RTbin)
return false;
else
{
if (expbin < right.expbin)
return true;
else if (expbin > right.expbin)
return false;
else
{
if(RTstrand < right.RTstrand)
return true;
else if (RTstrand > right.RTstrand)
return false;
else
{
if(senseStrand < right.senseStrand)
return true;
else if (senseStrand > right.senseStrand)
return false;
else
{
if(mutbase < right.mutbase)
return true;
else if(mutbase > right.mutbase)
return false;
else
return false;
}
}
}
}
}
}
};
class CRTexpMapKey2 {
public:
string motif;
int RTbin;
int expbin;
int RTstrand;
int senseStrand;
CRTexpMapKey2(string motif_, int RTbin_, int expbin_, int RTstrand_, int senseStrand_);
bool operator< (const CRTexpMapKey2 &right) const
{
if(motif < right.motif)
return true;
else if (motif > right.motif)
return false;
else
{
if(RTbin < right.RTbin)
return true;
else if (RTbin > right.RTbin)
return false;
else
{
if (expbin < right.expbin)
return true;
else if (expbin > right.expbin)
return false;
else
{
if(RTstrand < right.RTstrand)
return true;
else if (RTstrand > right.RTstrand)
return false;
else
{
if(senseStrand < right.senseStrand)
return true;
else if (senseStrand > right.senseStrand)
return false;
else
return false;
}
}
}
}
}
};
class CMapKey {
public:
string cancer;
string sample;
CMapKey(string cancer_, string sample_)
{
cancer = cancer_;
sample = sample_;
}
bool operator< (const CMapKey &right) const
{
if (cancer < right.cancer)
return true;
else if (cancer > right.cancer)
return false;
else
{
if (sample < right.sample)
return true;
else
return false;
}
}
};
class CMapValue {
public:
unsigned long APOBECmutsCnt;
unsigned long cytosineMutsCnt;
double enrichment;
double enrichmentExcludeTCW;
CMapValue(unsigned long APOBECmutsCnt_, unsigned long cytosineMutsCnt_, double enrichment_, double enrichmentExcludeTCW_)
{
APOBECmutsCnt = APOBECmutsCnt_;
cytosineMutsCnt = cytosineMutsCnt_;
enrichment = enrichment_;
enrichmentExcludeTCW = enrichmentExcludeTCW_;
}
};
class CSignatureAnalysis {
public:
vector<CMutationSignature> signatures;
CMutations signatureMuts;
CMutations otherMuts;
void ClassifyMutations(CMutations& muts, vector<string> cancers, vector<string> samples, CHumanGenome* phuman_ = NULL);
void AnalyzeReplicationTiming(CMutations& muts, string resultsFilename);
void AnalyzeExpression(CMutations& muts, string resultsFilename);
void AnalyzeRTExpression(CMutations& muts, string resultsFilename);
int GetExpressionBin(string sample, string chr, unsigned long pos, char isForwardMut, CHumanGenes& genes, CExpression& exp, vector<CExpressionBin>& expBins, int& strand, int& strandInconsistence);
void CalculateTargetsinRTBins(string motifname, CHumanGenome* phuman_ = NULL, int isSignatureMotif = 1);
void CalculateTargetsinExpressionBins(string outFilePrefix, CHumanGenome* phuman = NULL, string cancer = "", string sample = "", int isAPOBECmotif = 1);
void CalculateTargetsinRTexpressionBins(string outFilePrefix, CHumanGenome* phuman = NULL, string cancer = "", string sample = "", int isAPOBECmotif = 1);
void CalculateExpressionAllMotifs(CMutations& muts, string outFilePrefix, CHumanGenome* phuman, string cancer, string sample);
void CalculateTargetsinExpBinAllMotifs(string outFilePrefix, CHumanGenome* phuman, string cancer, string sample);
void RTExpAllMotifs(CMutations& muts, string dirpath, CReplicationTiming& rt, CExpression& exp, vector<CExpressionBin> expBins, CHumanGenome* phuman, CHumanGenes genes, string cancer, string sample);
void CalculateAPOBECEnrichment(CHumanGenome* phuman_ = NULL);
set<CCancerSample> LoadCancerSamples(string path);
};
#endif /* signanalysis_hpp */