From f07b917cb83cd20a36db7bc72d8b79d7511ca585 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 30 Jun 2025 09:30:43 -0500 Subject: Allow independent transposition of each file * Rework UI to provide independent selection of whether or not each file is transposed * Update the backend code to individually set the transposition status for each file independently. --- uploader/phenotypes/views.py | 6 +- .../phenotypes/add-phenotypes-raw-files.html | 330 +++++++++++++-------- 2 files changed, 206 insertions(+), 130 deletions(-) diff --git a/uploader/phenotypes/views.py b/uploader/phenotypes/views.py index b176890..bc15f2d 100644 --- a/uploader/phenotypes/views.py +++ b/uploader/phenotypes/views.py @@ -366,7 +366,6 @@ def process_phenotypes_rqtl2_bundle(error_uri): def process_phenotypes_individual_files(error_uri): """Process the uploaded individual files.""" form = request.form - _transposed = (form.get("file-transposed") or "off") == "on" cdata = { "sep": form["file-separator"], "comment.char": form["file-comment-character"], @@ -379,6 +378,9 @@ def process_phenotypes_individual_files(error_uri): ("pheno", "phenotype-data"), ("phenose", "phenotype-se"), ("phenonum", "phenotype-n")): + cdata[f"{rqtlkey}_transposed"] = ( + (form.get(f"{formkey}-transposed") or "off") == "on") + if form.get("resumable-upload", False): # Chunked upload of large files was used filedata = json.loads(form[formkey]) @@ -401,8 +403,6 @@ def process_phenotypes_individual_files(error_uri): arcname=filepath.name) cdata[rqtlkey] = cdata.get(rqtlkey, []) + [filepath.name] - if rqtlkey not in ("phenocovar",): - cdata[f"{rqtlkey}_transposed"] = _transposed zfile.writestr("control_data.json", data=json.dumps(cdata, indent=2)) diff --git a/uploader/templates/phenotypes/add-phenotypes-raw-files.html b/uploader/templates/phenotypes/add-phenotypes-raw-files.html index 5c6aaab..67b56e3 100644 --- a/uploader/templates/phenotypes/add-phenotypes-raw-files.html +++ b/uploader/templates/phenotypes/add-phenotypes-raw-files.html @@ -103,139 +103,215 @@ documentation for more information. - -
-
- - -
- - We expect the data in the file as a matrix of - samples × phenotypes, but it could be your file is - transposed, (i.e. it is a matrix of - “phenotypes × samples”, rather than the expected - form). -
- If that is the case for your files, mark your files as trasposed by - ensuring that this checkbox is checked. -
-
-
+
Data File(s) -
- - - - Provide a file that contains only the phenotype descriptions, - - the documentation for the expected format of the file. -
- - {{display_resumable_elements( - "resumable-phenotype-descriptions", - "phenotype descriptions", - '

You can drop a CSV file that contains the phenotype descriptions here, - or you can click the "Browse" button (below and to the right) to select it - from your computer.

-

The CSV file must conform to some standards, as documented in the - - "Phenotypes Descriptions" documentation section below.

')}} - {{display_preview_table("tbl-preview-pheno-desc", "phenotype descriptions")}} - - -
- - - - Provide a file that contains only the phenotype data. See - - the documentation for the expected format of the file. -
- - {{display_resumable_elements( - "resumable-phenotype-data", - "phenotype data", - '

You can drop a CSV file that contains the phenotype data here, - or you can click the "Browse" button (below and to the right) to select it - from your computer.

-

The CSV file must conform to some standards, as documented in the - - "Phenotypes Data" documentation section below.

')}} - {{display_preview_table("tbl-preview-pheno-data", "phenotype data")}} - - {%if population.Family in families_with_se_and_n%} -
- - - - Provide a file that contains only the standard errors for the phenotypes, - computed from the data above. -
- {{display_resumable_elements( - "resumable-phenotype-se", - "standard errors", - '

You can drop a CSV file that contains the computed standard-errors data - here, or you can click the "Browse" button (below and to the right) to - select it from your computer.

-

The CSV file must conform to some standards, as documented in the - - "Phenotypes Data" documentation section below.

')}} - {{display_preview_table("tbl-preview-pheno-se", "standard errors")}} +
+
+
+ + +
+ +
+ + + + Provide a file that contains only the phenotype descriptions, + + the documentation for the expected format of the file. +
+ {{display_resumable_elements( + "resumable-phenotype-descriptions", + "phenotype descriptions", + '

Drag and drop the CSV file that contains the descriptions of your + phenotypes here.

+ +

The CSV file should be a matrix of + phenotypes × descriptions i.e. The first column + contains the phenotype names/identifiers whereas the first row is a list + of metadata fields like, "description", "units", etc.

+ +

If the format is transposed (i.e. + descriptions × phenotypes) select the checkbox above. +

+ +

Please see the + + "Phenotypes Descriptions" documentation section below for more + information on the expected format of the file provided here.

')}} + {{display_preview_table( + "tbl-preview-pheno-desc", "phenotype descriptions")}} +
+
+ + +
+
+
+ + +
+ +
+ + + + Provide a file that contains only the phenotype data. See + + the documentation for the expected format of the file. +
+ + {{display_resumable_elements( + "resumable-phenotype-data", + "phenotype data", + '

Drag and drop a CSV file that contains the phenotypes numerical data + here. You can click the "Browse" button (below and to the right) to + select the file from your computer.

+ +

The CSV should be a matrix of samples × phenotypes, + i.e. The first column contains the samples identifiers while the first + row is the list of phenotypes identifiers occurring in the phenotypes + descriptions file.

+ +

If the format is transposed (i.e phenotypes × samples) + select the checkbox above.

+

Please see the + + "Phenotypes Data" documentation section below for more information + on the expected format for the file provided here.

')}} + {{display_preview_table("tbl-preview-pheno-data", "phenotype data")}} +
+
-
- - - - Provide a file that contains only the number of samples/individuals used in - the computation of the standard errors above. -
- {{display_resumable_elements( - "resumable-phenotype-n", - "number of samples/individuals", - '

You can drop a CSV file that contains the number of samples/individuals - used in computation of the standard-errors here, or you can click the - "Browse" button (below and to the right) to select it from your computer. -

-

The CSV file must conform to some standards, as documented in the - - "Phenotypes Data" documentation section below.

')}} - {{display_preview_table("tbl-preview-pheno-n", "number of samples/individuals")}} + {%if population.Family in families_with_se_and_n%} +
+
+
+ + +
+
+ + + + Provide a file that contains only the standard errors for the phenotypes, + computed from the data above. +
+ + {{display_resumable_elements( + "resumable-phenotype-se", + "standard errors", + '

Drag and drop a CSV file that contains the phenotypes standard-errors + data here. You can click the "Browse" button (below and to the right) to + select the file from your computer.

+ +

The CSV should be a matrix of samples × phenotypes, + i.e. The first column contains the samples identifiers while the first + row is the list of phenotypes identifiers occurring in the phenotypes + descriptions file.

+ +

If the format is transposed (i.e phenotypes × samples) + select the checkbox above.

+ +

Please see the + + "Phenotypes Data" documentation section below for more information + on the expected format of the file provided here.

')}} + + {{display_preview_table("tbl-preview-pheno-se", "standard errors")}} +
+
+ + +
+
+
+ + +
+
+ + + + Provide a file that contains only the number of samples/individuals used in + the computation of the standard errors above. +
+ + {{display_resumable_elements( + "resumable-phenotype-n", + "number of samples/individuals", + '

Drag and drop a CSV file that contains the samples\' phenotypes counts + data here. You can click the "Browse" button (below and to the right) to + select the file from your computer.

+ +

The CSV should be a matrix of samples × phenotypes, + i.e. The first column contains the samples identifiers while the first + row is the list of phenotypes identifiers occurring in the phenotypes + descriptions file.

+ +

If the format is transposed (i.e phenotypes × samples) + select the checkbox above.

+ +

Please see the + + "Phenotypes Data" documentation section below for more information + on the expected format of the file provided here.

')}} + + {{display_preview_table("tbl-preview-pheno-n", "number of samples/individuals")}} +
+
{%endif%} {%endblock%} -- cgit v1.2.3