aboutsummaryrefslogtreecommitdiff
path: root/gn3/heatmaps.py
AgeCommit message (Collapse)Author
2024-02-25Fix line-too-long error.Munyoki Kilyungi
* gn3/heatmaps.py (build_heatmap): Break down call to run_reaper command into many lines to fix pylint error. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2024-02-19Pass qtlreaper command path as argument to run_reaperzsloan
Originally the system would get the path from the environment
2023-10-06Pass in configs/settings as function argumentsFrederick Muriuki Muriithi
To avoid reliance of `flask.current_app.config` or on `gn3.settings` modules globally, this commit passes in the appropriate configurations as arguments to the relevant functions.
2022-12-21gn3: (gn3.random -> gn3.chancy): Rename module to avoid conflicts.Frederick Muriuki Muriithi
Rename the `gn3.random` module to gn3.chancy to avoid conflicts with Python's `random` module. * gn3/random.py -> gn3/chancy.py: rename module * gn3/commands.py: update import * gn3/computations/partial_correlations.py: update import * gn3/computations/qtlreaper.py: update import * gn3/computations/rust_correlation.py: update import * gn3/db/correlations.py: update import * gn3/db/traits.py: update import * gn3/heatmaps.py: update import * tests/integration/conftest.py: update import
2022-02-21Fix a myriad of linter issuesFrederick Muriuki Muriithi
* Use `with` in place of plain `open` * Use f-strings in place of `str.format()` * Remove string interpolation from queries - provide data as query parameters * other minor fixes
2021-11-11Remove redundant check on the Pearson correlation coefficient.Arun Isaac
The Pearson correlation coefficient always has a value between -1 and 1. So, this check is redundant. * gn3/heatmaps.py (cluster_traits.__compute_corr): Remove redundant check on the Pearson correlation coefficient.
2021-10-19Move 'export_trait_data' to 'gn3.db.traits' moduleFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * gn3/db/traits.py: Move function `export_trait_data` here * gn3/heatmaps.py: Remove function `export_trait_data` * tests/unit/db/test_traits.py: Move function `export_trait_data` tests here * tests/unit/test_heatmaps.py: Remove function `export_trait_data` here Function `export_trait_data` more closely corresponds to the traits and is used in more than just the `gn3.heatmaps` module. This commit moves the relevant code over to the `gn3.db.traits` module and also moves the tests to the corresponding tests modules.
2021-10-19Fix some linting issuesFrederick Muriuki Muriithi
2021-10-19Enable vertical orientation of heatmapsFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/non-clustered-heatmaps-and-flipping.gmi * Update the code to enable the generation of the heatmap in both the horizontal and vertical orientations.
2021-10-19Swap axis labelsFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/non-clustered-heatmaps-and-flipping.gmi * Switch the axis labels to make them less confusing for the user.
2021-10-19Add typing. Simplify arguments.Frederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/non-clustered-heatmaps-and-flipping.gmi * Add type-hints to the functions * Merge the axis data and labels to simpler dict arguments to reduce number of parameters to the function.
2021-10-19Remove file I/O statementsFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/non-clustered-heatmaps-and-flipping.gmi * Remove file I/O from the function. If file I/O is needed, it will be provided outside of this function.
2021-09-28Provide loci names to heatmapFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi * Provide the loci names to the heatmaps so that hovering over the heatmap cells displays the associated locus name.
2021-09-28Retrieve loci names ordered by chromosomesFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi * gn3/heatmaps.py: implement function * tests/unit/test_heatmaps.py: add test Add a function to retrieve the loci names from the traits, ordered by chromosomes, in alphabetical order. This is useful to provide the user with more information on hovering over the heatmap cells: each cell will now display the locus name, trait name and value associated with it.
2021-09-28Approximate single-spectrum colour scale in GN1Frederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi * To provide a somewhat similar experience to GeneNetwork1, this commit approximates the single-spectrum colour scale in GeneNetwork1 for the heatmaps in GeneNetwork3. Work to get the multiple-spectrum colour sc(ales/hemes) will be done in other commits, since that might require digging even deeper into Plotly's guts to figure out.
2021-09-27Update terminology: `riset` to `group`Frederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi * Update terminology to use the appropriate domain terminology according to Zachary's direction at https://github.com/genenetwork/genenetwork3/pull/37#issuecomment-926041744
2021-09-27Update terminology: `strain` to `sample`Frederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi * Update the terminology used: use `sample` in place of `strain` according to Zachary's direction at https://github.com/genenetwork/genenetwork3/pull/37#issuecomment-926043306
2021-09-22Fix typing issuesFrederick Muriuki Muriithi
* Ignore some errors * Update typing definitions for some portions of code * Add missing imports
2021-09-22Fix pylint errorsFrederick Muriuki Muriithi
* Add missing function and module docstrings * Remove unused imports * Fix import order * Rework some code sections to fix issues * Disable some pylint errors.
2021-09-22Return serialized plotly figureFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi * gn3/api/heatmaps.py: Serialize the figure to JSON * gn3/heatmaps.py: Return the figure object Serialize the Plotly figure into JSON, and return that, so that it can be used on the client to display the image.
2021-09-20Return only the dataFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi * gn3/api/heatmaps.py: Parse incoming data to build up correct trait names and respond with only the computed heatmap data. * gn3/heatmaps.py: Return only the computed data for heatmaps and clustering. Since GN3 is supposed to handle only the data, and db-access, this commit ensures that GN3 responds to the client with only the computed heatmap data, and does not try to generate the heatmaps themselves. The generation of the heatmaps will be delegated to the UI clients, such as GeneNetwork2.
2021-09-17Fix a number of linting issuesFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi
2021-09-17Fix some layout issues and update colorscaleFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi * Update the plot layouts and size to display the dendrogram and individual chromosome heatmaps side by side * Update the colour scale to begin with the grays rather than absolute black
2021-09-17Create dendrogram to show clustering treeFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi * Provide the clustering data to be used for the creation of the clustering dendrogram in the final clustered heatmap plot.
2021-09-16Fix minor bugsFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi * Fix a few minor bugs left over from the integration of code from the proof-of-concept code.
2021-09-16Add missing importsFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi * Add missing imports that are needed in the code.
2021-09-15Update entry-point function for heatmap generationFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi * Copy over code from the proof-of-concept implementation and clean it up a little for the entry-point function for heatmap generation via the API
2021-09-15Generate heatmaps in a single plotFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi * Add a function to generate the heatmaps for each chromosome into a single plot.
2021-09-15Process data into format usable by heatmapsFrederick Muriuki Muriithi
* gn3/heatmaps.py: implement `process_traits_data_for_heatmap` function, that will process the data into a form usable by heatmaps. * tests/unit/test_heatmaps.py: check that the function processes the data into the correct form.
2021-09-15Integrate get_lsr_from_chr functionFrederick Muriuki Muriithi
* gn3/heatmaps.py: copy over function * tests/unit/test_heatmaps.py: add tests Copy function over from proof of concept and add some tests to ensure it works as expected.
2021-09-15Reorganise modulesFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi * The heatmap generation does not fall cleanly within the computations or db modules. This commit moves it to the higher level gn3 module.