Skip to content

Commit

Permalink
Minor script updates - formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
kjaisingh committed Feb 18, 2025
1 parent aeadce2 commit a976cd7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
19 changes: 6 additions & 13 deletions src/svtk/svtk/cli/baf_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,11 @@ def preprocess(chrom, start, end, tbx, samples, window=None, called_samples=None

# 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 len(non_outlier_called_samples) > 0:
called_samaples = non_outlier_called_samples

if bafs.empty:
return bafs, bafs, retained_samples
return bafs, bafs, called_samaples

bafs['pos'] = bafs.pos.astype(int)
bafs['baf'] = bafs.baf.astype(float)
Expand All @@ -84,7 +82,7 @@ def preprocess(chrom, start, end, tbx, samples, window=None, called_samples=None

# Report BAF for variants inside CNV
called_bafs = bafs.loc[bafs.region == 'inside'].copy()
return het_counts, called_bafs, retained_samples
return het_counts, called_bafs, called_samaples


def main(argv):
Expand Down Expand Up @@ -163,12 +161,7 @@ def main(argv):
min(end - start, 1000000), random_state=random_state)
KS = KS2sample(called_bafs, samplelist)
ks, ksp = KS.test(samplelist)
try:
mean, delp = Del.Ttest(samplelist)
except Exception:
print(samplelist)
print(het_counts)
raise Exception
mean, delp = Del.Ttest(samplelist)
statis = Del.stats(samplelist)
line = chrom + '\t' + str(start) + '\t' + str(end) + '\t' + id + '\t' + samples + '\t' + type + '\t' + str(
mean) + ',' + str(delp) + "\t" + str(ks) + ',' + str(ksp) + '\t' + statis
Expand Down
6 changes: 5 additions & 1 deletion src/svtk/svtk/pesr/pesr_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,16 @@ 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 and s not in self.outlier_sample_ids]
background = [s for s in self.samples if s not in called]

# 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]
if len(non_outlier_called) > 0:
called = non_outlier_called

non_outlier_background = [s for s in background if s not in self.outlier_sample_ids]
if len(non_outlier_background) > 0:
background = non_outlier_background

# Permit override of specified white/blacklists
whitelist = whitelist if whitelist is not None else self.whitelist
Expand Down

0 comments on commit a976cd7

Please sign in to comment.