Skip to content

Commit

Permalink
Remove redundant code from motif result script
Browse files Browse the repository at this point in the history
  • Loading branch information
tnitka committed Mar 15, 2024
1 parent 4ff1b0a commit cdb04f7
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions snekmer/scripts/motif_motif.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
skm.utils.split_file_ext(snakemake.input.weights)[0],
regex=config["input_file_regex"],
)
# scores = coeffs.iloc[score_index]
scorer = skm.score.KmerScorer()

gc.collect()
Expand All @@ -72,24 +71,21 @@
alphabet_name = str(config["alphabet"]).capitalize()


# run permutations and score each

# gather scores from rescoring jobs
score_matrix = kmers.rename(columns={"0": "kmer"})
# score_matrix.rename(columns={"0": "kmer"}, inplace=True)
score_array = pd.DataFrame.to_numpy(score_matrix)
motif = skm.motif.SnekmerMotif()
for file in snakemake.input.perm_scores:
with gzip.open(file) as f:
perm_scores = pd.DataFrame.to_numpy(pd.read_csv(f))
score_array = np.hstack((score_array, perm_scores))

else:
score_array = np.delete(score_array, 0, 1)
score_matrix = score_matrix.merge(
pd.DataFrame(score_array), left_index=True, right_index=True
)

score_array = np.delete(score_array, 0, 1)
score_matrix = score_matrix.merge(
pd.DataFrame(score_array), left_index=True, right_index=True
)

# format output
scores = np.ravel(scores)
output_matrix = motif.p_values(score_matrix, scores, n_iter)
output_matrix = output_matrix.astype(
Expand Down

0 comments on commit cdb04f7

Please sign in to comment.