Skip to content

Commit

Permalink
debugging the bugfix - only marking the imputed loci with f64::INFINI…
Browse files Browse the repository at this point in the history
…TY and skipping the loci which were not imputed because they were completely missing across pools
  • Loading branch information
jeffersonfparil committed Nov 2, 2023
1 parent dd6a337 commit 326c28a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
14 changes: 9 additions & 5 deletions src/imputation/adaptive_ld_knn_imputation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,11 +312,15 @@ impl GenotypesAndPhenotypes {
}
}
// Set missing coverages to infinity to mark imputed data
for i in 0..self.coverages.nrows() {
for j in 0..self.coverages.ncols() {
if self.coverages[(i, j)].is_nan() {
self.coverages[(i, j)] = f64::INFINITY
};
for j in 0..self.coverages.ncols() {
// Mark only the imputed loci, i.e. loci which were not completely missing across all pools
let n_non_missing = self.coverages.select(Axis(1), &[j]).fold(0, |sum, &x| if x.is_nan()==false{sum + 1}else{sum});
if n_non_missing > 0 {
for i in 0..self.coverages.nrows() {
if self.coverages[(i, j)].is_nan() {
self.coverages[(i, j)] = f64::INFINITY
};
}
}
}
Ok(self)
Expand Down
14 changes: 9 additions & 5 deletions src/imputation/mean_imputation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,15 @@ impl GenotypesAndPhenotypes {
}
}
// Set missing coverages to infinity to mark imputed data
for i in 0..self.coverages.nrows() {
for j in 0..self.coverages.ncols() {
if self.coverages[(i, j)].is_nan() {
self.coverages[(i, j)] = f64::INFINITY
};
for j in 0..self.coverages.ncols() {
// Mark only the imputed loci, i.e. loci which were not completely missing across all pools
let n_non_missing = self.coverages.select(Axis(1), &[j]).fold(0, |sum, &x| if x.is_nan()==false{sum + 1}else{sum});
if n_non_missing > 0 {
for i in 0..self.coverages.nrows() {
if self.coverages[(i, j)].is_nan() {
self.coverages[(i, j)] = f64::INFINITY
};
}
}
}
Ok(self)
Expand Down

0 comments on commit 326c28a

Please sign in to comment.