Skip to content

Commit

Permalink
reproducible_seed (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
njbernstein authored Dec 23, 2020
1 parent 697e980 commit c584310
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions solo/solo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
import json
import os
import shutil
import anndata

import numpy as np
Expand Down Expand Up @@ -41,6 +40,9 @@ def main():
help='json file to pass VAE parameters')
parser.add_argument(dest='data_path',
help='path to h5ad, loom or 10x directory containing cell by genes counts')
parser.add_argument('--set-reproducible-seed', dest='reproducible_seed',
default=None, type=int,
help='Reproducible seed, give an int to set seed')
parser.add_argument('-d', dest='doublet_depth',
default=2., type=float,
help='Depth multiplier for a doublet relative to the \
Expand Down Expand Up @@ -105,6 +107,9 @@ def main():
if not os.path.isdir(args.out_dir):
os.mkdir(args.out_dir)

if args.reproducible_seed is not None:
torch.manual_seed(args.reproducible_seed)
np.random.seed(args.reproducible_seed)
##################################################
# data

Expand Down Expand Up @@ -435,7 +440,7 @@ def main():

np.save(os.path.join(args.out_dir, 'softmax_scores.npy'),
solo_scores)
np.savetxt(os.path.join(args.out_dir, 'softmax_scores.csv'),
np.savetxt(os.path.join(args.out_dir, 'softmax_scores.csv'),
solo_scores, delimiter=",")


Expand All @@ -458,7 +463,7 @@ def main():

np.save(os.path.join(args.out_dir, 'is_doublet.npy'), is_doublet[:num_cells])
np.savetxt(os.path.join(args.out_dir, 'is_doublet.csv'), is_doublet[:num_cells], delimiter=",")

np.save(os.path.join(args.out_dir, 'is_doublet_sim.npy'), is_doublet[num_cells:])

np.save(os.path.join(args.out_dir, 'preds.npy'), order_pred[:num_cells])
Expand Down

0 comments on commit c584310

Please sign in to comment.