We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6af3a4b commit e8dfa6aCopy full SHA for e8dfa6a
5 files changed
nonlinear-covariate-gwas/__init__.py
@@ -26,4 +26,4 @@
26
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
"""DeepNull."""
28
29
-__version__ = '0.1.2'
+__version__ = '0.1.3'
nonlinear-covariate-gwas/data.py
@@ -169,11 +169,17 @@ def write_plink_or_bolt_file(input_df: pd.DataFrame,
169
for column in df.columns:
170
values = df[column]
171
mask = ~values.isnull()
172
- if (values[mask] == values[mask].astype(int)).all():
173
- # All non-null values are integers. Convert to the 'Int64' type that
174
- # allows nullable integers. This requires nulls to use the pd.NA value
175
- # rather than np.nan.
176
- df[column] = values.fillna(pd.NA).astype('Int64')
+ try:
+ int_values = values[mask].astype(int)
+ except ValueError:
+ # This is a non-numeric field, leave it as-is.
+ continue
177
+ else:
178
+ if (values[mask] == int_values).all():
179
+ # All non-null values are integers. Convert to the 'Int64' type that
180
+ # allows nullable integers. This requires nulls to use the pd.NA value
181
+ # rather than np.nan.
182
+ df[column] = values.fillna(pd.NA).astype('Int64')
183
184
return df.to_csv(
185
path_or_buf, sep='\t', index=False, na_rep=str(missing_value))
nonlinear-covariate-gwas/data_test.py
@@ -164,7 +164,7 @@ def test_load_invalid_plink_or_bolt_file(self, str_contents, msg):
164
def test_write_plink_or_bolt_file(self):
165
df = pd.DataFrame(
166
{
167
- 'FID': [1, 2, 3, 4, 5],
+ 'FID': ['fam1', 'fam1', 'fam1', 'fam2', 'fam3'],
168
'IID': [1, 2, 3, 4, 5],
'age': [45, 50, 55, 60, 65],
'sex': [0, 0, 1, 1, 0],
@@ -175,11 +175,11 @@ def test_write_plink_or_bolt_file(self):
binary_column_map = {'sex': {0: 1, 1: 2}, 'binary_miss': {0.: 1., 1.: 2.}}
expected = ('FID\tIID\tage\tsex\tbinary_miss\tcont_miss\n'
- '1\t1\t45\t1\t1\t0.5\n'
- '2\t2\t50\t1\t2\t1.5\n'
- '3\t3\t55\t2\t2\t2.5\n'
- '4\t4\t60\t2\tNA\t3.5\n'
- '5\t5\t65\t1\t1\tNA\n')
+ 'fam1\t1\t45\t1\t1\t0.5\n'
+ 'fam1\t2\t50\t1\t2\t1.5\n'
+ 'fam1\t3\t55\t2\t2\t2.5\n'
+ 'fam2\t4\t60\t2\tNA\t3.5\n'
+ 'fam3\t5\t65\t1\t1\tNA\n')
actual = data.write_plink_or_bolt_file(
df,
nonlinear-covariate-gwas/setup.py
@@ -17,7 +17,7 @@
17
#
18
# $ pip install deepnull
19
name='deepnull',
20
- version='0.1.2', # Keep in sync with __init__.__version__.
+ version='0.1.3', # Keep in sync with __init__.__version__.
21
description='Models nonlinear interactions between covariates and phenotypes',
22
long_description=long_description,
23
long_description_content_type='text/markdown',
nonlinear-covariate-gwas/train_eval_test.py
@@ -194,6 +194,7 @@ def test_create_deepnull_prediction(self, target_is_binary):
194
design_df = _create_df(target_is_binary=target_is_binary, size=size)
195
design_df['FID'] = np.arange(size)
196
design_df['IID'] = np.arange(size)
197
+ design_df['unused_str_column'] = np.random.choice(list('abcdefg'), size)
198
199
input_df = design_df.copy(deep=True)
200
with tempfile.TemporaryDirectory() as tmpdir:
0 commit comments