|
1 | 1 | import sys |
2 | 2 | import gzip |
3 | | - |
| 3 | +import os |
4 | 4 | import numpy as np |
5 | 5 |
|
6 | 6 | class TestSNP: |
@@ -143,7 +143,8 @@ def open_input_files(in_filename): |
143 | 143 |
|
144 | 144 |
|
145 | 145 |
|
146 | | -def read_count_matrices(input_filename, shuffle=False, skip=0, min_counts=0, min_as_counts=0): |
| 146 | +def read_count_matrices(input_filename, shuffle=False, skip=0, |
| 147 | + min_counts=0, min_as_counts=0, sample=0): |
147 | 148 | """Given an input file that contains paths to input files for all individuals, and returns |
148 | 149 | matrix of observed read counts, and matrix of expected read counts |
149 | 150 | """ |
@@ -210,12 +211,12 @@ def read_count_matrices(input_filename, shuffle=False, skip=0, min_counts=0, min |
210 | 211 | sys.stderr.write("expect_matrix dimension: %s\n" % str(expected_matrix.shape)) |
211 | 212 |
|
212 | 213 | nrow = count_matrix.shape[0] |
213 | | - if (options.sample > 0) and (options.sample < count_matrix.shape): |
| 214 | + if (sample > 0) and (sample < count_matrix.shape): |
214 | 215 | # randomly sample subset of rows without replacement |
215 | | - sys.stderr.write("randomly sampling %d target regions\n" % options.sample) |
| 216 | + sys.stderr.write("randomly sampling %d target regions\n" % sample) |
216 | 217 | samp_index = np.arange(nrow) |
217 | 218 | np.random.shuffle(samp_index) |
218 | | - samp_index = samp_index[:options.sample] |
| 219 | + samp_index = samp_index[:sample] |
219 | 220 | count_matrix = count_matrix[samp_index,] |
220 | 221 | expected_matrix = expected_matrix[samp_index,] |
221 | 222 |
|
|
0 commit comments