From 4f994b79ecee851ea1cd0fa0699ee822c8884bc4 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Thu, 10 Oct 2024 16:18:52 -0500 Subject: Build UI to add new phenotypes. Build the UI and set up styling. This is not working currently. --- uploader/phenotypes/views.py | 22 ++ uploader/static/css/styles.css | 20 ++ uploader/templates/phenotypes/add-phenotypes.html | 222 +++++++++++++++++++++ .../macro-display-pheno-dataset-card.html | 23 +++ uploader/templates/phenotypes/view-dataset.html | 14 +- 5 files changed, 297 insertions(+), 4 deletions(-) create mode 100644 uploader/templates/phenotypes/add-phenotypes.html create mode 100644 uploader/templates/phenotypes/macro-display-pheno-dataset-card.html (limited to 'uploader') diff --git a/uploader/phenotypes/views.py b/uploader/phenotypes/views.py index ddf6908..eb0b460 100644 --- a/uploader/phenotypes/views.py +++ b/uploader/phenotypes/views.py @@ -286,3 +286,25 @@ def create_dataset(species: dict, population: dict, **kwargs):# pylint: disable= return redirect(url_for("species.populations.phenotypes.list_datasets", species_id=species["SpeciesId"], population_id=population["Id"])) + + +@phenotypesbp.route( + "/populations//phenotypes/datasets" + "//add-phenotypes", + methods=["GET", "POST"]) +@require_login +@with_dataset( + species_redirect_uri="species.populations.phenotypes.index", + population_redirect_uri="species.populations.phenotypes.select_population", + redirect_uri="species.populations.phenotypes.list_datasets") +def add_phenotypes(species: dict, population: dict, dataset: dict, **kwargs): + """Add one or more phenotypes to the dataset.""" + with (database_connection(app.config["SQL_URI"]) as conn, + conn.cursor(cursorclass=DictCursor) as cursor): + if request.method == "GET": + return render_template("phenotypes/add-phenotypes.html", + species=species, + population=population, + dataset=dataset, + activelink="add-phenotypes") + raise NotImplementedError("Please implement this...") diff --git a/uploader/static/css/styles.css b/uploader/static/css/styles.css index 0e9a029..5161169 100644 --- a/uploader/static/css/styles.css +++ b/uploader/static/css/styles.css @@ -131,3 +131,23 @@ input[type="submit"], .btn { border-color: #DCA7A7; background-color: #F2DEDE; } + +.heading { + border-bottom: solid #EEBB88; +} + +.subheading { + padding: 1em 0 0.1em 0.5em; + border-bottom: solid #88BBEE; +} + +form { + margin-top: 0.3em; + background: #E5E5FF; + padding: 0.5em; + border-radius:0.5em; +} + +form .form-control { + background-color: #EAEAFF; +} diff --git a/uploader/templates/phenotypes/add-phenotypes.html b/uploader/templates/phenotypes/add-phenotypes.html new file mode 100644 index 0000000..20f8087 --- /dev/null +++ b/uploader/templates/phenotypes/add-phenotypes.html @@ -0,0 +1,222 @@ +{%extends "phenotypes/base.html"%} +{%from "flash_messages.html" import flash_all_messages%} +{%from "macro-table-pagination.html" import table_pagination%} +{%from "phenotypes/macro-display-pheno-dataset-card.html" import display_pheno_dataset_card%} + +{%block title%}Phenotypes{%endblock%} + +{%block pagetitle%}Phenotypes{%endblock%} + +{%block lvl4_breadcrumbs%} + +{%endblock%} + +{%block contents%} +{{flash_all_messages()}} + +
+
+ Add New Phenotypes + +
+

Select the zip file bundle containing information on the phenotypes you + wish to upload, then click the "Upload Phenotypes" button below to + upload the data.

+

See the File Formats section below + to get an understanding of what is expected of the bundle files you + upload.

+

This will not update any existing phenotypes!

+
+ +
+ + +
+ +
+ +
+
+
+ +
+

File Formats

+

We accept an extended form of the + + input files' format used with the R/qtl2 software as a single ZIP + file

+

The following section will detail the expectations for each of the + different file types within the uploaded ZIP file bundle for phenotypes:

+ +

Control File

+

There MUST be one, and only one file that acts + as the control file. This file can be: +

    +
  • a JSON file, or
  • +
  • a YAML file.
  • +
+

+ +

The control file is useful for defining things about the bundle such as:

+
    +
  • The field separator value (default: sep: ','). There can + only ever be one field separator and it MUST be the same + one for ALL files in the bundle.
  • +
  • The comment character (default: comment.char: '#'). Any + line that starts with this character will be considered a comment line and + be ignored in its entirety.
  • +
  • Code for missing values (default: na.strings: 'NA'). You + can specify more than one code to indicate missing values, e.g. + {…, "na.strings": ["NA", "N/A", "-"], …}
  • +
+ +

pheno File(s)

+

These files are the main data files. You must have at least one of these + files in your bundle for it to be valid for this step.

+

The data is a matrix of individuals × phenotypes by default, as + below:
+ + id,10001,10002,10003,10004,…
+ BXD1,61.400002,54.099998,483,49.799999,…
+ BXD2,49,50.099998,403,45.5,…
+ BXD5,62.5,53.299999,501,62.900002,…
+ BXD6,53.099998,55.099998,403,NA,…
+ ⋮
+

+

If the pheno_transposed value is set to True, + then the data will be a phenotypes × individuals matrix as in the + example below:
+ + id,BXD1,BXD2,BXD5,BXD6,…
+ 10001,61.400002,49,62.5,53.099998,…
+ 10002,54.099998,50.099998,53.299999,55.099998,…
+ 10003,483,403,501,403,…
+ 10004,49.799999,45.5,62.900002,NA,…
+ ⋮ +
+

+ + +

phenocovar File(s)

+

At least one phenotypes metadata file with the metadata values such as + descriptions, PubMed Identifier, publication titles (if present), etc.

+

The data in this/these file(s) is a matrix of + phenotypes × phenotypes-covariates. The first column is always the + phenotype names/identifiers — same as in the R/qtl2 format.

+

phenocovar files should never be transposed!

+

This file MUST be present in the bundle, and have data for + the bundle to be considered valid by our system for this step.
+ In addition to that, the following are the fields that must be + present, and + have values, in the file before the file is considered valid: +

    +
  • description: A description for each phenotype. Useful + for users to know what the phenotype is about.
  • +
  • units: The units of measurement for the phenotype, + e.g. milligrams for brain weight, centimetres/millimetres for + tail-length, etc.
  • +

+ +

The following optional fields can also be provided: +

    +
  • pubmedid: A PubMed Identifier for the publication where + the phenotype is published. If this field is not provided, the system will + assume your phenotype is not published.
  • +
+

+

These files will be marked up in the control file with the + phenocovar key, as in the examples below: +

    +
  1. JSON: single file
    + {
    +   ⋮,
    +   "phenocovar": "your_covariates_file.csv",
    +   ⋮
    + } +
    +
  2. +
  3. JSON: multiple files
    + {
    +   ⋮,
    +   "phenocovar": [
    +     "covariates_file_01.csv",
    +     "covariates_file_01.csv",
    +     ⋮
    +   ],
    +   ⋮
    + } +
    +
  4. +
  5. YAML: single file or
    + + ⋮
    + phenocovar: your_covariates_file.csv
    + ⋮ +
    +
  6. +
  7. YAML: multiple files
    + + ⋮
    + phenocovar:
    + - covariates_file_01.csv
    + - covariates_file_02.csv
    + - covariates_file_03.csv
    + …
    + ⋮ +
    +
  8. +
+

+ +

phenose and phenonum File(s)

+

These are extensions to the R/qtl2 standard, i.e. these types ofs file are + not supported by the original R/qtl2 file format

+

We use these files to upload the standard errors (phenose) when + the data file (pheno) is average data. In that case, the + phenonum file(s) contains the number of individuals that were + involved when computing the averages.

+

Both types of files are matrices of individuals × phenotypes by + default. Like the related pheno files, if + pheno_transposed: True, then the file will be a matrix of + phenotypes × individuals.

+
+ +
+

Notes for Devs (well… Fred, really.)

+

Use the following resources for automated retrieval of certain data

+ +
+ +{%endblock%} + +{%block sidebarcontents%} +{{display_pheno_dataset_card(species, population, dataset)}} +{%endblock%} diff --git a/uploader/templates/phenotypes/macro-display-pheno-dataset-card.html b/uploader/templates/phenotypes/macro-display-pheno-dataset-card.html new file mode 100644 index 0000000..1121443 --- /dev/null +++ b/uploader/templates/phenotypes/macro-display-pheno-dataset-card.html @@ -0,0 +1,23 @@ +{%from "populations/macro-display-population-card.html" import display_population_card%} + +{%macro display_pheno_dataset_card(species, population, dataset)%} +{{display_population_card(species, population)}} + +
+
+
Phenotypes' Dataset
+
+
+
Name
+
{{dataset.Name}}
+ +
Full Name
+
{{dataset.FullName}}
+ +
Short Name
+
{{dataset.ShortName}}
+
+
+
+
+{%endmacro%} diff --git a/uploader/templates/phenotypes/view-dataset.html b/uploader/templates/phenotypes/view-dataset.html index 5a17755..b136bb6 100644 --- a/uploader/templates/phenotypes/view-dataset.html +++ b/uploader/templates/phenotypes/view-dataset.html @@ -37,10 +37,7 @@ - {{dataset.Name}} + {{dataset.Name}} {{dataset.FullName}} {{dataset.ShortName}} @@ -48,6 +45,15 @@ + +

Phenotype Data

-- cgit v1.2.3