Skip to content

Commit 3b3fee2

Browse files
committed
monclonal single-source seeding
1 parent 0b63771 commit 3b3fee2

File tree

4 files changed

+108
-0
lines changed

4 files changed

+108
-0
lines changed

CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,19 @@ set( pmh_pr_src
8484
src/migrationgraph.h
8585
)
8686

87+
set( ms_hdr
88+
src/utils.h
89+
src/frequencymatrix.h
90+
)
91+
92+
set( ms_src
93+
src/ms.cpp
94+
src/utils.cpp
95+
src/frequencymatrix.cpp
96+
src/utils.h
97+
src/frequencymatrix.h
98+
)
99+
87100
set( pmh_cti_hdr
88101
src/utils.h
89102
src/nonbinaryclonetree.h
@@ -259,6 +272,9 @@ add_executable( pmh_cti ${pmh_cti_src} ${pmh_cti_hdr} )
259272
target_include_directories( pmh_cti PUBLIC "${LIBLEMON_ROOT}/include" "src" ${Boost_INCLUDE_DIRS} ${GUROBI_INCLUDE_DIR} )
260273
target_link_libraries( pmh_cti ${CommonLibs} ${GUROBI_LIBRARIES} )
261274

275+
add_executable( ms ${ms_src} ${ms_hdr} )
276+
target_link_libraries( ms ${CommonLibs} )
277+
262278
add_executable( generatemigrationtrees ${generatemigrationtrees_src} ${generatemigrationtrees_hdr} )
263279
target_link_libraries( generatemigrationtrees ${CommonLibs} )
264280

src/frequencymatrix.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,30 @@ FrequencyMatrix::FrequencyMatrix()
1818
{
1919
}
2020

21+
bool FrequencyMatrix::mS() const
22+
{
23+
bool res = true;
24+
for (int s = 0; s < _m; ++s)
25+
{
26+
for (int t = 0; t < s; ++t)
27+
{
28+
for (int i = 0; i < _n; ++i)
29+
{
30+
if (isSurelySubclonal(s, i) && isSurelySubclonal(t, i))
31+
{
32+
std::cerr << "Mutation '" << _indexToCharacter[i] << "'"
33+
<< " is surely subclonal in anatomical sites '"
34+
<< _indexToSample[s] << "' and '" << _indexToSample[t] << "'"
35+
<< std::endl;
36+
res = false;
37+
}
38+
}
39+
}
40+
}
41+
42+
return res;
43+
}
44+
2145
std::ostream& operator<<(std::ostream& out, const FrequencyMatrix& F)
2246
{
2347
out << F._m << " #samples" << std::endl;

src/frequencymatrix.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,26 @@ class FrequencyMatrix
120120
return Sigma;
121121
}
122122

123+
/// Return whether a mutation is surely subclonal
124+
///
125+
/// @param s Sample index
126+
/// @param i Character index
127+
bool isSurelySubclonal(int s, int i) const
128+
{
129+
for (int j = 0; j < _n; ++j)
130+
{
131+
if (i == j) continue;
132+
133+
if (_f[s][i].second < _f[s][j].first && _f[s][i].first > 0)
134+
return true;
135+
}
136+
137+
return false;
138+
}
139+
140+
/// Return whether (F^-, F+^) satisfy a necessary condition for mS
141+
bool mS() const;
142+
123143
private:
124144
typedef std::pair<double, double> DoublePair;
125145
typedef std::vector<DoublePair> DoublePairVector;

src/ms.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* ms.cpp
3+
*
4+
* Created on: 3-jul-2017
5+
* Author: M. El-Kebir
6+
*/
7+
8+
#include "utils.h"
9+
#include "frequencymatrix.h"
10+
#include <fstream>
11+
#include <lemon/arg_parser.h>
12+
13+
int main(int argc, char** argv)
14+
{
15+
lemon::ArgParser ap(argc, argv);
16+
ap.other("frequencies", "Frequencies");
17+
ap.parse();
18+
19+
if (ap.files().size() != 1)
20+
{
21+
std::cerr << "Error: <frequencies> must be specified" << std::endl;
22+
return 1;
23+
}
24+
25+
std::string filenameFrequencies = ap.files()[0];
26+
27+
std::ifstream inFrequencies(filenameFrequencies.c_str());
28+
if (!inFrequencies.good())
29+
{
30+
std::cerr << "Could not open '" << filenameFrequencies << "' for reading" << std::endl;
31+
return 1;
32+
}
33+
34+
FrequencyMatrix F;
35+
inFrequencies >> F;
36+
inFrequencies.close();
37+
38+
if (F.mS())
39+
{
40+
std::cerr << "Provided frequency matrix is potentially generated by a clone tree with a monoclonal single-source seeding pattern" << std::endl;
41+
}
42+
else
43+
{
44+
std::cerr << "Provided frequency matrix is NOT generated by a clone tree with a monoclonal single-source seeding pattern" << std::endl;
45+
}
46+
47+
return 0;
48+
}

0 commit comments

Comments
 (0)