Skip to content

Commit

Permalink
updating call code
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaceves committed Dec 13, 2024
1 parent 3969a60 commit 069e200
Show file tree
Hide file tree
Showing 4 changed files with 361 additions and 186 deletions.
24 changes: 7 additions & 17 deletions src/call_consensus_clustering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ bool cluster_gravity_analysis(std::vector<std::vector<float>> solutions){
return(all_same);
}

bool account_for_clusters(std::vector<float> means, std::vector<std::vector<float>> results){
bool account_for_clusters(std::vector<float> means, std::vector<std::vector<float>> results, float error){
bool keep = false;
float error = 0.10;
std::vector<float> accounted_means;

for(uint32_t i=0; i < results.size(); i++){
Expand All @@ -46,9 +45,6 @@ bool account_for_clusters(std::vector<float> means, std::vector<std::vector<floa
if(means.size() == 0){
keep = true;
} else{
for(auto m : means){
std::cerr << "remaining means " << m << std::endl;
}
keep = false;
}
return(keep);
Expand All @@ -65,9 +61,7 @@ void find_combinations(std::vector<float> means, uint32_t index, std::vector<flo
}
}

std::vector<std::vector<float>> find_solutions(std::vector<float> means){
float error = 0.10;

std::vector<std::vector<float>> find_solutions(std::vector<float> means, float error){
std::vector<float> current;
std::vector<std::vector<float>> results;
find_combinations(means, 0, current, results);
Expand Down Expand Up @@ -110,7 +104,7 @@ std::vector<std::vector<float>> find_solutions(std::vector<float> means){
//find combinations of the clusters
find_combinations(final_results[i], 0, current, results);
//account for points
bool keep = account_for_clusters(useable_means, results);
bool keep = account_for_clusters(useable_means, results, error);
if(keep){
final_final_results.push_back(final_results[i]);
}
Expand Down Expand Up @@ -148,11 +142,6 @@ std::vector<std::vector<uint32_t>> find_combination_peaks(std::vector<float> sol
find_combinations(solution, 0, current, results);
for(uint32_t i=0; i < results.size(); i++){
float sum = std::accumulate(results[i].begin(), results[i].end(), 0.0f);
for(auto x : results[i]){
std::cerr << x << " ";
}
std::cerr << "\n";
std::cerr << "sum " << sum << std::endl;
totals.push_back(sum);
}
//given a solution and the means, map each cluster to the cluster it contains
Expand Down Expand Up @@ -223,8 +212,8 @@ std::vector<float> parse_clustering_results(std::string clustering_file){
void cluster_consensus(std::vector<variant> variants, std::string clustering_file, std::string variants_file){
//output string
float depth_cutoff = 10;
double error = 0.15; //acceptable error when forming solutions

double error = 0.05;
float error_rate = cluster_error(variants_file);
float freq_lower_bound = error_rate;
float freq_upper_bound = 1 - error_rate;
Expand All @@ -235,8 +224,9 @@ void cluster_consensus(std::vector<variant> variants, std::string clustering_fil
std::cerr << "consensus means " << m << std::endl;
}

std::vector<std::vector<float>> solutions = find_solutions(means);
std::vector<std::vector<float>> solutions = find_solutions(means, error);
std::vector<float> solution;

if(solutions.size() == 0){
std::cerr << "no solution found" << std::endl;
exit(1);
Expand Down
2 changes: 1 addition & 1 deletion src/call_consensus_clustering.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
#ifndef call_consensus_clustering
#define call_consensus_clustering

void cluster_consensus(std::vector<variant> variants, std::string clustering_file);
void cluster_consensus(std::vector<variant> variants, std::string clustering_file, std::string variants_filename);

#endif
Loading

0 comments on commit 069e200

Please sign in to comment.