aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorzsloan2021-10-12 16:08:54 -0500
committerGitHub2021-10-12 16:08:54 -0500
commit35105c816726b58dc376b2c3925d48077aeca675 (patch)
treea7d184e4eea8aeb4b9bf0d17468ba6a1efafef46 /wqflask
parent70023c835bdeeffc48efafe96626ac5b01b5a6d2 (diff)
parenta212ad123f902b6a9c74bcac1d98bc274cebbdda (diff)
downloadgenenetwork2-35105c816726b58dc376b2c3925d48077aeca675.tar.gz
Merge branch 'testing' into feature/add_resizeable_columns
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/tests/unit/wqflask/marker_regression/test_gemma_mapping.py12
-rw-r--r--wqflask/tests/unit/wqflask/marker_regression/test_run_mapping.py43
-rw-r--r--wqflask/wqflask/marker_regression/run_mapping.py25
-rw-r--r--wqflask/wqflask/static/new/javascript/initialize_show_trait_tables.js2
4 files changed, 40 insertions, 42 deletions
diff --git a/wqflask/tests/unit/wqflask/marker_regression/test_gemma_mapping.py b/wqflask/tests/unit/wqflask/marker_regression/test_gemma_mapping.py
index 4003d68f..58a44b2a 100644
--- a/wqflask/tests/unit/wqflask/marker_regression/test_gemma_mapping.py
+++ b/wqflask/tests/unit/wqflask/marker_regression/test_gemma_mapping.py
@@ -81,10 +81,12 @@ class TestGemmaMapping(unittest.TestCase):
def test_gen_pheno_txt_file(self):
"""add tests for generating pheno txt file"""
with mock.patch("builtins.open", mock.mock_open())as mock_open:
- gen_pheno_txt_file(this_dataset={}, genofile_name="", vals=[
- "x", "w", "q", "we", "R"], trait_filename="fitr.re")
+ gen_pheno_txt_file(
+ this_dataset=AttributeSetter({"name": "A"}),
+ genofile_name="", vals=[
+ "x", "w", "q", "we", "R"])
mock_open.assert_called_once_with(
- '/home/user/data/gn2/fitr.re.txt', 'w')
+ '/home/user/data/gn2/PHENO_KiAEKlCvM6iGTM9Kh_TAlQ.txt', 'w')
filehandler = mock_open()
values = ["x", "w", "q", "we", "R"]
write_calls = [mock.call('NA\n'), mock.call('w\n'), mock.call(
@@ -112,7 +114,7 @@ class TestGemmaMapping(unittest.TestCase):
create_trait.side_effect = create_trait_side_effect
group = MockGroup({"name": "group_X", "samplelist": samplelist})
- this_dataset = AttributeSetter({"group": group})
+ this_dataset = AttributeSetter({"group": group, "name": "A"})
flat_files.return_value = "Home/Genenetwork"
with mock.patch("builtins.open", mock.mock_open())as mock_open:
@@ -132,7 +134,7 @@ class TestGemmaMapping(unittest.TestCase):
flat_files.assert_called_once_with('mapping')
mock_open.assert_called_once_with(
- 'Home/Genenetwork/group_X_covariates.txt', 'w')
+ 'Home/Genenetwork/COVAR_anFZ_LfZYV0Ulywo+7tRCw.txt', 'w')
filehandler = mock_open()
filehandler.write.assert_has_calls([mock.call(
'-9\t'), mock.call('-9\t'), mock.call('-9\t'), mock.call('-9\t'), mock.call('\n')])
diff --git a/wqflask/tests/unit/wqflask/marker_regression/test_run_mapping.py b/wqflask/tests/unit/wqflask/marker_regression/test_run_mapping.py
index c220a072..868b0b0b 100644
--- a/wqflask/tests/unit/wqflask/marker_regression/test_run_mapping.py
+++ b/wqflask/tests/unit/wqflask/marker_regression/test_run_mapping.py
@@ -43,11 +43,11 @@ class TestRunMapping(unittest.TestCase):
})
}
self.dataset = AttributeSetter(
- {"fullname": "dataser_1", "group": self.group, "type": "ProbeSet"})
+ {"fullname": "dataset_1", "group": self.group, "type": "ProbeSet"})
self.chromosomes = AttributeSetter({"chromosomes": chromosomes})
self.trait = AttributeSetter(
- {"symbol": "IGFI", "chr": "X1", "mb": 123313})
+ {"symbol": "IGFI", "chr": "X1", "mb": 123313, "display_name": "Test Name"})
def tearDown(self):
self.dataset = AttributeSetter(
@@ -180,34 +180,36 @@ class TestRunMapping(unittest.TestCase):
with mock.patch("wqflask.marker_regression.run_mapping.datetime.datetime", new=datetime_mock):
export_mapping_results(dataset=self.dataset, trait=self.trait, markers=markers,
- results_path="~/results", mapping_scale="physic", score_type="-log(p)",
- transform="qnorm", covariates="Dataset1:Trait1,Dataset2:Trait2", n_samples="100")
+ results_path="~/results", mapping_method="gemma", mapping_scale="physic",
+ score_type="-logP", transform="qnorm",
+ covariates="Dataset1:Trait1,Dataset2:Trait2",
+ n_samples="100", vals_hash="")
write_calls = [
mock.call('Time/Date: 09/01/19 / 10:12:12\n'),
mock.call('Population: Human GP1_\n'), mock.call(
- 'Data Set: dataser_1\n'),
- mock.call('N Samples: 100\n'), mock.call(
- 'Transform - Quantile Normalized\n'),
+ 'Data Set: dataset_1\n'),
+ mock.call('Trait: Test Name\n'),
+ mock.call('Trait Hash: \n'),
+ mock.call('N Samples: 100\n'),
+ mock.call('Mapping Tool: gemma\n'),
+ mock.call('Transform - Quantile Normalized\n'),
mock.call('Gene Symbol: IGFI\n'), mock.call(
'Location: X1 @ 123313 Mb\n'),
mock.call('Cofactors (dataset - trait):\n'),
mock.call('Trait1 - Dataset1\n'),
mock.call('Trait2 - Dataset2\n'),
mock.call('\n'), mock.call('Name,Chr,'),
- mock.call('Mb,-log(p)'), mock.call('Cm,-log(p)'),
+ mock.call('Mb,-logP'),
mock.call(',Additive'), mock.call(',Dominance'),
mock.call('\n'), mock.call('MK1,C1,'),
- mock.call('12000,'), mock.call('1,'),
- mock.call('3'), mock.call(',VA'),
- mock.call(',TT'), mock.call('\n'),
- mock.call('MK2,C2,'), mock.call('10000,'),
- mock.call('15,'), mock.call('7'),
+ mock.call('12000,'), mock.call('3'),
+ mock.call(',VA'), mock.call(',TT'),
+ mock.call('\n'), mock.call('MK2,C2,'),
+ mock.call('10000,'), mock.call('7'),
mock.call('\n'), mock.call('MK1,C3,'),
- mock.call('1,'), mock.call('45,'),
- mock.call('7'), mock.call(',VE'),
- mock.call(',Tt')
-
+ mock.call('1,'), mock.call('7'),
+ mock.call(',VE'), mock.call(',Tt')
]
mock_open.assert_called_once_with("~/results", "w+")
filehandler = mock_open()
@@ -232,25 +234,20 @@ class TestRunMapping(unittest.TestCase):
"c1": "c1_value",
"c2": "c2_value",
"w1": "w1_value"
-
},
"S2": {
"w1": "w2_value",
"w2": "w2_value"
-
},
"S3": {
"c1": "c1_value",
"c2": "c2_value"
-
},
-
}})
-
results = get_perm_strata(this_trait={}, sample_list=sample_list,
categorical_vars=categorical_vars, used_samples=used_samples)
- self.assertEqual(results, [2, 1])
+ self.assertEqual(results, [1, 1])
def test_get_chr_length(self):
"""test for getting chromosome length"""
diff --git a/wqflask/wqflask/marker_regression/run_mapping.py b/wqflask/wqflask/marker_regression/run_mapping.py
index 290c4a14..80094057 100644
--- a/wqflask/wqflask/marker_regression/run_mapping.py
+++ b/wqflask/wqflask/marker_regression/run_mapping.py
@@ -104,7 +104,7 @@ class RunMapping:
if "results_path" in start_vars:
self.mapping_results_path = start_vars['results_path']
else:
- mapping_results_filename = "_".join([self.dataset.group.name, self.vals_hash]).replace("/", "_")
+ mapping_results_filename = "_".join([self.dataset.group.name, self.mapping_method, self.vals_hash]).replace("/", "_")
self.mapping_results_path = "{}{}.csv".format(
webqtlConfig.GENERATED_IMAGE_DIR, mapping_results_filename)
@@ -405,8 +405,8 @@ class RunMapping:
total_markers = len(self.qtl_results)
with Bench("Exporting Results"):
- export_mapping_results(self.dataset, self.this_trait, self.qtl_results,
- self.mapping_results_path, self.mapping_scale, self.score_type,
+ export_mapping_results(self.dataset, self.this_trait, self.qtl_results, self.mapping_results_path,
+ self.mapping_method, self.mapping_scale, self.score_type,
self.transform, self.covariates, self.n_samples, self.vals_hash)
with Bench("Trimming Markers for Figure"):
@@ -525,7 +525,11 @@ class RunMapping:
return trimmed_genotype_data
-def export_mapping_results(dataset, trait, markers, results_path, mapping_scale, score_type, transform, covariates, n_samples, vals_hash):
+def export_mapping_results(dataset, trait, markers, results_path, mapping_method, mapping_scale, score_type, transform, covariates, n_samples, vals_hash):
+ if mapping_scale == "physic":
+ scale_string = "Mb"
+ else:
+ scale_string = "cM"
with open(results_path, "w+") as output_file:
output_file.write(
"Time/Date: " + datetime.datetime.now().strftime("%x / %X") + "\n")
@@ -535,6 +539,7 @@ def export_mapping_results(dataset, trait, markers, results_path, mapping_scale,
output_file.write("Trait: " + trait.display_name + "\n")
output_file.write("Trait Hash: " + vals_hash + "\n")
output_file.write("N Samples: " + str(n_samples) + "\n")
+ output_file.write("Mapping Tool: " + str(mapping_method) + "\n")
if len(transform) > 0:
transform_text = "Transform - "
if transform == "qnorm":
@@ -564,10 +569,7 @@ def export_mapping_results(dataset, trait, markers, results_path, mapping_scale,
output_file.write("Name,Chr,")
if score_type.lower() == "-logP":
score_type = "-logP"
- if 'Mb' in markers[0]:
- output_file.write("Mb," + score_type)
- if 'cM' in markers[0]:
- output_file.write("Cm," + score_type)
+ output_file.write(scale_string + "," + score_type)
if "additive" in list(markers[0].keys()):
output_file.write(",Additive")
if "dominance" in list(markers[0].keys()):
@@ -575,11 +577,8 @@ def export_mapping_results(dataset, trait, markers, results_path, mapping_scale,
output_file.write("\n")
for i, marker in enumerate(markers):
output_file.write(marker['name'] + "," + str(marker['chr']) + ",")
- if 'Mb' in marker:
- output_file.write(str(marker['Mb']) + ",")
- if 'cM' in marker:
- output_file.write(str(marker['cM']) + ",")
- if "lod_score" in marker.keys():
+ output_file.write(str(marker[scale_string]) + ",")
+ if score_type == "-logP":
output_file.write(str(marker['lod_score']))
else:
output_file.write(str(marker['lrs_value']))
diff --git a/wqflask/wqflask/static/new/javascript/initialize_show_trait_tables.js b/wqflask/wqflask/static/new/javascript/initialize_show_trait_tables.js
index 897f79ff..96ef7a04 100644
--- a/wqflask/wqflask/static/new/javascript/initialize_show_trait_tables.js
+++ b/wqflask/wqflask/static/new/javascript/initialize_show_trait_tables.js
@@ -191,6 +191,7 @@ function loadDataTable(first_run=false, table_id, table_data){
$(row).addClass("value_se");
if (data.outlier) {
$(row).addClass("outlier");
+ $(row).attr("style", "background-color: orange;");
}
$('td', row).eq(1).addClass("column_name-Index")
$('td', row).eq(2).addClass("column_name-Sample")
@@ -262,7 +263,6 @@ function loadDataTable(first_run=false, table_id, table_data){
} );
} ).draw();
-
if (first_run){
$('#' + table_type.toLowerCase() + '_container').css("width", String($('#' + table_id).width() + 17) + "px");
}