Skip to content

Commit

Permalink
Changes yet to be tested: removes outliers from reference calls too
Browse files Browse the repository at this point in the history
  • Loading branch information
kjaisingh committed Oct 28, 2024
1 parent 9d763a5 commit 40248ae
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
5 changes: 2 additions & 3 deletions src/RdTest/RdTest.R
Original file line number Diff line number Diff line change
Expand Up @@ -1183,12 +1183,11 @@ runRdTest<-function(bed)
#Exclude outlier samples only if non-outlier samples exist
if (!is.null(opt$outlierSampleIds)) {
outlier_ids <- readLines(opt$outlierSampleIds)
outlier_samples <- intersect(sampleIDs, outlier_ids)
non_outlier_samples <- setdiff(sampleIDs, outlier_ids)
if (length(outlier_samples) > 0 && length(non_outlier_samples) > 0) {
if (length(non_outlier_samples) > 0) {
sampleIDs <- non_outlier_samples
cnv_matrix <- cnv_matrix[!(rownames(cnv_matrix) %in% outlier_samples), , drop = FALSE]
}
cnv_matrix <- cnv_matrix[!(rownames(cnv_matrix) %in% outlier_ids), , drop = FALSE]
}
samplesPrior <-unlist(strsplit(as.character(sampleIDs),split=","))

Expand Down
16 changes: 8 additions & 8 deletions src/svtk/svtk/cli/baf_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ def preprocess(chrom, start, end, tbx, samples, window=None, called_samples=None
return bafs, bafs, called_samples
bafs.columns = ['chr', 'pos', 'baf', 'sample']

# Exclude outlier samples only if non-outlier samples exist
filtered_samples = []
retained_samples = called_samples
non_outlier_samples = [s for s in called_samples if s not in outlier_sample_ids]
if (non_outlier_samples):
filtered_samples = [s for s in called_samples if s in outlier_sample_ids]
retained_samples = non_outlier_samples
bafs = bafs[bafs['sample'].isin(samples) & ~bafs['sample'].isin(filtered_samples)]
bafs = bafs[bafs['sample'].isin(samples) & ~bafs['sample'].isin(outlier_sample_ids)]

# Exclude outlier samples from called samples only if non-outlier samples exist
non_outlier_called_samples = [s for s in called_samples if s not in outlier_sample_ids]
if non_outlier_called_samples:
retained_samples = non_outlier_called_samples
else:
retained_samples = called_samples

if bafs.empty:
return bafs, bafs, retained_samples
Expand Down
2 changes: 1 addition & 1 deletion src/svtk/svtk/pesr/pesr_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def test_record(self, record):
def choose_background(self, record, whitelist=None, blacklist=None):
# Select called and background samples
called = svu.get_called_samples(record)
background = [s for s in self.samples if s not in called]
background = [s for s in self.samples if s not in called and s not in self.outlier_sample_ids]

# Exclude outlier samples only if non-outlier samples exist
non_outlier_called = [s for s in called if s not in self.outlier_sample_ids]
Expand Down

0 comments on commit 40248ae

Please # to comment.